Title: [120696] trunk/Source/WebCore
Revision
120696
Author
[email protected]
Date
2012-06-19 02:10:09 -0700 (Tue, 19 Jun 2012)

Log Message

Make StylePropertySet::merge() always override on conflict
https://bugs.webkit.org/show_bug.cgi?id=89348

Patch by Thiago Marcos P. Santos <[email protected]> on 2012-06-19
Reviewed by Ryosuke Niwa.

merge() was only used with argOverridesOnConflict = true, which
makes the extra parameter useless. It will also save a boolean check.

* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::mergeAndOverrideOnConflict):
* css/StylePropertySet.h:
(StylePropertySet):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):
* editing/EditingStyle.cpp:
(WebCore::EditingStyle::overrideWithStyle):
(WebCore::styleFromMatchedRulesForElement):
(WebCore::EditingStyle::mergeStyleFromRules):
(WebCore::EditingStyle::mergeStyleFromRulesForSerialization):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (120695 => 120696)


--- trunk/Source/WebCore/ChangeLog	2012-06-19 08:57:14 UTC (rev 120695)
+++ trunk/Source/WebCore/ChangeLog	2012-06-19 09:10:09 UTC (rev 120696)
@@ -1,3 +1,25 @@
+2012-06-19  Thiago Marcos P. Santos  <[email protected]>
+
+        Make StylePropertySet::merge() always override on conflict
+        https://bugs.webkit.org/show_bug.cgi?id=89348
+
+        Reviewed by Ryosuke Niwa.
+
+        merge() was only used with argOverridesOnConflict = true, which
+        makes the extra parameter useless. It will also save a boolean check.
+
+        * css/StylePropertySet.cpp:
+        (WebCore::StylePropertySet::mergeAndOverrideOnConflict):
+        * css/StylePropertySet.h:
+        (StylePropertySet):
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):
+        * editing/EditingStyle.cpp:
+        (WebCore::EditingStyle::overrideWithStyle):
+        (WebCore::styleFromMatchedRulesForElement):
+        (WebCore::EditingStyle::mergeStyleFromRules):
+        (WebCore::EditingStyle::mergeStyleFromRulesForSerialization):
+
 2012-06-19  Yoshifumi Inoue  <[email protected]>
 
         [Forms] Move isKeyboardFocusable and isMouseFocusable to InputType from HTMLInputElement

Modified: trunk/Source/WebCore/css/StylePropertySet.cpp (120695 => 120696)


--- trunk/Source/WebCore/css/StylePropertySet.cpp	2012-06-19 08:57:14 UTC (rev 120695)
+++ trunk/Source/WebCore/css/StylePropertySet.cpp	2012-06-19 09:10:09 UTC (rev 120696)
@@ -861,18 +861,16 @@
     return result.toString();
 }
 
-void StylePropertySet::merge(const StylePropertySet* other, bool argOverridesOnConflict)
+void StylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other)
 {
     ASSERT(isMutable());
     unsigned size = other->propertyCount();
     for (unsigned n = 0; n < size; ++n) {
         const CSSProperty& toMerge = other->propertyAt(n);
         CSSProperty* old = findPropertyWithId(toMerge.id());
-        if (old) {
-            if (!argOverridesOnConflict && old->value())
-                continue;
+        if (old)
             setProperty(toMerge, old);
-        } else
+        else
             append(toMerge);
     }
 }

Modified: trunk/Source/WebCore/css/StylePropertySet.h (120695 => 120696)


--- trunk/Source/WebCore/css/StylePropertySet.h	2012-06-19 08:57:14 UTC (rev 120695)
+++ trunk/Source/WebCore/css/StylePropertySet.h	2012-06-19 09:10:09 UTC (rev 120696)
@@ -83,7 +83,7 @@
     void removeBlockProperties();
     bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
 
-    void merge(const StylePropertySet*, bool argOverridesOnConflict = true);
+    void mergeAndOverrideOnConflict(const StylePropertySet*);
 
     void setCSSParserMode(CSSParserMode);
     CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); }

Modified: trunk/Source/WebCore/editing/ApplyStyleCommand.cpp (120695 => 120696)


--- trunk/Source/WebCore/editing/ApplyStyleCommand.cpp	2012-06-19 08:57:14 UTC (rev 120695)
+++ trunk/Source/WebCore/editing/ApplyStyleCommand.cpp	2012-06-19 09:10:09 UTC (rev 120696)
@@ -736,7 +736,7 @@
             // Add to this element's inline style and skip over its contents.
             HTMLElement* element = toHTMLElement(node.get());
             RefPtr<StylePropertySet> inlineStyle = element->ensureInlineStyle()->copy();
-            inlineStyle->merge(style->style());
+            inlineStyle->mergeAndOverrideOnConflict(style->style());
             setNodeAttribute(element, styleAttr, inlineStyle->asText());
             next = node->traverseNextSibling();
             continue;

Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (120695 => 120696)


--- trunk/Source/WebCore/editing/EditingStyle.cpp	2012-06-19 08:57:14 UTC (rev 120695)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp	2012-06-19 09:10:09 UTC (rev 120696)
@@ -529,7 +529,7 @@
         return;
     if (!m_mutableStyle)
         m_mutableStyle = StylePropertySet::create();
-    m_mutableStyle->merge(style);
+    m_mutableStyle->mergeAndOverrideOnConflict(style);
     extractFontSizeDelta();
 }
 
@@ -1066,7 +1066,7 @@
     if (matchedRules) {
         for (unsigned i = 0; i < matchedRules->length(); i++) {
             if (matchedRules->item(i)->type() == CSSRule::STYLE_RULE)
-                style->merge(static_cast<CSSStyleRule*>(matchedRules->item(i))->styleRule()->properties(), true);
+                style->mergeAndOverrideOnConflict(static_cast<CSSStyleRule*>(matchedRules->item(i))->styleRule()->properties());
         }
     }
     
@@ -1080,7 +1080,7 @@
     // Styles from the inline style declaration, held in the variable "style", take precedence 
     // over those from matched rules.
     if (m_mutableStyle)
-        styleFromMatchedRules->merge(m_mutableStyle.get());
+        styleFromMatchedRules->mergeAndOverrideOnConflict(m_mutableStyle.get());
 
     clear();
     m_mutableStyle = styleFromMatchedRules;
@@ -1108,7 +1108,7 @@
             }
         }
     }
-    m_mutableStyle->merge(fromComputedStyle.get());
+    m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get());
 }
 
 static void removePropertiesInStyle(StylePropertySet* styleToRemovePropertiesFrom, StylePropertySet* style)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to