Title: [163552] trunk/Source/WebCore
Revision
163552
Author
[email protected]
Date
2014-02-06 11:34:33 -0800 (Thu, 06 Feb 2014)

Log Message

[CSS Shapes] Simplify BasicShapeInset creation
https://bugs.webkit.org/show_bug.cgi?id=128314

Reviewed by David Hyatt.

Introduce convertToLengthSize helper function in order to simplify and make BasicShapeInset more readable.

No new tests, no behavior change.

* css/BasicShapeFunctions.cpp:
(WebCore::convertToLengthSize):
(WebCore::basicShapeForValue):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (163551 => 163552)


--- trunk/Source/WebCore/ChangeLog	2014-02-06 19:26:52 UTC (rev 163551)
+++ trunk/Source/WebCore/ChangeLog	2014-02-06 19:34:33 UTC (rev 163552)
@@ -1,3 +1,18 @@
+2014-02-06  Zoltan Horvath  <[email protected]>
+
+        [CSS Shapes] Simplify BasicShapeInset creation
+        https://bugs.webkit.org/show_bug.cgi?id=128314
+
+        Reviewed by David Hyatt.
+
+        Introduce convertToLengthSize helper function in order to simplify and make BasicShapeInset more readable.
+
+        No new tests, no behavior change.
+
+        * css/BasicShapeFunctions.cpp:
+        (WebCore::convertToLengthSize):
+        (WebCore::basicShapeForValue):
+
 2014-02-06  Anders Carlsson  <[email protected]>
 
         Try to fix the Windows build.

Modified: trunk/Source/WebCore/css/BasicShapeFunctions.cpp (163551 => 163552)


--- trunk/Source/WebCore/css/BasicShapeFunctions.cpp	2014-02-06 19:26:52 UTC (rev 163551)
+++ trunk/Source/WebCore/css/BasicShapeFunctions.cpp	2014-02-06 19:34:33 UTC (rev 163552)
@@ -186,6 +186,15 @@
     return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(style, rootStyle, style->effectiveZoom());
 }
 
+static LengthSize convertToLengthSize(const RenderStyle* style, const RenderStyle* rootStyle, CSSPrimitiveValue* value)
+{
+    if (!value)
+        return LengthSize(Length(0, Fixed), Length(0, Fixed));
+
+    Pair* pair = value->getPairValue();
+    return LengthSize(convertToLength(style, rootStyle, pair->first()), convertToLength(style, rootStyle, pair->second()));
+}
+
 static BasicShapeCenterCoordinate convertToCenterCoordinate(const RenderStyle* style, const RenderStyle* rootStyle, CSSPrimitiveValue* value)
 {
     BasicShapeCenterCoordinate::Direction direction;
@@ -356,51 +365,16 @@
         const CSSBasicShapeInset* rectValue = static_cast<const CSSBasicShapeInset* >(basicShapeValue);
         RefPtr<BasicShapeInset> rect = BasicShapeInset::create();
 
-        if (rectValue->top())
-            rect->setTop(convertToLength(style, rootStyle, rectValue->top()));
-        else {
-            rect->setTop(Length(0, Fixed));
-            return rect;
-        }
-        if (rectValue->right())
-            rect->setRight(convertToLength(style, rootStyle, rectValue->right()));
-        else
-            rect->setRight(Length(0, Fixed));
+        rect->setTop(convertToLength(style, rootStyle, rectValue->top()));
+        rect->setRight(convertToLength(style, rootStyle, rectValue->right()));
+        rect->setBottom(convertToLength(style, rootStyle, rectValue->bottom()));
+        rect->setLeft(convertToLength(style, rootStyle, rectValue->left()));
 
-        if (rectValue->bottom())
-            rect->setBottom(convertToLength(style, rootStyle, rectValue->bottom()));
-        else
-            rect->setBottom(Length(0, Fixed));
+        rect->setTopLeftRadius(convertToLengthSize(style, rootStyle, rectValue->topLeftRadius()));
+        rect->setTopRightRadius(convertToLengthSize(style, rootStyle, rectValue->topRightRadius()));
+        rect->setBottomRightRadius(convertToLengthSize(style, rootStyle, rectValue->bottomRightRadius()));
+        rect->setBottomLeftRadius(convertToLengthSize(style, rootStyle, rectValue->bottomLeftRadius()));
 
-        if (rectValue->left())
-            rect->setLeft(convertToLength(style, rootStyle, rectValue->left()));
-        else
-            rect->setLeft(Length(0, Fixed));
-
-        if (rectValue->topLeftRadius()) {
-            Pair* topLeftRadius = rectValue->topLeftRadius()->getPairValue();
-            rect->setTopLeftRadius(LengthSize(convertToLength(style, rootStyle, topLeftRadius->first()), convertToLength(style, rootStyle, topLeftRadius->second())));
-        } else
-            rect->setTopLeftRadius(LengthSize(Length(0, Fixed), Length(0, Fixed)));
-
-        if (rectValue->topRightRadius()) {
-            Pair* topRightRadius = rectValue->topRightRadius()->getPairValue();
-            rect->setTopRightRadius(LengthSize(convertToLength(style, rootStyle, topRightRadius->first()), convertToLength(style, rootStyle, topRightRadius->second())));
-        } else
-            rect->setTopRightRadius(LengthSize(Length(0, Fixed), Length(0, Fixed)));
-
-        if (rectValue->bottomRightRadius()) {
-            Pair* bottomRightRadius = rectValue->bottomRightRadius()->getPairValue();
-            rect->setBottomRightRadius(LengthSize(convertToLength(style, rootStyle, bottomRightRadius->first()), convertToLength(style, rootStyle, bottomRightRadius->second())));
-        } else
-            rect->setBottomRightRadius(LengthSize(Length(0, Fixed), Length(0, Fixed)));
-
-        if (rectValue->topLeftRadius()) {
-            Pair* bottomLeftRadius = rectValue->bottomLeftRadius()->getPairValue();
-            rect->setBottomLeftRadius(LengthSize(convertToLength(style, rootStyle, bottomLeftRadius->first()), convertToLength(style, rootStyle, bottomLeftRadius->second())));
-        } else
-            rect->setBottomLeftRadius(LengthSize(Length(0, Fixed), Length(0, Fixed)));
-
         basicShape = rect.release();
         break;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to