Title: [162001] trunk/Source/WebCore
Revision
162001
Author
[email protected]
Date
2014-01-14 13:42:03 -0800 (Tue, 14 Jan 2014)

Log Message

[CSS Shapes] Move CSSPrimitiveValue <-> LayoutBox Conversion to CSSPrimitiveValueMappings
https://bugs.webkit.org/show_bug.cgi?id=126719

Reviewed by Dirk Schulze.

The standard location for conversions to/from CSSPrimitiveValues is CSSPrimitiveValueMappings.
This patch moves the conversion for LayoutBoxes from BasicShapeFunctions to
CSSPrimitiveValueMappings.h.

Refactoring, no new tests.

* css/BasicShapeFunctions.cpp:
(WebCore::valueForBasicShape):
(WebCore::basicShapeForValue):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::propertyValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator LayoutBox):
* css/DeprecatedStyleBuilder.cpp:
(WebCore::ApplyPropertyClipPath::applyValue):
(WebCore::ApplyPropertyShape::applyValue):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (162000 => 162001)


--- trunk/Source/WebCore/ChangeLog	2014-01-14 21:41:04 UTC (rev 162000)
+++ trunk/Source/WebCore/ChangeLog	2014-01-14 21:42:03 UTC (rev 162001)
@@ -1,3 +1,28 @@
+2014-01-14  Bear Travis  <[email protected]>
+
+        [CSS Shapes] Move CSSPrimitiveValue <-> LayoutBox Conversion to CSSPrimitiveValueMappings
+        https://bugs.webkit.org/show_bug.cgi?id=126719
+
+        Reviewed by Dirk Schulze.
+
+        The standard location for conversions to/from CSSPrimitiveValues is CSSPrimitiveValueMappings.
+        This patch moves the conversion for LayoutBoxes from BasicShapeFunctions to
+        CSSPrimitiveValueMappings.h.
+
+        Refactoring, no new tests.
+
+        * css/BasicShapeFunctions.cpp:
+        (WebCore::valueForBasicShape):
+        (WebCore::basicShapeForValue):
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::propertyValue):
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator LayoutBox):
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::ApplyPropertyClipPath::applyValue):
+        (WebCore::ApplyPropertyShape::applyValue):
+
 2014-01-09  Roger Fong  <[email protected]>
 
         Add support for handling WebGL load policies.

Modified: trunk/Source/WebCore/css/BasicShapeFunctions.cpp (162000 => 162001)


--- trunk/Source/WebCore/css/BasicShapeFunctions.cpp	2014-01-14 21:41:04 UTC (rev 162000)
+++ trunk/Source/WebCore/css/BasicShapeFunctions.cpp	2014-01-14 21:42:03 UTC (rev 162001)
@@ -39,48 +39,6 @@
 
 namespace WebCore {
 
-PassRefPtr<CSSPrimitiveValue> valueForBox(LayoutBox box)
-{
-    switch (box) {
-    case ContentBox:
-        return cssValuePool().createIdentifierValue(CSSValueContentBox);
-    case PaddingBox:
-        return cssValuePool().createIdentifierValue(CSSValuePaddingBox);
-    case BorderBox:
-        return cssValuePool().createIdentifierValue(CSSValueBorderBox);
-    case MarginBox:
-        return cssValuePool().createIdentifierValue(CSSValueMarginBox);
-    case BoundingBox:
-        return cssValuePool().createIdentifierValue(CSSValueBoundingBox);
-    case BoxMissing:
-        return nullptr;
-    }
-    ASSERT_NOT_REACHED();
-    return nullptr;
-}
-
-LayoutBox boxForValue(const CSSPrimitiveValue* value)
-{
-    if (!value)
-        return BoxMissing;
-
-    switch (value->getValueID()) {
-    case CSSValueContentBox:
-        return ContentBox;
-    case CSSValuePaddingBox:
-        return PaddingBox;
-    case CSSValueBorderBox:
-        return BorderBox;
-    case CSSValueMarginBox:
-        return MarginBox;
-    case CSSValueBoundingBox:
-        return BoundingBox;
-    default:
-        ASSERT_NOT_REACHED();
-        return BoxMissing;
-    }
-}
-
 static PassRefPtr<CSSPrimitiveValue> valueForCenterCoordinate(CSSValuePool& pool, const RenderStyle* style, const BasicShapeCenterCoordinate& center)
 {
     CSSValueID keyword = CSSValueInvalid;
@@ -230,7 +188,8 @@
         break;
     }
 
-    basicShapeValue->setLayoutBox(valueForBox(basicShape->layoutBox()));
+    if (basicShape->layoutBox() != BoxMissing)
+        basicShapeValue->setLayoutBox(pool.createValue(basicShape->layoutBox()));
 
     return pool.createValue(basicShapeValue.release());
 }
@@ -460,7 +419,8 @@
         break;
     }
 
-    basicShape->setLayoutBox(boxForValue(basicShapeValue->layoutBox()));
+    if (basicShapeValue->layoutBox())
+        basicShape->setLayoutBox(LayoutBox(*basicShapeValue->layoutBox()));
 
     return basicShape.release();
 }

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (162000 => 162001)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2014-01-14 21:41:04 UTC (rev 162000)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2014-01-14 21:42:03 UTC (rev 162001)
@@ -2885,11 +2885,11 @@
                 ShapeClipPathOperation& shapeOperation = toShapeClipPathOperation(*operation);
                 list->append(valueForBasicShape(style.get(), shapeOperation.basicShape()));
                 if (shapeOperation.referenceBox() != BoxMissing)
-                    list->append(valueForBox(shapeOperation.referenceBox()));
+                    list->append(cssValuePool().createValue(shapeOperation.referenceBox()));
             }
             if (operation->type() == ClipPathOperation::Box) {
                 BoxClipPathOperation& boxOperation = toBoxClipPathOperation(*operation);
-                list->append(valueForBox(boxOperation.referenceBox()));
+                list->append(cssValuePool().createValue(boxOperation.referenceBox()));
             }
             return list.release();
         }
@@ -2922,7 +2922,7 @@
             if (!style->shapeInside())
                 return cssValuePool().createIdentifierValue(CSSValueNone);
             if (style->shapeInside()->type() == ShapeValue::Box)
-                return valueForBox(style->shapeInside()->layoutBox());
+                return cssValuePool().createValue(style->shapeInside()->layoutBox());
             if (style->shapeInside()->type() == ShapeValue::Outside)
                 return cssValuePool().createIdentifierValue(CSSValueOutsideShape);
             if (style->shapeInside()->type() == ShapeValue::Image) {
@@ -2936,7 +2936,7 @@
             if (!style->shapeOutside())
                 return cssValuePool().createIdentifierValue(CSSValueNone);
             if (style->shapeOutside()->type() == ShapeValue::Box)
-                return valueForBox(style->shapeOutside()->layoutBox());
+                return cssValuePool().createValue(style->shapeOutside()->layoutBox());
             if (style->shapeOutside()->type() == ShapeValue::Image) {
                 if (style->shapeOutside()->image())
                     return style->shapeOutside()->image()->cssValue();

Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (162000 => 162001)


--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2014-01-14 21:41:04 UTC (rev 162000)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2014-01-14 21:42:03 UTC (rev 162001)
@@ -5165,6 +5165,53 @@
 
 #endif // ENABLE(CSS_IMAGE_ORIENTATION)
 
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LayoutBox layoutBox)
+    : CSSValue(PrimitiveClass)
+{
+    m_primitiveUnitType = CSS_VALUE_ID;
+    switch (layoutBox) {
+    case BoundingBox:
+        m_value.valueID = CSSValueBoundingBox;
+        break;
+    case MarginBox:
+        m_value.valueID = CSSValueMarginBox;
+        break;
+    case BorderBox:
+        m_value.valueID = CSSValueBorderBox;
+        break;
+    case PaddingBox:
+        m_value.valueID = CSSValuePaddingBox;
+        break;
+    case ContentBox:
+        m_value.valueID = CSSValueContentBox;
+        break;
+    case BoxMissing:
+        ASSERT_NOT_REACHED();
+        m_value.valueID = CSSValueNone;
+        break;
+    }
 }
 
+template<> inline CSSPrimitiveValue::operator LayoutBox() const
+{
+    switch (getValueID()) {
+    case CSSValueBoundingBox:
+        return BoundingBox;
+    case CSSValueMarginBox:
+        return MarginBox;
+    case CSSValueBorderBox:
+        return BorderBox;
+    case CSSValuePaddingBox:
+        return PaddingBox;
+    case CSSValueContentBox:
+        return ContentBox;
+    default:
+        break;
+    }
+    ASSERT_NOT_REACHED();
+    return BoxMissing;
+}
+
+}
+
 #endif

Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (162000 => 162001)


--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-01-14 21:41:04 UTC (rev 162000)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-01-14 21:42:03 UTC (rev 162001)
@@ -2110,7 +2110,7 @@
                 || primitiveValue.getValueID() == CSSValueMarginBox
                 || primitiveValue.getValueID() == CSSValueBoundingBox)
                 && referenceBox == BoxMissing)
-                referenceBox = boxForValue(&primitiveValue);
+                referenceBox = LayoutBox(primitiveValue);
             else
                 return;
         }
@@ -2144,7 +2144,7 @@
                 || primitiveValue->getValueID() == CSSValueBorderBox
                 || primitiveValue->getValueID() == CSSValuePaddingBox
                 || primitiveValue->getValueID() == CSSValueMarginBox)
-                setValue(styleResolver->style(), ShapeValue::createLayoutBoxValue(boxForValue(primitiveValue)));
+                setValue(styleResolver->style(), ShapeValue::createLayoutBoxValue(LayoutBox(*primitiveValue)));
             else if (primitiveValue->getValueID() == CSSValueOutsideShape)
                 setValue(styleResolver->style(), ShapeValue::createOutsideValue());
             else if (primitiveValue->isShape()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to