Title: [177414] trunk/Source/WebCore
Revision
177414
Author
cdu...@apple.com
Date
2014-12-16 17:18:36 -0800 (Tue, 16 Dec 2014)

Log Message

Move 'cursor' CSS property to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=139660

Reviewed by Benjamin Poulain.

Move 'cursor' CSS property to the new StyleBuilder by using
custom code.

No new tests, no behavior change.

* css/CSSPropertyNames.in:
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::ApplyPropertyCursor::applyInheritValue): Deleted.
(WebCore::ApplyPropertyCursor::applyInitialValue): Deleted.
(WebCore::ApplyPropertyCursor::applyValue): Deleted.
(WebCore::ApplyPropertyCursor::createHandler): Deleted.
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyInitialCursor):
(WebCore::StyleBuilderCustom::applyInheritCursor):
(WebCore::StyleBuilderCustom::applyValueCursor):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (177413 => 177414)


--- trunk/Source/WebCore/ChangeLog	2014-12-17 00:54:42 UTC (rev 177413)
+++ trunk/Source/WebCore/ChangeLog	2014-12-17 01:18:36 UTC (rev 177414)
@@ -1,3 +1,27 @@
+2014-12-16  Chris Dumez  <cdu...@apple.com>
+
+        Move 'cursor' CSS property to the new StyleBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=139660
+
+        Reviewed by Benjamin Poulain.
+
+        Move 'cursor' CSS property to the new StyleBuilder by using
+        custom code.
+
+        No new tests, no behavior change.
+
+        * css/CSSPropertyNames.in:
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
+        (WebCore::ApplyPropertyCursor::applyInheritValue): Deleted.
+        (WebCore::ApplyPropertyCursor::applyInitialValue): Deleted.
+        (WebCore::ApplyPropertyCursor::applyValue): Deleted.
+        (WebCore::ApplyPropertyCursor::createHandler): Deleted.
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderCustom::applyInitialCursor):
+        (WebCore::StyleBuilderCustom::applyInheritCursor):
+        (WebCore::StyleBuilderCustom::applyValueCursor):
+
 2014-12-16  Zalan Bujtas  <za...@apple.com>
 
         Subpixel rendering: Animating HTML elements leaves trails when embedded to a subpxiel positioned iframe.

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (177413 => 177414)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2014-12-17 00:54:42 UTC (rev 177413)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2014-12-17 01:18:36 UTC (rev 177414)
@@ -168,7 +168,7 @@
 content [LegacyStyleBuilder]
 counter-increment [Custom=All]
 counter-reset [Custom=All]
-cursor [Inherited, LegacyStyleBuilder]
+cursor [Inherited, Custom=All]
 #if defined(ENABLE_CURSOR_VISIBILITY) && ENABLE_CURSOR_VISIBILITY
 -webkit-cursor-visibility [Inherited, TypeName=CursorVisibility]
 #endif

Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (177413 => 177414)


--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-12-17 00:54:42 UTC (rev 177413)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-12-17 01:18:36 UTC (rev 177414)
@@ -626,50 +626,6 @@
     }
 };
 
-class ApplyPropertyCursor {
-public:
-    static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
-    {
-        styleResolver->style()->setCursor(styleResolver->parentStyle()->cursor());
-        styleResolver->style()->setCursorList(styleResolver->parentStyle()->cursors());
-    }
-
-    static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
-    {
-        styleResolver->style()->clearCursorList();
-        styleResolver->style()->setCursor(RenderStyle::initialCursor());
-    }
-
-    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
-    {
-        styleResolver->style()->clearCursorList();
-        if (is<CSSValueList>(*value)) {
-            CSSValueList& list = downcast<CSSValueList>(*value);
-            int length = list.length();
-            styleResolver->style()->setCursor(CursorAuto);
-            for (int i = 0; i < length; i++) {
-                CSSValue* item = list.itemWithoutBoundsCheck(i);
-                if (is<CSSCursorImageValue>(*item)) {
-                    CSSCursorImageValue& image = downcast<CSSCursorImageValue>(*item);
-                    if (image.updateIfSVGCursorIsUsed(styleResolver->element())) // Elements with SVG cursors are not allowed to share style.
-                        styleResolver->style()->setUnique();
-                    styleResolver->style()->addCursor(styleResolver->styleImage(CSSPropertyCursor, image), image.hotSpot());
-                } else if (is<CSSPrimitiveValue>(*item)) {
-                    CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*item);
-                    if (primitiveValue.isValueID())
-                        styleResolver->style()->setCursor(primitiveValue);
-                }
-            }
-        } else if (is<CSSPrimitiveValue>(*value)) {
-            CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
-            if (primitiveValue.isValueID() && styleResolver->style()->cursor() != ECursor(primitiveValue))
-                styleResolver->style()->setCursor(primitiveValue);
-        }
-    }
-
-    static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
-};
-
 template <typename T,
           T (Animation::*getterFunction)() const,
           void (Animation::*setterFunction)(T),
@@ -774,7 +730,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(CSSPropertyCursor, ApplyPropertyCursor::createHandler());
     setPropertyHandler(CSSPropertyFontSize, ApplyPropertyFontSize::createHandler());
     setPropertyHandler(CSSPropertyFontStyle, ApplyPropertyFont<FontItalic, &FontDescription::italic, &FontDescription::setItalic, FontItalicOff>::createHandler());
     setPropertyHandler(CSSPropertyFontVariant, ApplyPropertyFont<FontSmallCaps, &FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff>::createHandler());

Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (177413 => 177414)


--- trunk/Source/WebCore/css/StyleBuilderCustom.h	2014-12-17 00:54:42 UTC (rev 177413)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h	2014-12-17 01:18:36 UTC (rev 177414)
@@ -28,7 +28,9 @@
 #define StyleBuilderCustom_h
 
 #include "CSSAspectRatioValue.h"
+#include "CSSCursorImageValue.h"
 #include "CSSShadowValue.h"
+#include "CursorList.h"
 #include "Frame.h"
 #include "LocaleToScriptMapping.h"
 #include "Rect.h"
@@ -133,6 +135,10 @@
     static void applyInheritCounterReset(StyleResolver&);
     static void applyValueCounterReset(StyleResolver&, CSSValue&);
 
+    static void applyInitialCursor(StyleResolver&);
+    static void applyInheritCursor(StyleResolver&);
+    static void applyValueCursor(StyleResolver&, CSSValue&);
+
 private:
     static void resetEffectiveZoom(StyleResolver&);
     static CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver&);
@@ -1136,6 +1142,45 @@
     applyValueCounter<Reset>(styleResolver, value);
 }
 
+inline void StyleBuilderCustom::applyInitialCursor(StyleResolver& styleResolver)
+{
+    styleResolver.style()->clearCursorList();
+    styleResolver.style()->setCursor(RenderStyle::initialCursor());
+}
+
+inline void StyleBuilderCustom::applyInheritCursor(StyleResolver& styleResolver)
+{
+    styleResolver.style()->setCursor(styleResolver.parentStyle()->cursor());
+    styleResolver.style()->setCursorList(styleResolver.parentStyle()->cursors());
+}
+
+inline void StyleBuilderCustom::applyValueCursor(StyleResolver& styleResolver, CSSValue& value)
+{
+    styleResolver.style()->clearCursorList();
+    if (is<CSSPrimitiveValue>(value)) {
+        ECursor cursor = downcast<CSSPrimitiveValue>(value);
+        if (styleResolver.style()->cursor() != cursor)
+            styleResolver.style()->setCursor(cursor);
+        return;
+    }
+
+    styleResolver.style()->setCursor(CursorAuto);
+    auto& list = downcast<CSSValueList>(value);
+    for (auto& item : list) {
+        if (is<CSSCursorImageValue>(item.get())) {
+            auto& image = downcast<CSSCursorImageValue>(item.get());
+            if (image.updateIfSVGCursorIsUsed(styleResolver.element())) // Elements with SVG cursors are not allowed to share style.
+                styleResolver.style()->setUnique();
+            styleResolver.style()->addCursor(styleResolver.styleImage(CSSPropertyCursor, image), image.hotSpot());
+            continue;
+        }
+
+        styleResolver.style()->setCursor(downcast<CSSPrimitiveValue>(item.get()));
+        ASSERT_WITH_MESSAGE(item.ptr() == list.item(list.length() - 1), "Cursor ID fallback should always be last in the list");
+        return;
+    }
+}
+
 } // namespace WebCore
 
 #endif // StyleBuilderCustom_h
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to