Title: [91336] trunk/Source/WebCore
Revision
91336
Author
[email protected]
Date
2011-07-19 22:41:16 -0700 (Tue, 19 Jul 2011)

Log Message

Implement CSSPropertyCounterIncrement and CounterReset in CSSStyleApplyProperty.
https://bugs.webkit.org/show_bug.cgi?id=64846

Reviewed by Dimitri Glazkov.

No new tests / refactoring only.

* css/CSSStyleApplyProperty.cpp:
(WebCore::ApplyPropertyCounter
Added class to handle counter properties.
(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
Initialize counter property handlers.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
Remove old handlers.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (91335 => 91336)


--- trunk/Source/WebCore/ChangeLog	2011-07-20 05:31:12 UTC (rev 91335)
+++ trunk/Source/WebCore/ChangeLog	2011-07-20 05:41:16 UTC (rev 91336)
@@ -1,3 +1,21 @@
+2011-07-19  Luke Macpherson   <[email protected]>
+
+        Implement CSSPropertyCounterIncrement and CounterReset in CSSStyleApplyProperty.
+        https://bugs.webkit.org/show_bug.cgi?id=64846
+
+        Reviewed by Dimitri Glazkov.
+
+        No new tests / refactoring only.
+
+        * css/CSSStyleApplyProperty.cpp:
+        (WebCore::ApplyPropertyCounter
+        Added class to handle counter properties.
+        (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
+        Initialize counter property handlers.
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        Remove old handlers.
+
 2011-07-19  Kent Tamura  <[email protected]>
 
         REGRESSION(r89004): Video pauses and never resumes playing if scrubbed during playback.

Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (91335 => 91336)


--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp	2011-07-20 05:31:12 UTC (rev 91335)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp	2011-07-20 05:41:16 UTC (rev 91336)
@@ -506,6 +506,60 @@
     }
 };
 
+enum CounterBehavior {Increment = 0, Reset};
+template <CounterBehavior counterBehavior>
+class ApplyPropertyCounter : public ApplyPropertyBase {
+private:
+    virtual void applyInheritValue(CSSStyleSelector*) const { }
+    virtual void applyInitialValue(CSSStyleSelector*) const { }
+
+    virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const
+    {
+        if (!value->isValueList())
+            return;
+
+        CSSValueList* list = static_cast<CSSValueList*>(value);
+
+        CounterDirectiveMap& map = selector->style()->accessCounterDirectives();
+        typedef CounterDirectiveMap::iterator Iterator;
+
+        Iterator end = map.end();
+        for (Iterator it = map.begin(); it != end; ++it)
+            if (counterBehavior)
+                it->second.m_reset = false;
+            else
+                it->second.m_increment = false;
+
+        int length = list ? list->length() : 0;
+        for (int i = 0; i < length; ++i) {
+            CSSValue* currValue = list->itemWithoutBoundsCheck(i);
+            if (!currValue->isPrimitiveValue())
+                continue;
+
+            Pair* pair = static_cast<CSSPrimitiveValue*>(currValue)->getPairValue();
+            if (!pair || !pair->first() || !pair->second())
+                continue;
+
+            AtomicString identifier = static_cast<CSSPrimitiveValue*>(pair->first())->getStringValue();
+            // FIXME: What about overflow?
+            int value = static_cast<CSSPrimitiveValue*>(pair->second())->getIntValue();
+            CounterDirectives& directives = map.add(identifier.impl(), CounterDirectives()).first->second;
+            if (counterBehavior) {
+                directives.m_reset = true;
+                directives.m_resetValue = value;
+            } else {
+                if (directives.m_increment)
+                    directives.m_incrementValue += value;
+                else {
+                    directives.m_increment = true;
+                    directives.m_incrementValue = value;
+                }
+            }
+        }
+    }
+};
+
+
 class ApplyPropertyCursor : public ApplyPropertyBase {
 private:
     virtual void applyInheritValue(CSSStyleSelector* selector) const
@@ -668,6 +722,9 @@
 
     setPropertyHandler(CSSPropertyCursor, new ApplyPropertyCursor());
 
+    setPropertyHandler(CSSPropertyCounterIncrement, new ApplyPropertyCounter<Increment>());
+    setPropertyHandler(CSSPropertyCounterReset, new ApplyPropertyCounter<Reset>());
+
     setPropertyHandler(CSSPropertyFontStyle, new ApplyPropertyFont<FontItalic>(&FontDescription::italic, &FontDescription::setItalic, FontItalicOff));
     setPropertyHandler(CSSPropertyFontVariant, new ApplyPropertyFont<FontSmallCaps>(&FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff));
     setPropertyHandler(CSSPropertyTextRendering, new ApplyPropertyFont<TextRenderingMode>(&FontDescription::textRenderingMode, &FontDescription::setTextRenderingMode, AutoTextRendering));

Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (91335 => 91336)


--- trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-07-20 05:31:12 UTC (rev 91335)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-07-20 05:41:16 UTC (rev 91336)
@@ -3562,46 +3562,6 @@
     return "";
 }
 
-static void applyCounterList(RenderStyle* style, CSSValueList* list, bool isReset)
-{
-    CounterDirectiveMap& map = style->accessCounterDirectives();
-    typedef CounterDirectiveMap::iterator Iterator;
-
-    Iterator end = map.end();
-    for (Iterator it = map.begin(); it != end; ++it)
-        if (isReset)
-            it->second.m_reset = false;
-        else
-            it->second.m_increment = false;
-
-    int length = list ? list->length() : 0;
-    for (int i = 0; i < length; ++i) {
-        CSSValue* currValue = list->itemWithoutBoundsCheck(i);
-        if (!currValue->isPrimitiveValue())
-            continue;
-
-        Pair* pair = static_cast<CSSPrimitiveValue*>(currValue)->getPairValue();
-        if (!pair || !pair->first() || !pair->second())
-            continue;
-
-        AtomicString identifier = static_cast<CSSPrimitiveValue*>(pair->first())->getStringValue();
-        // FIXME: What about overflow?
-        int value = static_cast<CSSPrimitiveValue*>(pair->second())->getIntValue();
-        CounterDirectives& directives = map.add(identifier.impl(), CounterDirectives()).first->second;
-        if (isReset) {
-            directives.m_reset = true;
-            directives.m_resetValue = value;
-        } else {
-            if (directives.m_increment)
-                directives.m_incrementValue += value;
-            else {
-                directives.m_increment = true;
-                directives.m_incrementValue = value;
-            }
-        }
-    }
-}
-
 void CSSStyleSelector::applyPropertyToStyle(int id, CSSValue *value, RenderStyle* style)
 {
     initElement(0);
@@ -4187,14 +4147,6 @@
                 m_style->setQuotes(adoptRef(QuotesData::create(0)));
         }
         return;
-
-    case CSSPropertyCounterIncrement:
-        applyCounterList(style(), value->isValueList() ? static_cast<CSSValueList*>(value) : 0, false);
-        return;
-    case CSSPropertyCounterReset:
-        applyCounterList(style(), value->isValueList() ? static_cast<CSSValueList*>(value) : 0, true);
-        return;
-
     case CSSPropertyFontFamily: {
         // list of strings and ids
         if (isInherit) {
@@ -5333,6 +5285,8 @@
     case CSSPropertyBorderSpacing:
     case CSSPropertyWebkitBorderHorizontalSpacing:
     case CSSPropertyWebkitBorderVerticalSpacing:
+    case CSSPropertyCounterIncrement:
+    case CSSPropertyCounterReset:
     case CSSPropertyLetterSpacing:
     case CSSPropertyWordSpacing:
     case CSSPropertyFontStyle:
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to