2010-09-20 Daniel Bates <dbates@rim.com>
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Sep 2010 04:27:36 +0000 (04:27 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Sep 2010 04:27:36 +0000 (04:27 +0000)
        Reviewed by Dan Bernstein.

        Cleanup: Extract common border radii expansion code in
        RenderBoxModelObject::paintBoxShadow() into function
        https://bugs.webkit.org/show_bug.cgi?id=45934

        Extracted code for expanding and clamping the border radii
        into common function to remove duplicate code.

        No functionality was changed. So, no new tests.

        * rendering/RenderBoxModelObject.cpp:
        (WebCore::uniformlyExpandBorderRadii): Added.
        (WebCore::RenderBoxModelObject::paintBoxShadow): Moved common code to uniformlyExpandBorderRadii().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@67921 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/rendering/RenderBoxModelObject.cpp

index 723133e..77ef188 100644 (file)
@@ -1,3 +1,20 @@
+2010-09-20  Daniel Bates  <dbates@rim.com>
+
+        Reviewed by Dan Bernstein.
+
+        Cleanup: Extract common border radii expansion code in
+        RenderBoxModelObject::paintBoxShadow() into function
+        https://bugs.webkit.org/show_bug.cgi?id=45934
+
+        Extracted code for expanding and clamping the border radii
+        into common function to remove duplicate code.
+
+        No functionality was changed. So, no new tests.
+
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::uniformlyExpandBorderRadii): Added.
+        (WebCore::RenderBoxModelObject::paintBoxShadow): Moved common code to uniformlyExpandBorderRadii().
+
 2010-09-20  Kwang Yul Seo  <skyul@company100.net>
 
         Reviewed by James Robinson.
 2010-09-20  Kwang Yul Seo  <skyul@company100.net>
 
         Reviewed by James Robinson.
index f4c2d2a..74de8a8 100644 (file)
@@ -1590,6 +1590,18 @@ void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext* graphicsContex
     graphicsContext->clipConvexPolygon(4, secondQuad, !secondEdgeMatches);
 }
 
     graphicsContext->clipConvexPolygon(4, secondQuad, !secondEdgeMatches);
 }
 
+static inline void uniformlyExpandBorderRadii(int delta, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight)
+{
+    topLeft.expand(delta, delta);
+    topLeft.clampNegativeToZero();
+    topRight.expand(delta, delta);
+    topRight.clampNegativeToZero();
+    bottomLeft.expand(delta, delta);
+    bottomLeft.clampNegativeToZero();
+    bottomRight.expand(delta, delta);
+    bottomRight.clampNegativeToZero();
+}
+
 void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int ty, int w, int h, const RenderStyle* s, ShadowStyle shadowStyle, bool begin, bool end)
 {
     // FIXME: Deal with border-image.  Would be great to use border-image as a mask.
 void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int ty, int w, int h, const RenderStyle* s, ShadowStyle shadowStyle, bool begin, bool end)
 {
     // FIXME: Deal with border-image.  Would be great to use border-image as a mask.
@@ -1673,37 +1685,15 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
                 IntSize bottomLeftToClipOut = bottomLeft;
                 IntSize bottomRightToClipOut = bottomRight;
 
                 IntSize bottomLeftToClipOut = bottomLeft;
                 IntSize bottomRightToClipOut = bottomRight;
 
-                if (shadowSpread < 0) {
-                    topLeft.expand(shadowSpread, shadowSpread);
-                    topLeft.clampNegativeToZero();
-
-                    topRight.expand(shadowSpread, shadowSpread);
-                    topRight.clampNegativeToZero();
-
-                    bottomLeft.expand(shadowSpread, shadowSpread);
-                    bottomLeft.clampNegativeToZero();
-
-                    bottomRight.expand(shadowSpread, shadowSpread);
-                    bottomRight.clampNegativeToZero();
-                }
+                if (shadowSpread < 0)
+                    uniformlyExpandBorderRadii(shadowSpread, topLeft, topRight, bottomLeft, bottomRight);
 
                 // If the box is opaque, it is unnecessary to clip it out. However, doing so saves time
                 // when painting the shadow. On the other hand, it introduces subpixel gaps along the
                 // corners. Those are avoided by insetting the clipping path by one pixel.
                 if (hasOpaqueBackground) {
                     rectToClipOut.inflate(-1);
 
                 // If the box is opaque, it is unnecessary to clip it out. However, doing so saves time
                 // when painting the shadow. On the other hand, it introduces subpixel gaps along the
                 // corners. Those are avoided by insetting the clipping path by one pixel.
                 if (hasOpaqueBackground) {
                     rectToClipOut.inflate(-1);
-
-                    topLeftToClipOut.expand(-1, -1);
-                    topLeftToClipOut.clampNegativeToZero();
-
-                    topRightToClipOut.expand(-1, -1);
-                    topRightToClipOut.clampNegativeToZero();
-
-                    bottomLeftToClipOut.expand(-1, -1);
-                    bottomLeftToClipOut.clampNegativeToZero();
-
-                    bottomRightToClipOut.expand(-1, -1);
-                    bottomRightToClipOut.clampNegativeToZero();
+                    uniformlyExpandBorderRadii(-1, topLeftToClipOut, topRightToClipOut, bottomLeftToClipOut, bottomRightToClipOut);
                 }
 
                 if (!rectToClipOut.isEmpty())
                 }
 
                 if (!rectToClipOut.isEmpty())
@@ -1769,19 +1759,8 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
             context->addPath(Path::createRectangle(outerRect));
 
             if (hasBorderRadius) {
             context->addPath(Path::createRectangle(outerRect));
 
             if (hasBorderRadius) {
-                if (shadowSpread > 0) {
-                    topLeft.expand(-shadowSpread, -shadowSpread);
-                    topLeft.clampNegativeToZero();
-
-                    topRight.expand(-shadowSpread, -shadowSpread);
-                    topRight.clampNegativeToZero();
-
-                    bottomLeft.expand(-shadowSpread, -shadowSpread);
-                    bottomLeft.clampNegativeToZero();
-
-                    bottomRight.expand(-shadowSpread, -shadowSpread);
-                    bottomRight.clampNegativeToZero();
-                }
+                if (shadowSpread > 0)
+                    uniformlyExpandBorderRadii(-shadowSpread, topLeft, topRight, bottomLeft, bottomRight);
                 context->addPath(Path::createRoundedRectangle(holeRect, topLeft, topRight, bottomLeft, bottomRight));
             } else
                 context->addPath(Path::createRectangle(holeRect));
                 context->addPath(Path::createRoundedRectangle(holeRect, topLeft, topRight, bottomLeft, bottomRight));
             } else
                 context->addPath(Path::createRectangle(holeRect));