Non inheritable CSS properties are not preserved when merging paragraphs
authorGrzegorz Czajkowski <g.czajkowski@samsung.com>
Fri, 17 May 2013 08:06:02 +0000 (10:06 +0200)
committerGrzegorz Czajkowski <g.czajkowski@samsung.com>
Mon, 3 Jun 2013 12:56:48 +0000 (14:56 +0200)
In 'mergeInlineAndImplicitStyleOfElement' we get style from matched rules.
If they contain either background-color or text-decoration they will be removed
in removeNonEditingProperties() due to implicit OnlyInheritableEditingProperties
parameter.
We have already had similar issue at https://bugs.webkit.org/show_bug.cgi?id=53196

This is being discussed at https://bugs.webkit.org/show_bug.cgi?id=116215.

Change-Id: I63a37cbf5a7f729487c52e824f57941782a37da0

Source/WTF/wtf/Platform.h
Source/WebCore/editing/EditingStyle.cpp
Source/WebCore/editing/EditingStyle.h

index 3316d65..8f463c5 100755 (executable)
 #define ENABLE_TIZEN_USE_SETTINGS_FONT 1 /* Hyeonji Kim(hyeonji.kim@samsung.com) : When font-family is "Tizen", use system's setting font as default font-family */
 #define ENABLE_TIZEN_PARAGRAPH_SEPARATOR_FIX 1 /* Michal Pakula (m.pakula@samsung.com) : This is a quick fix for a bug where new paragraph was not created on contenteditable area with image and text nodes inside span tag */
 #define ENABLE_TIZEN_CONTENT_EDITABLE_BACKSPACE 1 /* Wojciech Bielawski(w.bielawski.com) : This is a quick fix for a bug where after pressing backspace image was moved not correctly */
+#define ENABLE_TIZEN_PRESERVE_PROPERTIES_WHEN_PARAGRAPH_MERGE 1 /* Grzegorz Czajkowski (g.czajkowski@samsung.com): This is a quick fix for background-color and text-decoration defined in class are not copied when paragraph is merged.  We erroneously copy only CSS inheritable properties via removeNonEditingProperties(). */
 
 #if ENABLE(TEXT_AUTOSIZING)
 #define ENABLE_TIZEN_TEXT_AUTOSIZING 1 /* Jaehun Lim(ljaehun.lim@samsung.com) : for Tizen environment */
index d166f9d..e9f6048 100644 (file)
@@ -618,10 +618,18 @@ void EditingStyle::removeStyleConflictingWithStyleOfNode(Node* node)
         m_mutableStyle->removeProperty(nodeStyle->propertyAt(i).id());
 }
 
+#if ENABLE(TIZEN_PRESERVE_PROPERTIES_WHEN_PARAGRAPH_MERGE)
+void EditingStyle::removeNonEditingProperties(bool removeNonInheritableEditingProperties)
+#else
 void EditingStyle::removeNonEditingProperties()
+#endif
 {
     if (m_mutableStyle)
+#if ENABLE(TIZEN_PRESERVE_PROPERTIES_WHEN_PARAGRAPH_MERGE)
+        m_mutableStyle = copyEditingProperties(m_mutableStyle.get(), removeNonInheritableEditingProperties ? OnlyInheritableEditingProperties : AllEditingProperties);
+#else
         m_mutableStyle = copyEditingProperties(m_mutableStyle.get());
+#endif
 }
 
 void EditingStyle::collapseTextDecorationProperties()
@@ -982,7 +990,11 @@ void EditingStyle::mergeInlineAndImplicitStyleOfElement(StyledElement* element,
 {
     RefPtr<EditingStyle> styleFromRules = EditingStyle::create();
     styleFromRules->mergeStyleFromRulesForSerialization(element);
+#if ENABLE(TIZEN_PRESERVE_PROPERTIES_WHEN_PARAGRAPH_MERGE)
+    styleFromRules->removeNonEditingProperties(propertiesToInclude == OnlyEditingInheritableProperties);
+#else
     styleFromRules->removeNonEditingProperties();
+#endif
     mergeStyle(styleFromRules->m_mutableStyle.get(), mode);
 
     mergeInlineStyleOfElement(element, mode, propertiesToInclude);
index 00e9d57..c96e7c3 100644 (file)
@@ -110,7 +110,11 @@ public:
     void removeBlockProperties();
     void removeStyleAddedByNode(Node*);
     void removeStyleConflictingWithStyleOfNode(Node*);
+#if ENABLE(TIZEN_PRESERVE_PROPERTIES_WHEN_PARAGRAPH_MERGE)
+    void removeNonEditingProperties(bool removeNonInheritableEditingProperties = true);
+#else
     void removeNonEditingProperties();
+#endif
     void collapseTextDecorationProperties();
     enum ShouldIgnoreTextOnlyProperties { IgnoreTextOnlyProperties, DoNotIgnoreTextOnlyProperties };
     TriState triStateOfStyle(EditingStyle*) const;