2011-04-05 Luke Macpherson <macpherson@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Apr 2011 15:36:16 +0000 (15:36 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Apr 2011 15:36:16 +0000 (15:36 +0000)
        Reviewed by Dimitri Glazkov.

        Implement CSSPropertyDirection in CSSStyleApplyProperty
        https://bugs.webkit.org/show_bug.cgi?id=57608

        No new tests required as no new functionality introduced.

        * css/CSSStyleApplyProperty.cpp:
        Add implementation class for CSSPropertyDirection
        * css/CSSStyleSelector.cpp:
        Remove existing implementation for CSSPropertyDirection
        * css/CSSStyleSelector.h:
        Add getter for element

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@82942 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/CSSStyleApplyProperty.cpp
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/css/CSSStyleSelector.h

index bcbc9c5..ffdce43 100644 (file)
@@ -1,3 +1,19 @@
+2011-04-05  Luke Macpherson   <macpherson@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        Implement CSSPropertyDirection in CSSStyleApplyProperty
+        https://bugs.webkit.org/show_bug.cgi?id=57608
+
+        No new tests required as no new functionality introduced.
+
+        * css/CSSStyleApplyProperty.cpp:
+        Add implementation class for CSSPropertyDirection
+        * css/CSSStyleSelector.cpp:
+        Remove existing implementation for CSSPropertyDirection
+        * css/CSSStyleSelector.h:
+        Add getter for element
+
 2011-04-05  Leandro Gracia Gil  <leandrogracia@chromium.org>
 
         Reviewed by Steve Block.
index e075615..aea5a4d 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "CSSPrimitiveValueMappings.h"
 #include "CSSStyleSelector.h"
+#include "Document.h"
+#include "Element.h"
 #include "RenderStyle.h"
 #include <wtf/StdLibExtras.h>
 #include <wtf/UnusedParam.h>
@@ -134,6 +136,23 @@ protected:
     Color (*m_initialValue)();
 };
 
+// CSSPropertyDirection
+class ApplyPropertyDirection : public ApplyPropertyDefault<TextDirection> {
+public:
+    ApplyPropertyDirection(TextDirection (RenderStyle::*getter)() const, void (RenderStyle::*setter)(TextDirection), TextDirection (*initial)())
+        : ApplyPropertyDefault<TextDirection>(getter, setter, initial)
+    {
+    }
+
+    virtual void value(CSSStyleSelector* selector, CSSValue* value) const
+    {
+        ApplyPropertyDefault<TextDirection>::value(selector, value);
+        Element* element = selector->element();
+        if (element && selector->element() == element->document()->documentElement())
+            element->document()->setDirectionSetOnDocumentElement(true);
+    }
+};
+
 const CSSStyleApplyProperty& CSSStyleApplyProperty::sharedCSSStyleApplyProperty()
 {
     DEFINE_STATIC_LOCAL(CSSStyleApplyProperty, cssStyleApplyPropertyInstance, ());
@@ -147,6 +166,7 @@ CSSStyleApplyProperty::CSSStyleApplyProperty()
        m_propertyMap[i] = 0;
 
     setPropertyValue(CSSPropertyColor, new ApplyPropertyColor(&RenderStyle::color, &RenderStyle::setColor, RenderStyle::initialColor));
+    setPropertyValue(CSSPropertyDirection, new ApplyPropertyDirection(&RenderStyle::direction, &RenderStyle::setDirection, RenderStyle::initialDirection));
     setPropertyValue(CSSPropertyBackgroundColor, new ApplyPropertyColorBase(&RenderStyle::backgroundColor, 0, &RenderStyle::setBackgroundColor));
     setPropertyValue(CSSPropertyBorderBottomColor, new ApplyPropertyColorBase(&RenderStyle::borderBottomColor, &RenderStyle::color, &RenderStyle::setBorderBottomColor));
     setPropertyValue(CSSPropertyBorderLeftColor, new ApplyPropertyColorBase(&RenderStyle::borderLeftColor, &RenderStyle::color, &RenderStyle::setBorderLeftColor));
index 2af0335..1d4b232 100644 (file)
@@ -3722,11 +3722,6 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     case CSSPropertyClear:
         HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(clear, Clear)
         return;
-    case CSSPropertyDirection:
-        HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(direction, Direction)
-        if (!isInherit && !isInitial && m_element && m_element == m_element->document()->documentElement())
-            m_element->document()->setDirectionSetOnDocumentElement(true);
-        return;
     case CSSPropertyDisplay:
         HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(display, Display)
 #if ENABLE(WCSS)
@@ -6197,6 +6192,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
 
     // These properties are implemented in the CSSStyleApplyProperty lookup table.
     case CSSPropertyColor:
+    case CSSPropertyDirection:
     case CSSPropertyBackgroundColor:
     case CSSPropertyBorderBottomColor:
     case CSSPropertyBorderLeftColor:
index 756c5bf..69f9903 100644 (file)
@@ -115,6 +115,7 @@ public:
 
         RenderStyle* style() const { return m_style.get(); }
         RenderStyle* parentStyle() const { return m_parentStyle; }
+        Element* element() const { return m_element; }
 
     private:
         void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO);