WebCore: Fix for https://bugs.webkit.org/show_bug.cgi?id=33491 REGRESSION:
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jan 2010 22:56:09 +0000 (22:56 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jan 2010 22:56:09 +0000 (22:56 +0000)
Many SVG -webkit-shadow tests are currently failing (in the pixel
tests)
-and-
<rdar://problem/7501200>

Reviewed by Oliver Hunt.

The real fix here is to call inflateForShadow() on the repaintRect
in prepareToRenderSVGContent(). But in order to do that, I had to
move inflateForShadow() to a different class since functions in
SVGRenderBase cannot call each other. inflateForShadow() now exists
in SVGRenderStyle which I think makes some sense because a similar
function that returns a box shadow's extent exists on RenderStyle.

Now call inflateForShadow() through the SVGRenderStyle.
* rendering/RenderForeignObject.cpp:
(WebCore::RenderForeignObject::computeRectForRepaint):
* rendering/RenderSVGImage.cpp:
(WebCore::RenderSVGImage::computeRectForRepaint):
* rendering/RenderSVGModelObject.cpp:
(WebCore::RenderSVGModelObject::computeRectForRepaint):
* rendering/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::computeRectForRepaint):
* rendering/RenderSVGText.cpp:
(WebCore::RenderSVGText::computeRectForRepaint):

No longer implement inflateForShadow() here.
* rendering/SVGRenderSupport.cpp:
(WebCore::SVGRenderBase::prepareToRenderSVGContent): Call new
inflateForShadow() through the SVGRenderStyle
* rendering/SVGRenderSupport.h:

Implementation of inflateForShadow() now lives here.
* rendering/style/SVGRenderStyle.cpp:
(WebCore::getSVGShadowExtent):
(WebCore::SVGRenderStyle::inflateForShadow):
* rendering/style/SVGRenderStyle.h:

LayoutTests: New tests for https://bugs.webkit.org/show_bug.cgi?id=33491
REGRESSION: Many SVG -webkit-shadow tests are currently failing (in
the pixel tests)
-and-
<rdar://problem/7501200>

Reviewed by Oliver Hunt.

I would like to note that this change fixes some existing layout
tests as well.

* platform/mac/svg/css/shadow-with-large-radius-expected.checksum: Added.
* platform/mac/svg/css/shadow-with-large-radius-expected.png: Added.
* platform/mac/svg/css/shadow-with-large-radius-expected.txt: Added.
* platform/mac/svg/css/shadow-with-negative-offset-expected.checksum: Added.
* platform/mac/svg/css/shadow-with-negative-offset-expected.png: Added.
* platform/mac/svg/css/shadow-with-negative-offset-expected.txt: Added.
* platform/mac/svg/css/stars-with-shadow-expected.checksum:
* platform/mac/svg/css/stars-with-shadow-expected.png:
* svg/css/shadow-with-large-radius.svg: Added.
* svg/css/shadow-with-negative-offset.svg: Added.

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/svg/css/shadow-with-large-radius-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/svg/css/shadow-with-large-radius-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/css/shadow-with-large-radius-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/css/shadow-with-negative-offset-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/svg/css/shadow-with-negative-offset-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/css/shadow-with-negative-offset-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/css/stars-with-shadow-expected.checksum
LayoutTests/platform/mac/svg/css/stars-with-shadow-expected.png
LayoutTests/svg/css/shadow-with-large-radius.svg [new file with mode: 0644]
LayoutTests/svg/css/shadow-with-negative-offset.svg [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderForeignObject.cpp
WebCore/rendering/RenderSVGImage.cpp
WebCore/rendering/RenderSVGModelObject.cpp
WebCore/rendering/RenderSVGRoot.cpp
WebCore/rendering/RenderSVGText.cpp
WebCore/rendering/SVGRenderSupport.cpp
WebCore/rendering/SVGRenderSupport.h
WebCore/rendering/style/SVGRenderStyle.cpp
WebCore/rendering/style/SVGRenderStyle.h

index 8b5bdf8..965127b 100644 (file)
@@ -1,3 +1,28 @@
+2010-01-11  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Oliver Hunt.
+        
+        New tests for https://bugs.webkit.org/show_bug.cgi?id=33491 
+        REGRESSION: Many SVG -webkit-shadow tests are currently failing (in 
+        the pixel tests)
+        -and-
+        <rdar://problem/7501200>
+
+        I would like to note that this change fixes some existing layout 
+        tests as well.
+
+        * platform/mac/svg/css/shadow-with-large-radius-expected.checksum: Added.
+        * platform/mac/svg/css/shadow-with-large-radius-expected.png: Added.
+        * platform/mac/svg/css/shadow-with-large-radius-expected.txt: Added.
+        * platform/mac/svg/css/shadow-with-negative-offset-expected.checksum: Added.
+        * platform/mac/svg/css/shadow-with-negative-offset-expected.png: Added.
+        * platform/mac/svg/css/shadow-with-negative-offset-expected.txt: Added.
+        * platform/mac/svg/css/stars-with-shadow-expected.checksum:
+        * platform/mac/svg/css/stars-with-shadow-expected.png:
+        * svg/css/shadow-with-large-radius.svg: Added.
+        * svg/css/shadow-with-negative-offset.svg: Added.
+
+
 2010-01-11  Eric Seidel  <eric@webkit.org>
 
         Rubber-stamped by Csaba Osztrogonac.
diff --git a/LayoutTests/platform/mac/svg/css/shadow-with-large-radius-expected.checksum b/LayoutTests/platform/mac/svg/css/shadow-with-large-radius-expected.checksum
new file mode 100644 (file)
index 0000000..065efa9
--- /dev/null
@@ -0,0 +1 @@
+b61b672d9b1b9b1a6a79d783d7fd218f
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/css/shadow-with-large-radius-expected.png b/LayoutTests/platform/mac/svg/css/shadow-with-large-radius-expected.png
new file mode 100644 (file)
index 0000000..084e7a8
Binary files /dev/null and b/LayoutTests/platform/mac/svg/css/shadow-with-large-radius-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/css/shadow-with-large-radius-expected.txt b/LayoutTests/platform/mac/svg/css/shadow-with-large-radius-expected.txt
new file mode 100644 (file)
index 0000000..c90d22a
--- /dev/null
@@ -0,0 +1,5 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (95,95) size 110x110
+    RenderPath {path} at (95,95) size 110x110 [stroke={[type=SOLID] [color=#000000] [stroke width=10.00]}] [fill={[type=SOLID] [color=#999999]}] [data="M100.00,100.00 L200.00,100.00 L200.00,200.00 L100.00,200.00 Z"]
diff --git a/LayoutTests/platform/mac/svg/css/shadow-with-negative-offset-expected.checksum b/LayoutTests/platform/mac/svg/css/shadow-with-negative-offset-expected.checksum
new file mode 100644 (file)
index 0000000..817c807
--- /dev/null
@@ -0,0 +1 @@
+b322c1317f68c4e9b9299532233e7200
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/css/shadow-with-negative-offset-expected.png b/LayoutTests/platform/mac/svg/css/shadow-with-negative-offset-expected.png
new file mode 100644 (file)
index 0000000..3858a86
Binary files /dev/null and b/LayoutTests/platform/mac/svg/css/shadow-with-negative-offset-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/css/shadow-with-negative-offset-expected.txt b/LayoutTests/platform/mac/svg/css/shadow-with-negative-offset-expected.txt
new file mode 100644 (file)
index 0000000..c90d22a
--- /dev/null
@@ -0,0 +1,5 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (95,95) size 110x110
+    RenderPath {path} at (95,95) size 110x110 [stroke={[type=SOLID] [color=#000000] [stroke width=10.00]}] [fill={[type=SOLID] [color=#999999]}] [data="M100.00,100.00 L200.00,100.00 L200.00,200.00 L100.00,200.00 Z"]
index 41c4cd9..9b2a365 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/css/stars-with-shadow-expected.png and b/LayoutTests/platform/mac/svg/css/stars-with-shadow-expected.png differ
diff --git a/LayoutTests/svg/css/shadow-with-large-radius.svg b/LayoutTests/svg/css/shadow-with-large-radius.svg
new file mode 100644 (file)
index 0000000..83b709d
--- /dev/null
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<path d="M 100 100 L 200 100 L 200 200 L 100 200 Z" fill="#999" stroke="#000" stroke-width="10" style="-webkit-shadow: #f00 5px 5px 50px"></path>
+</svg>
diff --git a/LayoutTests/svg/css/shadow-with-negative-offset.svg b/LayoutTests/svg/css/shadow-with-negative-offset.svg
new file mode 100644 (file)
index 0000000..cb5d6d8
--- /dev/null
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<path d="M 100 100 L 200 100 L 200 200 L 100 200 Z" fill="#999" stroke="#000" stroke-width="10" style="-webkit-shadow: #f00 -5px -5px 50px"></path>
+</svg>
index 5964019..bcfe425 100644 (file)
@@ -1,3 +1,44 @@
+2010-01-11  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Fix for https://bugs.webkit.org/show_bug.cgi?id=33491 REGRESSION: 
+        Many SVG -webkit-shadow tests are currently failing (in the pixel 
+        tests)
+        -and-
+        <rdar://problem/7501200>
+
+        The real fix here is to call inflateForShadow() on the repaintRect 
+        in prepareToRenderSVGContent(). But in order to do that, I had to 
+        move inflateForShadow() to a different class since functions in 
+        SVGRenderBase cannot call each other. inflateForShadow() now exists 
+        in SVGRenderStyle which I think makes some sense because a similar 
+        function that returns a box shadow's extent exists on RenderStyle.
+
+        Now call inflateForShadow() through the SVGRenderStyle.
+        * rendering/RenderForeignObject.cpp:
+        (WebCore::RenderForeignObject::computeRectForRepaint):
+        * rendering/RenderSVGImage.cpp:
+        (WebCore::RenderSVGImage::computeRectForRepaint):
+        * rendering/RenderSVGModelObject.cpp:
+        (WebCore::RenderSVGModelObject::computeRectForRepaint):
+        * rendering/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::computeRectForRepaint):
+        * rendering/RenderSVGText.cpp:
+        (WebCore::RenderSVGText::computeRectForRepaint):
+
+        No longer implement inflateForShadow() here.
+        * rendering/SVGRenderSupport.cpp:
+        (WebCore::SVGRenderBase::prepareToRenderSVGContent): Call new 
+        inflateForShadow() through the SVGRenderStyle
+        * rendering/SVGRenderSupport.h:
+
+        Implementation of inflateForShadow() now lives here.
+        * rendering/style/SVGRenderStyle.cpp:
+        (WebCore::getSVGShadowExtent):
+        (WebCore::SVGRenderStyle::inflateForShadow):
+        * rendering/style/SVGRenderStyle.h:
+
 2010-01-11  Alexander Pavlov  <apavlov@chromium.org>
 
         Reviewed by Pavel Feldman.
index 809ad5d..35bc207 100644 (file)
@@ -84,7 +84,7 @@ FloatRect RenderForeignObject::repaintRectInLocalCoordinates() const
 void RenderForeignObject::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& rect, bool fixed)
 {
     rect = localToParentTransform().mapRect(rect);
-    inflateForShadow(style(), rect);
+    style()->svgStyle()->inflateForShadow(rect);
     RenderBlock::computeRectForRepaint(repaintContainer, rect, fixed);
 }
 
index ae648c6..5a4442d 100644 (file)
@@ -175,7 +175,7 @@ IntRect RenderSVGImage::clippedOverflowRectForRepaint(RenderBoxModelObject* repa
 
 void RenderSVGImage::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed)
 {
-    inflateForShadow(style(), repaintRect);
+    style()->svgStyle()->inflateForShadow(repaintRect);
     SVGRenderBase::computeRectForRepaint(this, repaintContainer, repaintRect, fixed);
 }
 
index 045adb4..7a76fbd 100644 (file)
@@ -56,7 +56,7 @@ IntRect RenderSVGModelObject::clippedOverflowRectForRepaint(RenderBoxModelObject
 
 void RenderSVGModelObject::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed)
 {
-    inflateForShadow(style(), repaintRect);
+    style()->svgStyle()->inflateForShadow(repaintRect);
     SVGRenderBase::computeRectForRepaint(this, repaintContainer, repaintRect, fixed);
 }
 
index e68cfc8..be8cef9 100644 (file)
@@ -265,7 +265,7 @@ void RenderSVGRoot::computeRectForRepaint(RenderBoxModelObject* repaintContainer
     // Apply our local transforms (except for x/y translation), then our shadow, 
     // and then call RenderBox's method to handle all the normal CSS Box model bits
     repaintRect = localToBorderBoxTransform().mapRect(repaintRect);
-    inflateForShadow(style(), repaintRect);
+    style()->svgStyle()->inflateForShadow(repaintRect);
     RenderBox::computeRectForRepaint(repaintContainer, repaintRect, fixed);
 }
 
index cf0fec1..5763235 100644 (file)
@@ -59,7 +59,7 @@ IntRect RenderSVGText::clippedOverflowRectForRepaint(RenderBoxModelObject* repai
 
 void RenderSVGText::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed)
 {
-    inflateForShadow(style(), repaintRect);
+    style()->svgStyle()->inflateForShadow(repaintRect);
     SVGRenderBase::computeRectForRepaint(this, repaintContainer, repaintRect, fixed);
 }
 
index a2b4cdf..a11ecef 100644 (file)
@@ -40,8 +40,6 @@
 #include "TransformationMatrix.h"
 #include <wtf/UnusedParam.h>
 
-using namespace std;
-
 namespace WebCore {
 
 SVGRenderBase::~SVGRenderBase()
@@ -61,48 +59,6 @@ IntRect SVGRenderBase::clippedOverflowRectForRepaint(RenderObject* object, Rende
     return repaintRect;
 }
 
-static void getSVGShadowExtent(ShadowData* shadow, int& top, int& right, int& bottom, int& left)
-{
-    top = 0;
-    right = 0;
-    bottom = 0;
-    left = 0;
-
-    int blurAndSpread = shadow->blur + shadow->spread;
-
-    top = min(top, shadow->y - blurAndSpread);
-    right = max(right, shadow->x + blurAndSpread);
-    bottom = max(bottom, shadow->y + blurAndSpread);
-    left = min(left, shadow->x - blurAndSpread);
-}
-
-void SVGRenderBase::inflateForShadow(RenderStyle* style, IntRect& repaintRect) const
-{
-    ASSERT(style);
-    if (!style)
-        return;
-
-    ShadowData* shadow = style->svgStyle()->shadow();
-    if (!shadow)
-        return;
-
-    int shadowTop;
-    int shadowRight;
-    int shadowBottom;
-    int shadowLeft;
-    getSVGShadowExtent(shadow, shadowTop, shadowRight, shadowBottom, shadowLeft);
-
-    int overflowLeft = repaintRect.x() + shadowLeft;
-    int overflowRight = repaintRect.right() + shadowRight;
-    int overflowTop = repaintRect.y() + shadowTop;
-    int overflowBottom = repaintRect.bottom() + shadowBottom;
-
-    repaintRect.setX(overflowLeft);
-    repaintRect.setY(overflowTop);
-    repaintRect.setWidth(overflowRight - overflowLeft);
-    repaintRect.setHeight(overflowBottom - overflowTop);
-}
-
 void SVGRenderBase::computeRectForRepaint(RenderObject* object, RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed)
 {
     // Translate to coords in our parent renderer, and then call computeRectForRepaint on our parent
@@ -144,13 +100,9 @@ bool SVGRenderBase::prepareToRenderSVGContent(RenderObject* object, RenderObject
     }
 
     if (ShadowData* shadow = svgStyle->shadow()) {
-        int xShift = shadow->x < 0 ? shadow->x : 0;
-        int yShift = shadow->y < 0 ? shadow->y :0;
-        int widthShift = shadow->x < 0 ? 0 : shadow->x;
-        int heightShift = shadow->y < 0 ? 0 : shadow->y;
-        FloatRect shadowRect = FloatRect(repaintRect.x() + xShift, repaintRect.y() + yShift,
-            repaintRect.width() + widthShift, repaintRect.height() + heightShift);
-        paintInfo.context->clip(enclosingIntRect(shadowRect));
+        IntRect shadowRect = enclosingIntRect(repaintRect);
+        svgStyle->inflateForShadow(shadowRect);
+        paintInfo.context->clip(shadowRect);
         paintInfo.context->setShadow(IntSize(shadow->x, shadow->y), shadow->blur, shadow->color, style->colorSpace());
         paintInfo.context->beginTransparencyLayer(1.0f);
     }
index bd067eb..9ea66e3 100644 (file)
@@ -56,8 +56,6 @@ namespace WebCore {
         FloatRect clipperBoundingBoxForRenderer(const RenderObject*) const;
         FloatRect maskerBoundingBoxForRenderer(const RenderObject*) const;
 
-        virtual void inflateForShadow(RenderStyle*, IntRect&) const;
-
     protected:
         static IntRect clippedOverflowRectForRepaint(RenderObject*, RenderBoxModelObject* repaintContainer);
         static void computeRectForRepaint(RenderObject*, RenderBoxModelObject* repaintContainer, IntRect&, bool fixed);
index 728738b..d5ba549 100644 (file)
 
 #include "CSSPrimitiveValue.h"
 #include "CSSValueList.h"
+#include "IntRect.h"
 #include "NodeRenderStyle.h"
 #include "RenderObject.h"
 #include "RenderStyle.h"
 #include "SVGStyledElement.h"
 
+using namespace std;
+
 namespace WebCore {
 
 SVGRenderStyle::SVGRenderStyle()
@@ -141,6 +144,45 @@ float SVGRenderStyle::cssPrimitiveToLength(const RenderObject* item, CSSValue* v
     return primitive->computeLengthFloat(const_cast<RenderStyle*>(item->style()), item->document()->documentElement()->renderStyle());
 }
 
+
+static void getSVGShadowExtent(ShadowData* shadow, int& top, int& right, int& bottom, int& left)
+{
+    top = 0;
+    right = 0;
+    bottom = 0;
+    left = 0;
+
+    int blurAndSpread = shadow->blur + shadow->spread;
+
+    top = min(top, shadow->y - blurAndSpread);
+    right = max(right, shadow->x + blurAndSpread);
+    bottom = max(bottom, shadow->y + blurAndSpread);
+    left = min(left, shadow->x - blurAndSpread);
+}
+
+void SVGRenderStyle::inflateForShadow(IntRect& repaintRect) const
+{
+    ShadowData* svgShadow = shadow();
+    if (!svgShadow)
+        return;
+
+    int shadowTop;
+    int shadowRight;
+    int shadowBottom;
+    int shadowLeft;
+    getSVGShadowExtent(svgShadow, shadowTop, shadowRight, shadowBottom, shadowLeft);
+
+    int overflowLeft = repaintRect.x() + shadowLeft;
+    int overflowRight = repaintRect.right() + shadowRight;
+    int overflowTop = repaintRect.y() + shadowTop;
+    int overflowBottom = repaintRect.bottom() + shadowBottom;
+
+    repaintRect.setX(overflowLeft);
+    repaintRect.setY(overflowTop);
+    repaintRect.setWidth(overflowRight - overflowLeft);
+    repaintRect.setHeight(overflowBottom - overflowTop);
+}
+
 }
 
 #endif // ENABLE(SVG)
index c65be97..a7cea22 100644 (file)
@@ -36,6 +36,7 @@ namespace WebCore {
 
     class RenderObject;
     class RenderStyle;
+    class IntRect;
 
     class SVGRenderStyle : public RefCounted<SVGRenderStyle> {    
     public:
@@ -45,6 +46,8 @@ namespace WebCore {
 
         bool inheritedNotEqual(const SVGRenderStyle*) const;
         void inheritFrom(const SVGRenderStyle*);
+
+        void inflateForShadow(IntRect&) const;
         
         bool operator==(const SVGRenderStyle&) const;
         bool operator!=(const SVGRenderStyle& o) const { return !(*this == o); }