Title: [175481] trunk/Source/WebCore
Revision
175481
Author
cdu...@apple.com
Date
2014-11-03 11:40:23 -0800 (Mon, 03 Nov 2014)

Log Message

Move -webkit-shape-outside to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=138296

Reviewed by Zoltan Horvath.

Move -webkit-shape-outside to the new StyleBuilder, using custom
code as it does not always call setShapeOutside().

No new tests, no behavior change.

* css/CSSPropertyNames.in:
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::ApplyPropertyShape::setValue): Deleted.
(WebCore::ApplyPropertyShape::applyValue): Deleted.
(WebCore::ApplyPropertyShape::createHandler): Deleted.
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderFunctions::applyValueWebkitShapeOutside):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (175480 => 175481)


--- trunk/Source/WebCore/ChangeLog	2014-11-03 19:38:57 UTC (rev 175480)
+++ trunk/Source/WebCore/ChangeLog	2014-11-03 19:40:23 UTC (rev 175481)
@@ -1,3 +1,24 @@
+2014-11-03  Chris Dumez  <cdu...@apple.com>
+
+        Move -webkit-shape-outside to the new StyleBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=138296
+
+        Reviewed by Zoltan Horvath.
+
+        Move -webkit-shape-outside to the new StyleBuilder, using custom
+        code as it does not always call setShapeOutside().
+
+        No new tests, no behavior change.
+
+        * css/CSSPropertyNames.in:
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
+        (WebCore::ApplyPropertyShape::setValue): Deleted.
+        (WebCore::ApplyPropertyShape::applyValue): Deleted.
+        (WebCore::ApplyPropertyShape::createHandler): Deleted.
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderFunctions::applyValueWebkitShapeOutside):
+
 2014-11-03  Alexey Proskuryakov  <a...@apple.com>
 
         REGRESSION: Using a media element changes window.name

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (175480 => 175481)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2014-11-03 19:38:57 UTC (rev 175480)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2014-11-03 19:40:23 UTC (rev 175481)
@@ -514,7 +514,7 @@
 -webkit-region-break-inside [NewStyleBuilder, TypeName=EPageBreak, Initial=initialPageBreak]
 #endif
 #if defined(ENABLE_CSS_SHAPES) && ENABLE_CSS_SHAPES
--webkit-shape-outside
+-webkit-shape-outside [NewStyleBuilder, Custom=Value]
 -webkit-shape-margin [NewStyleBuilder, Converter=Length]
 -webkit-shape-image-threshold [NewStyleBuilder, Converter=Number<float>]
 #endif

Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (175480 => 175481)


--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-11-03 19:38:57 UTC (rev 175480)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-11-03 19:40:23 UTC (rev 175481)
@@ -1803,53 +1803,6 @@
     }
 };
 
-#if ENABLE(CSS_SHAPES)
-template <ShapeValue* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<ShapeValue>), ShapeValue* (*initialFunction)()>
-class ApplyPropertyShape {
-public:
-    static void setValue(RenderStyle* style, PassRefPtr<ShapeValue> value) { (style->*setterFunction)(value); }
-    static void applyValue(CSSPropertyID property, StyleResolver* styleResolver, CSSValue* value)
-    {
-        if (is<CSSPrimitiveValue>(*value)) {
-            CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
-            if (primitiveValue.getValueID() == CSSValueAuto)
-                setValue(styleResolver->style(), 0);
-        } else if (value->isImageValue() || value->isImageGeneratorValue() || value->isImageSetValue()) {
-            RefPtr<ShapeValue> shape = ShapeValue::createImageValue(styleResolver->styleImage(property, value));
-            setValue(styleResolver->style(), shape.release());
-        } else if (is<CSSValueList>(*value)) {
-            RefPtr<BasicShape> shape;
-            CSSBoxType referenceBox = BoxMissing;
-            CSSValueList& valueList = downcast<CSSValueList>(*value);
-            for (unsigned i = 0; i < valueList.length(); ++i) {
-                CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*valueList.itemWithoutBoundsCheck(i));
-                if (primitiveValue.isShape())
-                    shape = basicShapeForValue(styleResolver->state().cssToLengthConversionData(), primitiveValue.getShapeValue());
-                else if (primitiveValue.getValueID() == CSSValueContentBox
-                    || primitiveValue.getValueID() == CSSValueBorderBox
-                    || primitiveValue.getValueID() == CSSValuePaddingBox
-                    || primitiveValue.getValueID() == CSSValueMarginBox)
-                    referenceBox = CSSBoxType(primitiveValue);
-                else
-                    return;
-            }
-
-            if (shape)
-                setValue(styleResolver->style(), ShapeValue::createShapeValue(shape.release(), referenceBox));
-            else if (referenceBox != BoxMissing)
-                setValue(styleResolver->style(), ShapeValue::createBoxShapeValue(referenceBox));
-
-        }
-    }
-
-    static PropertyHandler createHandler()
-    {
-        PropertyHandler handler = ApplyPropertyDefaultBase<ShapeValue*, getterFunction, PassRefPtr<ShapeValue>, setterFunction, ShapeValue*, initialFunction>::createHandler();
-        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
-    }
-};
-#endif
-
 #if ENABLE(CSS_IMAGE_RESOLUTION)
 class ApplyPropertyImageResolution {
 public:
@@ -2070,9 +2023,6 @@
     setPropertyHandler(CSSPropertyWebkitTransitionProperty, ApplyPropertyAnimation<CSSPropertyID, &Animation::property, &Animation::setProperty, &Animation::isPropertySet, &Animation::clearProperty, &Animation::initialAnimationProperty, &CSSToStyleMap::mapAnimationProperty, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
     setPropertyHandler(CSSPropertyWebkitTransitionTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSToStyleMap::mapAnimationTimingFunction, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
     setPropertyHandler(CSSPropertyWebkitClipPath, ApplyPropertyClipPath<&RenderStyle::clipPath, &RenderStyle::setClipPath, &RenderStyle::initialClipPath>::createHandler());
-#if ENABLE(CSS_SHAPES)
-    setPropertyHandler(CSSPropertyWebkitShapeOutside, ApplyPropertyShape<&RenderStyle::shapeOutside, &RenderStyle::setShapeOutside, &RenderStyle::initialShapeOutside>::createHandler());
-#endif
     setPropertyHandler(CSSPropertyWidows, ApplyPropertyAuto<short, &RenderStyle::widows, &RenderStyle::setWidows, &RenderStyle::hasAutoWidows, &RenderStyle::setHasAutoWidows>::createHandler());
     setPropertyHandler(CSSPropertyWordSpacing, ApplyPropertyWordSpacing::createHandler());
 

Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (175480 => 175481)


--- trunk/Source/WebCore/css/StyleBuilderCustom.h	2014-11-03 19:38:57 UTC (rev 175480)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h	2014-11-03 19:40:23 UTC (rev 175481)
@@ -27,6 +27,10 @@
 #ifndef StyleBuilderCustom_h
 #define StyleBuilderCustom_h
 
+#include "BasicShapeFunctions.h"
+#include "CSSImageGeneratorValue.h"
+#include "CSSImageSetValue.h"
+#include "CSSImageValue.h"
 #include "StyleResolver.h"
 
 namespace WebCore {
@@ -109,6 +113,42 @@
     }
 }
 
+#if ENABLE(CSS_SHAPES)
+inline void applyValueWebkitShapeOutside(StyleResolver& styleResolver, CSSValue& value)
+{
+    if (is<CSSPrimitiveValue>(value)) {
+        // FIXME: Shouldn't this be CSSValueNone?
+        // http://www.w3.org/TR/css-shapes/#shape-outside-property
+        if (downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueAuto)
+            styleResolver.style()->setShapeOutside(nullptr);
+    } if (is<CSSImageValue>(value) || is<CSSImageGeneratorValue>(value) || is<CSSImageSetValue>(value)) {
+        RefPtr<ShapeValue> shape = ShapeValue::createImageValue(styleResolver.styleImage(CSSPropertyWebkitShapeOutside, &value));
+        styleResolver.style()->setShapeOutside(shape.release());
+    } else if (is<CSSValueList>(value)) {
+        RefPtr<BasicShape> shape;
+        CSSBoxType referenceBox = BoxMissing;
+        auto& valueList = downcast<CSSValueList>(value);
+        for (unsigned i = 0; i < valueList.length(); ++i) {
+            CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*valueList.itemWithoutBoundsCheck(i));
+            if (primitiveValue.isShape())
+                shape = basicShapeForValue(styleResolver.state().cssToLengthConversionData(), primitiveValue.getShapeValue());
+            else if (primitiveValue.getValueID() == CSSValueContentBox
+                || primitiveValue.getValueID() == CSSValueBorderBox
+                || primitiveValue.getValueID() == CSSValuePaddingBox
+                || primitiveValue.getValueID() == CSSValueMarginBox)
+                referenceBox = CSSBoxType(primitiveValue);
+            else
+                return;
+        }
+
+        if (shape)
+            styleResolver.style()->setShapeOutside(ShapeValue::createShapeValue(shape.release(), referenceBox));
+        else if (referenceBox != BoxMissing)
+            styleResolver.style()->setShapeOutside(ShapeValue::createBoxShapeValue(referenceBox));
+    }
+}
+#endif // ENABLE(CSS_SHAPES)
+
 } // namespace StyleBuilderFunctions
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to