Title: [176383] trunk/Source/WebCore
Revision
176383
Author
[email protected]
Date
2014-11-19 23:42:19 -0800 (Wed, 19 Nov 2014)

Log Message

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

Reviewed by Andreas Kling.

Move 'clip' CSS property from DeprecatedStyleBuilder to the new
StyleBuilder by using custom code.

No new tests, no behavior change.

* css/CSSPropertyNames.in:
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::ApplyPropertyClip::convertToLength): Deleted.
(WebCore::ApplyPropertyClip::applyInheritValue): Deleted.
(WebCore::ApplyPropertyClip::applyInitialValue): Deleted.
(WebCore::ApplyPropertyClip::applyValue): Deleted.
(WebCore::ApplyPropertyClip::createHandler): Deleted.
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderFunctions::applyInitialClip):
(WebCore::StyleBuilderFunctions::applyInheritClip):
(WebCore::StyleBuilderFunctions::applyValueClip):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (176382 => 176383)


--- trunk/Source/WebCore/ChangeLog	2014-11-20 05:45:52 UTC (rev 176382)
+++ trunk/Source/WebCore/ChangeLog	2014-11-20 07:42:19 UTC (rev 176383)
@@ -1,3 +1,28 @@
+2014-11-19  Chris Dumez  <[email protected]>
+
+        Move 'clip' CSS property to the new StyleBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=138909
+
+        Reviewed by Andreas Kling.
+
+        Move 'clip' CSS property from DeprecatedStyleBuilder to the new
+        StyleBuilder by using custom code.
+
+        No new tests, no behavior change.
+
+        * css/CSSPropertyNames.in:
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
+        (WebCore::ApplyPropertyClip::convertToLength): Deleted.
+        (WebCore::ApplyPropertyClip::applyInheritValue): Deleted.
+        (WebCore::ApplyPropertyClip::applyInitialValue): Deleted.
+        (WebCore::ApplyPropertyClip::applyValue): Deleted.
+        (WebCore::ApplyPropertyClip::createHandler): Deleted.
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderFunctions::applyInitialClip):
+        (WebCore::StyleBuilderFunctions::applyInheritClip):
+        (WebCore::StyleBuilderFunctions::applyValueClip):
+
 2014-11-19  Ryuan Choi  <[email protected]>
 
         Remove dead code from TiledBackingStore

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (176382 => 176383)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2014-11-20 05:45:52 UTC (rev 176382)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2014-11-20 07:42:19 UTC (rev 176383)
@@ -158,7 +158,7 @@
 caption-side [Inherited, NewStyleBuilder]
 -epub-caption-side = caption-side
 clear [NewStyleBuilder]
-clip
+clip [NewStyleBuilder, Custom=All]
 -webkit-clip-path [NewStyleBuilder, Converter=ClipPath]
 content
 counter-increment

Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (176382 => 176383)


--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-11-20 05:45:52 UTC (rev 176382)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-11-20 07:42:19 UTC (rev 176383)
@@ -192,51 +192,6 @@
     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
 };
 
-class ApplyPropertyClip {
-private:
-    static Length convertToLength(StyleResolver* styleResolver, CSSPrimitiveValue* value)
-    {
-        return value->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(styleResolver->state().cssToLengthConversionData());
-    }
-public:
-    static void applyInheritValue(CSSPropertyID propertyID, StyleResolver* styleResolver)
-    {
-        RenderStyle* parentStyle = styleResolver->parentStyle();
-        if (!parentStyle->hasClip())
-            return applyInitialValue(propertyID, styleResolver);
-        styleResolver->style()->setClip(parentStyle->clipTop(), parentStyle->clipRight(), parentStyle->clipBottom(), parentStyle->clipLeft());
-        styleResolver->style()->setHasClip(true);
-    }
-
-    static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
-    {
-        styleResolver->style()->setClip(Length(), Length(), Length(), Length());
-        styleResolver->style()->setHasClip(false);
-    }
-
-    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
-    {
-        if (!is<CSSPrimitiveValue>(*value))
-            return;
-
-        CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
-
-        if (Rect* rect = primitiveValue.getRectValue()) {
-            Length top = convertToLength(styleResolver, rect->top());
-            Length right = convertToLength(styleResolver, rect->right());
-            Length bottom = convertToLength(styleResolver, rect->bottom());
-            Length left = convertToLength(styleResolver, rect->left());
-            styleResolver->style()->setClip(top, right, bottom, left);
-            styleResolver->style()->setHasClip(true);
-        } else if (primitiveValue.getValueID() == CSSValueAuto) {
-            styleResolver->style()->setClip(Length(), Length(), Length(), Length());
-            styleResolver->style()->setHasClip(false);
-        }
-    }
-
-    static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
-};
-
 enum ColorInherit {NoInheritFromParent = 0, InheritFromParent};
 Color defaultInitialColor();
 Color defaultInitialColor() { return Color(); }
@@ -1187,7 +1142,6 @@
     setPropertyHandler(CSSPropertyBorderLeftColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderLeftColor, &RenderStyle::setBorderLeftColor, &RenderStyle::setVisitedLinkBorderLeftColor, &RenderStyle::color>::createHandler());
     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(CSSPropertyClip, ApplyPropertyClip::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());

Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (176382 => 176383)


--- trunk/Source/WebCore/css/StyleBuilderCustom.h	2014-11-20 05:45:52 UTC (rev 176382)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h	2014-11-20 07:42:19 UTC (rev 176383)
@@ -32,6 +32,7 @@
 #include "CSSImageSetValue.h"
 #include "CSSImageValue.h"
 #include "Frame.h"
+#include "Rect.h"
 #include "StyleResolver.h"
 
 namespace WebCore {
@@ -610,6 +611,39 @@
     styleResolver.style()->setOutlineStyle(primitiveValue);
 }
 
+inline void applyInitialClip(StyleResolver& styleResolver)
+{
+    styleResolver.style()->setClip(Length(), Length(), Length(), Length());
+    styleResolver.style()->setHasClip(false);
+}
+
+inline void applyInheritClip(StyleResolver& styleResolver)
+{
+    RenderStyle* parentStyle = styleResolver.parentStyle();
+    if (!parentStyle->hasClip())
+        return applyInitialClip(styleResolver);
+    styleResolver.style()->setClip(parentStyle->clipTop(), parentStyle->clipRight(), parentStyle->clipBottom(), parentStyle->clipLeft());
+    styleResolver.style()->setHasClip(true);
+}
+
+inline void applyValueClip(StyleResolver& styleResolver, CSSValue& value)
+{
+    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+
+    if (Rect* rect = primitiveValue.getRectValue()) {
+        auto conversionData = styleResolver.state().cssToLengthConversionData();
+        Length top = rect->top()->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(conversionData);
+        Length right = rect->right()->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(conversionData);
+        Length bottom = rect->bottom()->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(conversionData);
+        Length left = rect->left()->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(conversionData);
+        styleResolver.style()->setClip(top, right, bottom, left);
+        styleResolver.style()->setHasClip(true);
+    } else {
+        ASSERT(primitiveValue.getValueID() == CSSValueAuto);
+        applyInitialClip(styleResolver);
+    }
+}
+
 } // namespace StyleBuilderFunctions
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to