Title: [91170] trunk/Source/WebCore
Revision
91170
Author
[email protected]
Date
2011-07-17 18:59:55 -0700 (Sun, 17 Jul 2011)

Log Message

Implement CSSPropertyCursor in CSSStyleApplyProperty
https://bugs.webkit.org/show_bug.cgi?id=64432

Reviewed by Dimitri Glazkov.

No new tests / refectoring only.

* css/CSSStyleApplyProperty.cpp:
Add handler for CSSPropertyCursor.
* css/CSSStyleSelector.cpp:
Remove current handler of CSSPropertyCursor.
* css/CSSStyleSelector.h:
Make styleImage and cachedOrPendingFromValue public.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (91169 => 91170)


--- trunk/Source/WebCore/ChangeLog	2011-07-18 01:47:28 UTC (rev 91169)
+++ trunk/Source/WebCore/ChangeLog	2011-07-18 01:59:55 UTC (rev 91170)
@@ -1,3 +1,19 @@
+2011-07-17  Luke Macpherson   <[email protected]>
+
+        Implement CSSPropertyCursor in CSSStyleApplyProperty
+        https://bugs.webkit.org/show_bug.cgi?id=64432
+
+        Reviewed by Dimitri Glazkov.
+
+        No new tests / refectoring only.
+
+        * css/CSSStyleApplyProperty.cpp:
+        Add handler for CSSPropertyCursor.
+        * css/CSSStyleSelector.cpp:
+        Remove current handler of CSSPropertyCursor.
+        * css/CSSStyleSelector.h:
+        Make styleImage and cachedOrPendingFromValue public.
+
 2011-07-16  Simon Fraser  <[email protected]>
 
         Add code to attempt to align compositing layers to pixel boundaries when page scale changes

Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (91169 => 91170)


--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp	2011-07-18 01:47:28 UTC (rev 91169)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp	2011-07-18 01:59:55 UTC (rev 91170)
@@ -25,9 +25,11 @@
 #include "config.h"
 #include "CSSStyleApplyProperty.h"
 
+#include "CSSCursorImageValue.h"
 #include "CSSPrimitiveValueMappings.h"
 #include "CSSStyleSelector.h"
 #include "CSSValueList.h"
+#include "CursorList.h"
 #include "Document.h"
 #include "Element.h"
 #include "Pair.h"
@@ -504,6 +506,52 @@
     }
 };
 
+class ApplyPropertyCursor : public ApplyPropertyBase {
+private:
+    virtual void applyInheritValue(CSSStyleSelector* selector) const
+    {
+        selector->style()->setCursor(selector->parentStyle()->cursor());
+        selector->style()->setCursorList(selector->parentStyle()->cursors());
+    }
+
+    virtual void applyInitialValue(CSSStyleSelector* selector) const
+    {
+        selector->style()->clearCursorList();
+        selector->style()->setCursor(RenderStyle::initialCursor());
+    }
+
+    virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const
+    {
+        selector->style()->clearCursorList();
+        if (value->isValueList()) {
+            CSSValueList* list = static_cast<CSSValueList*>(value);
+            int len = list->length();
+            selector->style()->setCursor(CURSOR_AUTO);
+            for (int i = 0; i < len; i++) {
+                CSSValue* item = list->itemWithoutBoundsCheck(i);
+                if (!item->isPrimitiveValue())
+                    continue;
+                CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(item);
+                int type = primitiveValue->primitiveType();
+                if (type == CSSPrimitiveValue::CSS_URI) {
+                    if (primitiveValue->isCursorImageValue()) {
+                        CSSCursorImageValue* image = static_cast<CSSCursorImageValue*>(primitiveValue);
+                        if (image->updateIfSVGCursorIsUsed(selector->element())) // Elements with SVG cursors are not allowed to share style.
+                            selector->style()->setUnique();
+                        selector->style()->addCursor(selector->cachedOrPendingFromValue(CSSPropertyCursor, image), image->hotSpot());
+                    }
+                } else if (type == CSSPrimitiveValue::CSS_IDENT)
+                    selector->style()->setCursor(*primitiveValue);
+            }
+        } else if (value->isPrimitiveValue()) {
+            CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+            int type = primitiveValue->primitiveType();
+            if (type == CSSPrimitiveValue::CSS_IDENT && selector->style()->cursor() != ECursor(*primitiveValue))
+                selector->style()->setCursor(*primitiveValue);
+        }
+    }
+};
+
 const CSSStyleApplyProperty& CSSStyleApplyProperty::sharedCSSStyleApplyProperty()
 {
     DEFINE_STATIC_LOCAL(CSSStyleApplyProperty, cssStyleApplyPropertyInstance, ());
@@ -618,6 +666,8 @@
     setPropertyHandler(CSSPropertyLetterSpacing, new ApplyPropertyComputeLength<int, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>(&RenderStyle::letterSpacing, &RenderStyle::setLetterSpacing, &RenderStyle::initialLetterWordSpacing));
     setPropertyHandler(CSSPropertyWordSpacing, new ApplyPropertyComputeLength<int, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>(&RenderStyle::wordSpacing, &RenderStyle::setWordSpacing, &RenderStyle::initialLetterWordSpacing));
 
+    setPropertyHandler(CSSPropertyCursor, new ApplyPropertyCursor());
+
     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 (91169 => 91170)


--- trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-07-18 01:47:28 UTC (rev 91169)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-07-18 01:59:55 UTC (rev 91170)
@@ -3813,44 +3813,6 @@
     case CSSPropertyWhiteSpace:
         HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(whiteSpace, WhiteSpace)
         return;
-    case CSSPropertyCursor:
-        if (isInherit) {
-            m_style->setCursor(m_parentStyle->cursor());
-            m_style->setCursorList(m_parentStyle->cursors());
-            return;
-        }
-        m_style->clearCursorList();
-        if (isInitial) {
-            m_style->setCursor(RenderStyle::initialCursor());
-            return;
-        }
-        if (value->isValueList()) {
-            CSSValueList* list = static_cast<CSSValueList*>(value);
-            int len = list->length();
-            m_style->setCursor(CURSOR_AUTO);
-            for (int i = 0; i < len; i++) {
-                CSSValue* item = list->itemWithoutBoundsCheck(i);
-                if (!item->isPrimitiveValue())
-                    continue;
-                primitiveValue = static_cast<CSSPrimitiveValue*>(item);
-                int type = primitiveValue->primitiveType();
-                if (type == CSSPrimitiveValue::CSS_URI) {
-                    if (primitiveValue->isCursorImageValue()) {
-                        CSSCursorImageValue* image = static_cast<CSSCursorImageValue*>(primitiveValue);
-                        if (image->updateIfSVGCursorIsUsed(m_element)) // Elements with SVG cursors are not allowed to share style.
-                            m_style->setUnique();
-                        m_style->addCursor(cachedOrPendingFromValue(CSSPropertyCursor, image), image->hotSpot());
-                    }
-                } else if (type == CSSPrimitiveValue::CSS_IDENT)
-                    m_style->setCursor(*primitiveValue);
-            }
-        } else if (primitiveValue) {
-            int type = primitiveValue->primitiveType();
-            if (type == CSSPrimitiveValue::CSS_IDENT && m_style->cursor() != ECursor(*primitiveValue))
-                m_style->setCursor(*primitiveValue);
-        }
-        return;
-    
 // uri || inherit
     case CSSPropertyListStyleImage:
     {
@@ -5428,6 +5390,7 @@
     case CSSPropertyWebkitTransformOriginY:
     case CSSPropertyWebkitPerspectiveOriginX:
     case CSSPropertyWebkitPerspectiveOriginY:
+    case CSSPropertyCursor:
         ASSERT_NOT_REACHED();
         return;
 #if ENABLE(SVG)

Modified: trunk/Source/WebCore/css/CSSStyleSelector.h (91169 => 91170)


--- trunk/Source/WebCore/css/CSSStyleSelector.h	2011-07-18 01:47:28 UTC (rev 91169)
+++ trunk/Source/WebCore/css/CSSStyleSelector.h	2011-07-18 01:59:55 UTC (rev 91170)
@@ -304,6 +304,9 @@
             mutable HashSet<LinkHash, LinkHashHash> m_linksCheckedForVisitedState;
         };
 
+        StyleImage* styleImage(CSSPropertyID, CSSValue*);
+        StyleImage* cachedOrPendingFromValue(CSSPropertyID, CSSImageValue*);
+
     private:
         static RenderStyle* s_styleNotYetAvailable;
 
@@ -346,9 +349,6 @@
 #endif
 
         void loadPendingImages();
-        
-        StyleImage* styleImage(CSSPropertyID, CSSValue* value);
-        StyleImage* cachedOrPendingFromValue(CSSPropertyID property, CSSImageValue* value);
 
         // We collect the set of decls that match in |m_matchedDecls|.  We then walk the
         // set of matched decls four times, once for those properties that others depend on (like font-size),
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to