Title: [177289] trunk/Source/WebCore
Revision
177289
Author
[email protected]
Date
2014-12-15 10:57:58 -0800 (Mon, 15 Dec 2014)

Log Message

[CSS Shapes] Fix StyleBuilder code to use CSSValueNone to match spec and other code
https://bugs.webkit.org/show_bug.cgi?id=139601

Reviewed by Chris Dumez.

Change the code to properly use CSSValueNone instead of CSSValueAuto.
Asserts have been added to catch similar errors in the future.
In doing this change, it became apparent that there is nothing
special about the shape-outside property that requires custom code, so
it was changed to use a standard converter function.

No change observable via LayoutTests.

* css/CSSPropertyNames.in: Use a converter instead of custom code.
* css/StyleBuilderConverter.h:
(WebCore::isImageShape): Helper function so that isImageSetValue can
    be properly guarded.
(WebCore::StyleBuilderConverter::convertShapeValue): Format as a
    converter instead of custom code.
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyValueWebkitShapeOutside): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (177288 => 177289)


--- trunk/Source/WebCore/ChangeLog	2014-12-15 18:57:07 UTC (rev 177288)
+++ trunk/Source/WebCore/ChangeLog	2014-12-15 18:57:58 UTC (rev 177289)
@@ -1,3 +1,27 @@
+2014-12-15  Bem Jones-Bey  <[email protected]>
+
+        [CSS Shapes] Fix StyleBuilder code to use CSSValueNone to match spec and other code
+        https://bugs.webkit.org/show_bug.cgi?id=139601
+
+        Reviewed by Chris Dumez.
+
+        Change the code to properly use CSSValueNone instead of CSSValueAuto.
+        Asserts have been added to catch similar errors in the future.
+        In doing this change, it became apparent that there is nothing
+        special about the shape-outside property that requires custom code, so
+        it was changed to use a standard converter function. 
+
+        No change observable via LayoutTests.
+
+        * css/CSSPropertyNames.in: Use a converter instead of custom code.
+        * css/StyleBuilderConverter.h:
+        (WebCore::isImageShape): Helper function so that isImageSetValue can
+            be properly guarded.
+        (WebCore::StyleBuilderConverter::convertShapeValue): Format as a
+            converter instead of custom code.
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderCustom::applyValueWebkitShapeOutside): Deleted.
+
 2014-12-15  Oliver Hunt  <[email protected]>
 
         Make sure range based iteration of Vector<> still receives bounds checking

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (177288 => 177289)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2014-12-15 18:57:07 UTC (rev 177288)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2014-12-15 18:57:58 UTC (rev 177289)
@@ -536,7 +536,7 @@
 -webkit-region-break-inside [TypeName=EPageBreak, Initial=initialPageBreak]
 #endif
 #if defined(ENABLE_CSS_SHAPES) && ENABLE_CSS_SHAPES
--webkit-shape-outside [Custom=Value]
+-webkit-shape-outside [Converter=ShapeValue]
 -webkit-shape-margin [Converter=Length]
 -webkit-shape-image-threshold [Converter=Number<float>]
 #endif

Modified: trunk/Source/WebCore/css/StyleBuilderConverter.h (177288 => 177289)


--- trunk/Source/WebCore/css/StyleBuilderConverter.h	2014-12-15 18:57:07 UTC (rev 177288)
+++ trunk/Source/WebCore/css/StyleBuilderConverter.h	2014-12-15 18:57:58 UTC (rev 177289)
@@ -29,6 +29,9 @@
 
 #include "BasicShapeFunctions.h"
 #include "CSSCalculationValue.h"
+#include "CSSImageGeneratorValue.h"
+#include "CSSImageSetValue.h"
+#include "CSSImageValue.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSReflectValue.h"
 #include "Length.h"
@@ -74,6 +77,7 @@
     static float convertTextStrokeWidth(StyleResolver&, CSSValue&);
     static LineBoxContain convertLineBoxContain(StyleResolver&, CSSValue&);
     static TextDecorationSkip convertTextDecorationSkip(StyleResolver&, CSSValue&);
+    static PassRefPtr<ShapeValue> convertShapeValue(StyleResolver&, CSSValue&);
 
 private:
     static Length convertToRadiusLength(CSSToLengthConversionData&, CSSPrimitiveValue&);
@@ -586,7 +590,54 @@
     return skip;
 }
 
+#if ENABLE(CSS_SHAPES)
+static inline bool isImageShape(const CSSValue& value)
+{
+    return is<CSSImageValue>(value)
+#if ENABLE(CSS_IMAGE_SET)
+        || is<CSSImageSetValue>(value)
+#endif 
+        || is<CSSImageGeneratorValue>(value);
+}
 
+inline PassRefPtr<ShapeValue> StyleBuilderConverter::convertShapeValue(StyleResolver& styleResolver, CSSValue& value)
+{
+    if (is<CSSPrimitiveValue>(value)) {
+        ASSERT(downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueNone);
+        return nullptr;
+    }
+
+    if (isImageShape(value))
+        return ShapeValue::createImageValue(styleResolver.styleImage(CSSPropertyWebkitShapeOutside, value));
+
+    RefPtr<BasicShape> shape;
+    CSSBoxType referenceBox = BoxMissing;
+    for (auto& currentValue : downcast<CSSValueList>(value)) {
+        CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(currentValue.get());
+        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 = primitiveValue;
+        else {
+            ASSERT_NOT_REACHED();
+            return nullptr;
+        }
+    }
+
+    if (shape)
+        return ShapeValue::createShapeValue(shape.release(), referenceBox);
+
+    if (referenceBox != BoxMissing)
+        return ShapeValue::createBoxShapeValue(referenceBox);
+
+    ASSERT_NOT_REACHED();
+    return nullptr;
+}
+#endif // ENABLE(CSS_SHAPES)
+
 } // namespace WebCore
 
 #endif // StyleBuilderConverter_h

Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (177288 => 177289)


--- trunk/Source/WebCore/css/StyleBuilderCustom.h	2014-12-15 18:57:07 UTC (rev 177288)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h	2014-12-15 18:57:58 UTC (rev 177289)
@@ -27,11 +27,7 @@
 #ifndef StyleBuilderCustom_h
 #define StyleBuilderCustom_h
 
-#include "BasicShapeFunctions.h"
 #include "CSSAspectRatioValue.h"
-#include "CSSImageGeneratorValue.h"
-#include "CSSImageSetValue.h"
-#include "CSSImageValue.h"
 #include "CSSShadowValue.h"
 #include "Frame.h"
 #include "LocaleToScriptMapping.h"
@@ -53,10 +49,6 @@
     static void applyInheritZoom(StyleResolver&);
     static void applyValueZoom(StyleResolver&, CSSValue&);
 
-#if ENABLE(CSS_SHAPES)
-    static void applyValueWebkitShapeOutside(StyleResolver&, CSSValue&);
-#endif // ENABLE(CSS_SHAPES)
-
     static void applyValueVerticalAlign(StyleResolver&, CSSValue&);
 
 #if ENABLE(CSS_IMAGE_RESOLUTION)
@@ -236,42 +228,6 @@
             styleResolver.setZoom(number);
     }
 }
-
-#if ENABLE(CSS_SHAPES)
-inline void StyleBuilderCustom::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;
-        for (auto& currentValue : downcast<CSSValueList>(value)) {
-            CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(currentValue.get());
-            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)
-
 inline Length StyleBuilderCustom::mmLength(double mm)
 {
     Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(mm, CSSPrimitiveValue::CSS_MM));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to