Title: [177274] trunk/Source/WebCore
Revision
177274
Author
[email protected]
Date
2014-12-15 01:50:23 -0800 (Mon, 15 Dec 2014)

Log Message

Move 'counter-increment' / 'counter-reset' to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=139635

Reviewed by Antti Koivisto.

Move 'counter-increment' / 'counter-reset' to the new StyleBuilder by
using custom code.

No new tests, no behavior change.

* css/CSSPropertyNames.in:
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::ApplyPropertyCounter::emptyFunction): Deleted.
(WebCore::ApplyPropertyCounter::applyInheritValue): Deleted.
(WebCore::ApplyPropertyCounter::applyValue): Deleted.
(WebCore::ApplyPropertyCounter::createHandler): Deleted.
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyInitialCounterIncrement):
(WebCore::StyleBuilderCustom::applyInitialCounterReset):
(WebCore::StyleBuilderCustom::applyInheritCounter):
(WebCore::StyleBuilderCustom::applyValueCounter):
(WebCore::StyleBuilderCustom::applyInheritCounterIncrement):
(WebCore::StyleBuilderCustom::applyValueCounterIncrement):
(WebCore::StyleBuilderCustom::applyInheritCounterReset):
(WebCore::StyleBuilderCustom::applyValueCounterReset):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (177273 => 177274)


--- trunk/Source/WebCore/ChangeLog	2014-12-15 06:40:12 UTC (rev 177273)
+++ trunk/Source/WebCore/ChangeLog	2014-12-15 09:50:23 UTC (rev 177274)
@@ -1,3 +1,32 @@
+2014-12-15  Chris Dumez  <[email protected]>
+
+        Move 'counter-increment' / 'counter-reset' to the new StyleBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=139635
+
+        Reviewed by Antti Koivisto.
+
+        Move 'counter-increment' / 'counter-reset' to the new StyleBuilder by
+        using custom code.
+
+        No new tests, no behavior change.
+
+        * css/CSSPropertyNames.in:
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
+        (WebCore::ApplyPropertyCounter::emptyFunction): Deleted.
+        (WebCore::ApplyPropertyCounter::applyInheritValue): Deleted.
+        (WebCore::ApplyPropertyCounter::applyValue): Deleted.
+        (WebCore::ApplyPropertyCounter::createHandler): Deleted.
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderCustom::applyInitialCounterIncrement):
+        (WebCore::StyleBuilderCustom::applyInitialCounterReset):
+        (WebCore::StyleBuilderCustom::applyInheritCounter):
+        (WebCore::StyleBuilderCustom::applyValueCounter):
+        (WebCore::StyleBuilderCustom::applyInheritCounterIncrement):
+        (WebCore::StyleBuilderCustom::applyValueCounterIncrement):
+        (WebCore::StyleBuilderCustom::applyInheritCounterReset):
+        (WebCore::StyleBuilderCustom::applyValueCounterReset):
+
 2014-12-14  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r177238 and r177244.

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (177273 => 177274)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2014-12-15 06:40:12 UTC (rev 177273)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2014-12-15 09:50:23 UTC (rev 177274)
@@ -166,8 +166,8 @@
 clip [Custom=All]
 -webkit-clip-path [Converter=ClipPath]
 content [LegacyStyleBuilder]
-counter-increment [LegacyStyleBuilder]
-counter-reset [LegacyStyleBuilder]
+counter-increment [Custom=All]
+counter-reset [Custom=All]
 cursor [Inherited, LegacyStyleBuilder]
 #if defined(ENABLE_CURSOR_VISIBILITY) && ENABLE_CURSOR_VISIBILITY
 -webkit-cursor-visibility [Inherited, TypeName=CursorVisibility]

Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (177273 => 177274)


--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-12-15 06:40:12 UTC (rev 177273)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-12-15 09:50:23 UTC (rev 177274)
@@ -626,72 +626,6 @@
     }
 };
 
-enum CounterBehavior {Increment = 0, Reset};
-template <CounterBehavior counterBehavior>
-class ApplyPropertyCounter {
-public:
-    static void emptyFunction(CSSPropertyID, StyleResolver*) { }
-    static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
-    {
-        CounterDirectiveMap& map = styleResolver->style()->accessCounterDirectives();
-        CounterDirectiveMap& parentMap = styleResolver->parentStyle()->accessCounterDirectives();
-
-        typedef CounterDirectiveMap::iterator Iterator;
-        Iterator end = parentMap.end();
-        for (Iterator it = parentMap.begin(); it != end; ++it) {
-            CounterDirectives& directives = map.add(it->key, CounterDirectives()).iterator->value;
-            if (counterBehavior == Reset) {
-                directives.inheritReset(it->value);
-            } else {
-                directives.inheritIncrement(it->value);
-            }
-        }
-    }
-    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
-    {
-        bool setCounterIncrementToNone = counterBehavior == Increment && is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).getValueID() == CSSValueNone;
-
-        if (!is<CSSValueList>(*value) && !setCounterIncrementToNone)
-            return;
-
-        CounterDirectiveMap& map = styleResolver->style()->accessCounterDirectives();
-        typedef CounterDirectiveMap::iterator Iterator;
-
-        Iterator end = map.end();
-        for (Iterator it = map.begin(); it != end; ++it)
-            if (counterBehavior == Reset)
-                it->value.clearReset();
-            else
-                it->value.clearIncrement();
-        
-        if (setCounterIncrementToNone)
-            return;
-        
-        CSSValueList& list = downcast<CSSValueList>(*value);
-        int length = list.length();
-        for (int i = 0; i < length; ++i) {
-            CSSValue* currValue = list.itemWithoutBoundsCheck(i);
-            if (!is<CSSPrimitiveValue>(*currValue))
-                continue;
-
-            Pair* pair = downcast<CSSPrimitiveValue>(*currValue).getPairValue();
-            if (!pair || !pair->first() || !pair->second())
-                continue;
-
-            AtomicString identifier = static_cast<CSSPrimitiveValue*>(pair->first())->getStringValue();
-            int value = static_cast<CSSPrimitiveValue*>(pair->second())->getIntValue();
-            CounterDirectives& directives = map.add(identifier, CounterDirectives()).iterator->value;
-            if (counterBehavior == Reset) {
-                directives.setResetValue(value);
-            } else {
-                directives.addIncrementValue(value);
-            }
-        }
-    }
-    static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &emptyFunction, &applyValue); }
-};
-
-
 class ApplyPropertyCursor {
 public:
     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
@@ -884,8 +818,6 @@
     setPropertyHandler(CSSPropertyBorderRightColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderRightColor, &RenderStyle::setBorderRightColor, &RenderStyle::setVisitedLinkBorderRightColor, &RenderStyle::color>::createHandler());
     setPropertyHandler(CSSPropertyBorderTopColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderTopColor, &RenderStyle::setBorderTopColor, &RenderStyle::setVisitedLinkBorderTopColor, &RenderStyle::color>::createHandler());
     setPropertyHandler(CSSPropertyColor, ApplyPropertyColor<InheritFromParent, &RenderStyle::color, &RenderStyle::setColor, &RenderStyle::setVisitedLinkColor, &RenderStyle::invalidColor, RenderStyle::initialColor>::createHandler());
-    setPropertyHandler(CSSPropertyCounterIncrement, ApplyPropertyCounter<Increment>::createHandler());
-    setPropertyHandler(CSSPropertyCounterReset, ApplyPropertyCounter<Reset>::createHandler());
     setPropertyHandler(CSSPropertyCursor, ApplyPropertyCursor::createHandler());
     setPropertyHandler(CSSPropertyFontSize, ApplyPropertyFontSize::createHandler());
     setPropertyHandler(CSSPropertyFontStyle, ApplyPropertyFont<FontItalic, &FontDescription::italic, &FontDescription::setItalic, FontItalicOff>::createHandler());

Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (177273 => 177274)


--- trunk/Source/WebCore/css/StyleBuilderCustom.h	2014-12-15 06:40:12 UTC (rev 177273)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h	2014-12-15 09:50:23 UTC (rev 177274)
@@ -134,6 +134,13 @@
     static void applyInheritWebkitTextEmphasisStyle(StyleResolver&);
     static void applyValueWebkitTextEmphasisStyle(StyleResolver&, CSSValue&);
 
+    static void applyInitialCounterIncrement(StyleResolver&) { }
+    static void applyInheritCounterIncrement(StyleResolver&);
+    static void applyValueCounterIncrement(StyleResolver&, CSSValue&);
+    static void applyInitialCounterReset(StyleResolver&) { }
+    static void applyInheritCounterReset(StyleResolver&);
+    static void applyValueCounterReset(StyleResolver&, CSSValue&);
+
 private:
     static void resetEffectiveZoom(StyleResolver&);
     static CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver&);
@@ -146,6 +153,12 @@
     template <CSSPropertyID id>
     static void applyTextOrBoxShadowValue(StyleResolver&, CSSValue&);
     static bool isValidDisplayValue(StyleResolver&, EDisplay);
+
+    enum CounterBehavior {Increment = 0, Reset};
+    template <CounterBehavior counterBehavior>
+    static void applyInheritCounter(StyleResolver&);
+    template <CounterBehavior counterBehavior>
+    static void applyValueCounter(StyleResolver&, CSSValue&);
 };
 
 inline void StyleBuilderCustom::applyValueWebkitMarqueeIncrement(StyleResolver& styleResolver, CSSValue& value)
@@ -1100,6 +1113,73 @@
     }
 }
 
+template <StyleBuilderCustom::CounterBehavior counterBehavior>
+inline void StyleBuilderCustom::applyInheritCounter(StyleResolver& styleResolver)
+{
+    CounterDirectiveMap& map = styleResolver.style()->accessCounterDirectives();
+    for (auto& keyValue : styleResolver.parentStyle()->accessCounterDirectives()) {
+        CounterDirectives& directives = map.add(keyValue.key, CounterDirectives()).iterator->value;
+        if (counterBehavior == Reset)
+            directives.inheritReset(keyValue.value);
+        else
+            directives.inheritIncrement(keyValue.value);
+    }
+}
+
+template <StyleBuilderCustom::CounterBehavior counterBehavior>
+inline void StyleBuilderCustom::applyValueCounter(StyleResolver& styleResolver, CSSValue& value)
+{
+    bool setCounterIncrementToNone = counterBehavior == Increment && is<CSSPrimitiveValue>(value) && downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueNone;
+
+    if (!is<CSSValueList>(value) && !setCounterIncrementToNone)
+        return;
+
+    CounterDirectiveMap& map = styleResolver.style()->accessCounterDirectives();
+    for (auto& keyValue : map) {
+        if (counterBehavior == Reset)
+            keyValue.value.clearReset();
+        else
+            keyValue.value.clearIncrement();
+    }
+
+    if (setCounterIncrementToNone)
+        return;
+
+    for (auto& item : downcast<CSSValueList>(value)) {
+        Pair* pair = downcast<CSSPrimitiveValue>(item.get()).getPairValue();
+        if (!pair || !pair->first() || !pair->second())
+            continue;
+
+        AtomicString identifier = pair->first()->getStringValue();
+        int value = pair->second()->getIntValue();
+        CounterDirectives& directives = map.add(identifier, CounterDirectives()).iterator->value;
+        if (counterBehavior == Reset)
+            directives.setResetValue(value);
+        else
+            directives.addIncrementValue(value);
+    }
+}
+
+inline void StyleBuilderCustom::applyInheritCounterIncrement(StyleResolver& styleResolver)
+{
+    applyInheritCounter<Increment>(styleResolver);
+}
+
+inline void StyleBuilderCustom::applyValueCounterIncrement(StyleResolver& styleResolver, CSSValue& value)
+{
+    applyValueCounter<Increment>(styleResolver, value);
+}
+
+inline void StyleBuilderCustom::applyInheritCounterReset(StyleResolver& styleResolver)
+{
+    applyInheritCounter<Reset>(styleResolver);
+}
+
+inline void StyleBuilderCustom::applyValueCounterReset(StyleResolver& styleResolver, CSSValue& value)
+{
+    applyValueCounter<Reset>(styleResolver, value);
+}
+
 } // namespace WebCore
 
 #endif // StyleBuilderCustom_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to