[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

zimmermann at webkit.org zimmermann at webkit.org
Wed Dec 22 12:37:59 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 28825720e94d8e7c55d804689212a7227601198c
Author: zimmermann at webkit.org <zimmermann at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Aug 26 10:27:20 2010 +0000

    2010-08-26  Nikolas Zimmermann  <nzimmermann at rim.com>
    
            Reviewed by Dirk Schulze.
    
            text-shadow is not respected in RenderSVGText::repaintRectInLocalCoordinates()
            https://bugs.webkit.org/show_bug.cgi?id=44616
    
            Centralize code to calculate the shadow extents in ShadowData.
            Respect textShadow() when calculating the repaint rect of RenderSVGText.
    
            Tests: svg/css/composite-shadow-text.svg
                   transitions/svg-text-shadow-transition.html
    
            * rendering/RenderObject.cpp:
            (WebCore::RenderObject::adjustRectForOutlineAndShadow):
            * rendering/RenderSVGRoot.cpp:
            (WebCore::RenderSVGRoot::repaintRectInLocalCoordinates):
            (WebCore::RenderSVGRoot::computeRectForRepaint):
            * rendering/RenderSVGText.cpp:
            (WebCore::RenderSVGText::repaintRectInLocalCoordinates):
            * rendering/SVGRenderSupport.cpp:
            (WebCore::SVGRenderSupport::computeRectForRepaint):
            (WebCore::SVGRenderSupport::prepareToRenderSVGContent):
            (WebCore::SVGRenderSupport::finishRenderSVGContent):
            (WebCore::SVGRenderSupport::intersectRepaintRectWithResources):
            * rendering/style/SVGRenderStyle.cpp:
            * rendering/style/SVGRenderStyle.h:
            * rendering/style/ShadowData.cpp:
            (WebCore::calculateShadowExtent):
            (WebCore::ShadowData::adjustRectForShadow):
            * rendering/style/ShadowData.h:
    
    2010-08-26  Nikolas Zimmermann  <nzimmermann at rim.com>
    
            Reviewed by Dirk Schulze.
    
            text-shadow is not respected in RenderSVGText::repaintRectInLocalCoordinates()
            https://bugs.webkit.org/show_bug.cgi?id=44616
    
            * platform/mac/svg/css/composite-shadow-text-expected.checksum: Added.
            * platform/mac/svg/css/composite-shadow-text-expected.png: Added.
            * platform/mac/svg/css/composite-shadow-text-expected.txt: Added.
            * platform/mac/svg/css/text-shadow-multiple-expected.txt:
            * platform/mac/transitions/svg-text-shadow-transition-expected.checksum: Added.
            * platform/mac/transitions/svg-text-shadow-transition-expected.png: Added.
            * platform/mac/transitions/svg-text-shadow-transition-expected.txt: Added.
            * svg/css/composite-shadow-text.svg: Added.
            * transitions/svg-text-shadow-transition.html: Added.
            * transitions/transition-test-helpers.js: Cleanup code, accept negative offsets in the regexp for shadow.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66093 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 1a14ab4..006147b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2010-08-26  Nikolas Zimmermann  <nzimmermann at rim.com>
+
+        Reviewed by Dirk Schulze.
+
+        text-shadow is not respected in RenderSVGText::repaintRectInLocalCoordinates()
+        https://bugs.webkit.org/show_bug.cgi?id=44616
+
+        * platform/mac/svg/css/composite-shadow-text-expected.checksum: Added.
+        * platform/mac/svg/css/composite-shadow-text-expected.png: Added.
+        * platform/mac/svg/css/composite-shadow-text-expected.txt: Added.
+        * platform/mac/svg/css/text-shadow-multiple-expected.txt:
+        * platform/mac/transitions/svg-text-shadow-transition-expected.checksum: Added.
+        * platform/mac/transitions/svg-text-shadow-transition-expected.png: Added.
+        * platform/mac/transitions/svg-text-shadow-transition-expected.txt: Added.
+        * svg/css/composite-shadow-text.svg: Added.
+        * transitions/svg-text-shadow-transition.html: Added.
+        * transitions/transition-test-helpers.js: Cleanup code, accept negative offsets in the regexp for shadow.
+
 2010-08-26  Philippe Normand  <pnormand at igalia.com>
 
         Unreviewed, skip a flakey test.
diff --git a/LayoutTests/platform/mac/svg/css/composite-shadow-text-expected.checksum b/LayoutTests/platform/mac/svg/css/composite-shadow-text-expected.checksum
new file mode 100644
index 0000000..ea1aa55
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/css/composite-shadow-text-expected.checksum
@@ -0,0 +1 @@
+7b8f12f4290cb0b321f194463c40a749
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/css/composite-shadow-text-expected.png b/LayoutTests/platform/mac/svg/css/composite-shadow-text-expected.png
new file mode 100644
index 0000000..89de975
Binary files /dev/null and b/LayoutTests/platform/mac/svg/css/composite-shadow-text-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/css/composite-shadow-text-expected.txt b/LayoutTests/platform/mac/svg/css/composite-shadow-text-expected.txt
new file mode 100644
index 0000000..bf73b12
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/css/composite-shadow-text-expected.txt
@@ -0,0 +1,24 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (9,9) size 361x445
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceLinearGradient {linearGradient} [id="gradient"] [gradientUnits=objectBoundingBox] [start=(0,0)] [end=(1,0)]
+        RenderSVGGradientStop {stop} [offset=0.00] [color=#0000FF]
+        RenderSVGGradientStop {stop} [offset=1.00] [color=#FF0000]
+      RenderSVGResourcePattern {pattern} [id="pattern"] [patternUnits=userSpaceOnUse] [patternContentUnits=userSpaceOnUse]
+        RenderPath {rect} at (0,0) size 10x10 [fill={[type=SOLID] [color=#0000FF]}] [data="M0.00,0.00 L10.00,0.00 L10.00,10.00 L0.00,10.00 Z"]
+        RenderPath {rect} at (0,10) size 10x10 [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,10.00 L10.00,10.00 L10.00,20.00 L0.00,20.00 Z"]
+    RenderSVGContainer {g} at (9,9) size 245x427
+      RenderSVGText {text} at (10,10) size 183x115 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 183x115
+          chunk 1 text run 1 at (10.00,100.00) startOffset 0 endOffset 4 width 183.00: "Test"
+      RenderSVGText {text} at (10,135) size 183x115 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 183x115
+          chunk 1 text run 1 at (10.00,225.00) startOffset 0 endOffset 4 width 183.00: "Test"
+      RenderSVGText {text} at (10,260) size 183x115 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 183x115
+          chunk 1 text run 1 at (10.00,350.00) startOffset 0 endOffset 4 width 183.00: "Test"
+    RenderSVGText {text} at (30,436) size 340x18 contains 1 chunk(s)
+      RenderSVGInlineText {#text} at (0,0) size 340x18
+        chunk 1 (middle anchor) text run 1 at (30.00,450.00) startOffset 0 endOffset 51 width 340.00: "The word Test should only be shadowd once, per line"
diff --git a/LayoutTests/platform/mac/svg/css/text-shadow-multiple-expected.txt b/LayoutTests/platform/mac/svg/css/text-shadow-multiple-expected.txt
index 1b7b032..a9f15c9 100644
--- a/LayoutTests/platform/mac/svg/css/text-shadow-multiple-expected.txt
+++ b/LayoutTests/platform/mac/svg/css/text-shadow-multiple-expected.txt
@@ -30,7 +30,7 @@ layer at (0,0) size 800x408
         RenderText {#text} at (0,0) size 556x18
           text run at (0,0) width 556: "The next two texts have subtle differences, as the stroke/fill is painted seperated in SVG."
       RenderBlock (anonymous) at (0,238) size 800x154
-        RenderSVGRoot {svg} at (20,324) size 720x56
+        RenderSVGRoot {svg} at (0,307) size 747x89
           RenderSVGText {text} at (20,20) size 720x56 contains 1 chunk(s)
             RenderSVGTSpan {tspan} at (0,0) size 95x56
               RenderSVGInlineText {#text} at (0,0) size 95x56
diff --git a/LayoutTests/platform/mac/transitions/svg-text-shadow-transition-expected.checksum b/LayoutTests/platform/mac/transitions/svg-text-shadow-transition-expected.checksum
new file mode 100644
index 0000000..11d0c17
--- /dev/null
+++ b/LayoutTests/platform/mac/transitions/svg-text-shadow-transition-expected.checksum
@@ -0,0 +1 @@
+1c50dcc3c217c22c3b31f714599af80c
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/transitions/svg-text-shadow-transition-expected.png b/LayoutTests/platform/mac/transitions/svg-text-shadow-transition-expected.png
new file mode 100644
index 0000000..6915a03
Binary files /dev/null and b/LayoutTests/platform/mac/transitions/svg-text-shadow-transition-expected.png differ
diff --git a/LayoutTests/platform/mac/transitions/svg-text-shadow-transition-expected.txt b/LayoutTests/platform/mac/transitions/svg-text-shadow-transition-expected.txt
new file mode 100644
index 0000000..8ad1e8d
--- /dev/null
+++ b/LayoutTests/platform/mac/transitions/svg-text-shadow-transition-expected.txt
@@ -0,0 +1,18 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x156
+  RenderBlock {HTML} at (0,0) size 800x156
+    RenderBody {BODY} at (8,8) size 784x140
+      RenderBlock (anonymous) at (0,0) size 784x104
+        RenderSVGRoot {svg} at (8,12) size 307x76
+          RenderSVGText {text} at (10,14) size 277x46 contains 1 chunk(s)
+            RenderSVGInlineText {#text} at (0,0) size 277x46
+              chunk 1 text run 1 at (10.00,50.00) startOffset 0 endOffset 15 width 277.00: "Shadow on texts"
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {DIV} at (0,104) size 784x36
+        RenderText {#text} at (0,0) size 577x18
+          text run at (0,0) width 577: "PASS - \"text-shadow\" property for \"text\" element at 0s saw something close to: -25,-5,0,15"
+        RenderBR {BR} at (577,0) size 0x18
+        RenderText {#text} at (0,18) size 559x18
+          text run at (0,18) width 559: "PASS - \"text-shadow\" property for \"text\" element at 1s saw something close to: 5,5,0,15"
+        RenderBR {BR} at (559,18) size 0x18
diff --git a/LayoutTests/svg/css/composite-shadow-text.svg b/LayoutTests/svg/css/composite-shadow-text.svg
new file mode 100644
index 0000000..5c886fc
--- /dev/null
+++ b/LayoutTests/svg/css/composite-shadow-text.svg
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+    <linearGradient id="gradient" gradientUnits="objectBoundingBox" x1="0" y1="0" x2="1" y2="0">
+        <stop stop-color="blue"  offset="0"/>
+        <stop stop-color="red"  offset="1"/>
+    </linearGradient>
+
+    <pattern id="pattern" patternUnits="userSpaceOnUse" x="0" y="0" width="10" height="20">
+        <rect x="0" y="0" width="10" height="10" fill="blue" />
+        <rect x="0" y="10" width="10" height="10" fill="red" />
+    </pattern>
+</defs>
+
+<g style="-webkit-svg-shadow: rgba(106,119,64, 0.7) 25px 25px 5px;">
+    <text x="10" y="100" fill="url(#gradient)" stroke="yellow" style="font-weight:bold; font-size:100px;">Test</text>
+    <text x="10" y="225" fill="url(#pattern)" stroke="yellow" style="font-weight:bold; font-size:100px;">Test</text>
+    <text x="10" y="350" fill="green" stroke="red" style="font-weight:bold; font-size:100px;">Test</text>
+</g>
+<text x="200" y="450" text-anchor="middle">The word Test should only be shadowd once, per line</text>
+</svg>
diff --git a/LayoutTests/transitions/svg-text-shadow-transition.html b/LayoutTests/transitions/svg-text-shadow-transition.html
new file mode 100644
index 0000000..7b8ab75
--- /dev/null
+++ b/LayoutTests/transitions/svg-text-shadow-transition.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style type="text/css" media="screen">
+        .text {
+            -webkit-transition-duration: 1s;
+            -webkit-transition-timing-function: linear;
+            -webkit-transition-property: text-shadow;
+        }
+
+        #text {
+            text-shadow: -25px -5px 15px red;
+        }
+
+        #text.final {
+            text-shadow: 5px 5px 15px green;
+        }
+    </style>
+
+    <script src="transition-test-helpers.js" type="text/javascript" charset="utf-8"></script>
+    <script type="text/javascript" charset="utf-8">
+        const expectedValues = [
+            // [time, element-id, property, expected-value, tolerance]
+            [0, 'text', 'text-shadow', [-25, -5, 0, 15], 4],
+            [1, 'text', 'text-shadow', [5, 5, 0, 15], 4]
+        ];
+
+        function setupTest()
+        {
+            document.getElementById('text').className.baseVal = 'text final';
+        }
+
+        runTransitionTest(expectedValues, setupTest, true, true);
+    </script>
+</head>
+<body>
+    <svg width="400" height="100">
+        <text id="text" class="text" x="10" y="50" style="font-size:30pt; font-weight:bold;">Shadow on texts</text>
+    </svg>
+
+    <div id="result">
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/transitions/transition-test-helpers.js b/LayoutTests/transitions/transition-test-helpers.js
index 50386db..b23be12 100644
--- a/LayoutTests/transitions/transition-test-helpers.js
+++ b/LayoutTests/transitions/transition-test-helpers.js
@@ -41,11 +41,9 @@ function getShadowXY(cssValue)
 {
     var text = cssValue.cssText;
     // Shadow cssText looks like "rgb(0, 0, 255) 0px -3px 10px 0px"
-    var shadowPositionRegExp = /\)\s*(\d+)px\s*(-?\d+)px/;
-    var result = shadowPositionRegExp.exec(cssValue.cssText);
-
-    var result = [parseInt(result[1]), parseInt(result[2])];
-    return result;
+    var shadowPositionRegExp = /\)\s*(-?\d+)px\s*(-?\d+)px/;
+    var result = shadowPositionRegExp.exec(text);
+    return [parseInt(result[1]), parseInt(result[2])];
 }
 
 function checkExpectedValue(expected, index)
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3c04fb7..88c5d36 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,35 @@
+2010-08-26  Nikolas Zimmermann  <nzimmermann at rim.com>
+
+        Reviewed by Dirk Schulze.
+
+        text-shadow is not respected in RenderSVGText::repaintRectInLocalCoordinates()
+        https://bugs.webkit.org/show_bug.cgi?id=44616
+
+        Centralize code to calculate the shadow extents in ShadowData.
+        Respect textShadow() when calculating the repaint rect of RenderSVGText.
+
+        Tests: svg/css/composite-shadow-text.svg
+               transitions/svg-text-shadow-transition.html
+
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::adjustRectForOutlineAndShadow):
+        * rendering/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::repaintRectInLocalCoordinates):
+        (WebCore::RenderSVGRoot::computeRectForRepaint):
+        * rendering/RenderSVGText.cpp:
+        (WebCore::RenderSVGText::repaintRectInLocalCoordinates):
+        * rendering/SVGRenderSupport.cpp:
+        (WebCore::SVGRenderSupport::computeRectForRepaint):
+        (WebCore::SVGRenderSupport::prepareToRenderSVGContent):
+        (WebCore::SVGRenderSupport::finishRenderSVGContent):
+        (WebCore::SVGRenderSupport::intersectRepaintRectWithResources):
+        * rendering/style/SVGRenderStyle.cpp:
+        * rendering/style/SVGRenderStyle.h:
+        * rendering/style/ShadowData.cpp:
+        (WebCore::calculateShadowExtent):
+        (WebCore::ShadowData::adjustRectForShadow):
+        * rendering/style/ShadowData.h:
+
 2010-08-25  Xan Lopez  <xlopez at igalia.com>
 
         Reviewed by Martin Robinson.
diff --git a/WebCore/rendering/RenderObject.cpp b/WebCore/rendering/RenderObject.cpp
index 11b4374..0eb05b1 100644
--- a/WebCore/rendering/RenderObject.cpp
+++ b/WebCore/rendering/RenderObject.cpp
@@ -2553,27 +2553,11 @@ void RenderObject::adjustRectForOutlineAndShadow(IntRect& rect) const
 {
     int outlineSize = outlineStyleForRepaint()->outlineSize();
     if (const ShadowData* boxShadow = style()->boxShadow()) {
-        int shadowLeft = 0;
-        int shadowRight = 0;
-        int shadowTop = 0;
-        int shadowBottom = 0;
-
-        do {
-            if (boxShadow->style() == Normal) {
-                shadowLeft = min(boxShadow->x() - boxShadow->blur() - boxShadow->spread() - outlineSize, shadowLeft);
-                shadowRight = max(boxShadow->x() + boxShadow->blur() + boxShadow->spread() + outlineSize, shadowRight);
-                shadowTop = min(boxShadow->y() - boxShadow->blur() - boxShadow->spread() - outlineSize, shadowTop);
-                shadowBottom = max(boxShadow->y() + boxShadow->blur() + boxShadow->spread() + outlineSize, shadowBottom);
-            }
-
-            boxShadow = boxShadow->next();
-        } while (boxShadow);
+        boxShadow->adjustRectForShadow(rect, outlineSize);
+        return;
+    }
 
-        rect.move(shadowLeft, shadowTop);
-        rect.setWidth(rect.width() - shadowLeft + shadowRight);
-        rect.setHeight(rect.height() - shadowTop + shadowBottom);
-    } else
-        rect.inflate(outlineSize);
+    rect.inflate(outlineSize);
 }
 
 AnimationController* RenderObject::animation() const
diff --git a/WebCore/rendering/RenderSVGRoot.cpp b/WebCore/rendering/RenderSVGRoot.cpp
index b66a870..5995668 100644
--- a/WebCore/rendering/RenderSVGRoot.cpp
+++ b/WebCore/rendering/RenderSVGRoot.cpp
@@ -280,7 +280,11 @@ FloatRect RenderSVGRoot::strokeBoundingBox() const
 FloatRect RenderSVGRoot::repaintRectInLocalCoordinates() const
 {
     FloatRect repaintRect = SVGRenderSupport::computeContainerBoundingBox(this, SVGRenderSupport::RepaintBoundingBox);
-    style()->svgStyle()->inflateForShadow(repaintRect);
+
+    const SVGRenderStyle* svgStyle = style()->svgStyle();
+    if (const ShadowData* shadow = svgStyle->shadow())
+        shadow->adjustRectForShadow(repaintRect);
+
     repaintRect.inflate(borderAndPaddingWidth());
     return repaintRect;
 }
@@ -299,7 +303,10 @@ void RenderSVGRoot::computeRectForRepaint(RenderBoxModelObject* repaintContainer
     // Apply initial viewport clip - not affected by overflow settings    
     repaintRect.intersect(enclosingIntRect(FloatRect(FloatPoint(), m_viewportSize)));
 
-    style()->svgStyle()->inflateForShadow(repaintRect);
+    const SVGRenderStyle* svgStyle = style()->svgStyle();
+    if (const ShadowData* shadow = svgStyle->shadow())
+        shadow->adjustRectForShadow(repaintRect);
+
     RenderBox::computeRectForRepaint(repaintContainer, repaintRect, fixed);
 }
 
diff --git a/WebCore/rendering/RenderSVGText.cpp b/WebCore/rendering/RenderSVGText.cpp
index 20c8a7c..4b70643 100644
--- a/WebCore/rendering/RenderSVGText.cpp
+++ b/WebCore/rendering/RenderSVGText.cpp
@@ -178,6 +178,9 @@ FloatRect RenderSVGText::repaintRectInLocalCoordinates() const
     FloatRect repaintRect = strokeBoundingBox();
     SVGRenderSupport::intersectRepaintRectWithResources(this, repaintRect);
 
+    if (const ShadowData* textShadow = style()->textShadow())
+        textShadow->adjustRectForShadow(repaintRect);
+
     return repaintRect;
 }
 
diff --git a/WebCore/rendering/SVGRenderSupport.cpp b/WebCore/rendering/SVGRenderSupport.cpp
index 12d6d77..fc99c91 100644
--- a/WebCore/rendering/SVGRenderSupport.cpp
+++ b/WebCore/rendering/SVGRenderSupport.cpp
@@ -61,7 +61,9 @@ IntRect SVGRenderSupport::clippedOverflowRectForRepaint(RenderObject* object, Re
 
 void SVGRenderSupport::computeRectForRepaint(RenderObject* object, RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed)
 {
-    object->style()->svgStyle()->inflateForShadow(repaintRect);
+    const SVGRenderStyle* svgStyle = object->style()->svgStyle();
+    if (const ShadowData* shadow = svgStyle->shadow())
+        shadow->adjustRectForShadow(repaintRect);
 
     // Translate to coords in our parent renderer, and then call computeRectForRepaint on our parent
     repaintRect = object->localToParentTransform().mapRect(repaintRect);
@@ -86,24 +88,22 @@ bool SVGRenderSupport::prepareToRenderSVGContent(RenderObject* object, PaintInfo
     const SVGRenderStyle* svgStyle = style->svgStyle();
     ASSERT(svgStyle);
 
-    FloatRect repaintRect;
-
     // Setup transparency layers before setting up SVG resources!
     float opacity = style->opacity();
-    if (opacity < 1) {
-        repaintRect = object->repaintRectInLocalCoordinates();
-        paintInfo.context->clip(repaintRect);
-        paintInfo.context->beginTransparencyLayer(opacity);
-    }
+    const ShadowData* shadow = svgStyle->shadow();
+    if (opacity < 1 || shadow) {
+        FloatRect repaintRect = object->repaintRectInLocalCoordinates();
 
-    if (const ShadowData* shadow = svgStyle->shadow()) {
-        // Eventually compute repaint rect, if not done so far.
-        if (opacity >= 1)
-            repaintRect = object->repaintRectInLocalCoordinates();
+        if (opacity < 1) {
+            paintInfo.context->clip(repaintRect);
+            paintInfo.context->beginTransparencyLayer(opacity);
+        }
 
-        paintInfo.context->clip(repaintRect);
-        paintInfo.context->setShadow(IntSize(shadow->x(), shadow->y()), shadow->blur(), shadow->color(), style->colorSpace());
-        paintInfo.context->beginTransparencyLayer(1);
+        if (shadow) {
+            paintInfo.context->clip(repaintRect);
+            paintInfo.context->setShadow(IntSize(shadow->x(), shadow->y()), shadow->blur(), shadow->color(), style->colorSpace());
+            paintInfo.context->beginTransparencyLayer(1);
+        }
     }
 
     SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(object);
@@ -154,12 +154,9 @@ void SVGRenderSupport::finishRenderSVGContent(RenderObject* object, PaintInfo& p
     }
 #endif
 
-    float opacity = style->opacity();    
-    if (opacity < 1)
+    if (style->opacity() < 1)
         paintInfo.context->endTransparencyLayer();
 
-    // This needs to be done separately from opacity, because if both properties are set,
-    // then the transparency layers are nested. 
     if (svgStyle->shadow())
         paintInfo.context->endTransparencyLayer();
 }
@@ -281,7 +278,8 @@ void SVGRenderSupport::intersectRepaintRectWithResources(const RenderObject* obj
     RenderObject* renderer = const_cast<RenderObject*>(object);
     SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(renderer);
     if (!resources) {
-        svgStyle->inflateForShadow(repaintRect);
+        if (const ShadowData* shadow = svgStyle->shadow())
+            shadow->adjustRectForShadow(repaintRect);
         return;
     }
 
@@ -296,7 +294,8 @@ void SVGRenderSupport::intersectRepaintRectWithResources(const RenderObject* obj
     if (RenderSVGResourceMasker* masker = resources->masker())
         repaintRect.intersect(masker->resourceBoundingBox(renderer));
 
-    svgStyle->inflateForShadow(repaintRect);
+    if (const ShadowData* shadow = svgStyle->shadow())
+        shadow->adjustRectForShadow(repaintRect);
 }
 
 bool SVGRenderSupport::pointInClippingArea(RenderObject* object, const FloatPoint& point)
diff --git a/WebCore/rendering/style/SVGRenderStyle.cpp b/WebCore/rendering/style/SVGRenderStyle.cpp
index dc8a5af..51d2f20 100644
--- a/WebCore/rendering/style/SVGRenderStyle.cpp
+++ b/WebCore/rendering/style/SVGRenderStyle.cpp
@@ -215,48 +215,6 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const
     return StyleDifferenceEqual;
 }
 
-static void getSVGShadowExtent(ShadowData* shadow, float& top, float& right, float& bottom, float& left)
-{
-    top = 0.0f;
-    right = 0.0f;
-    bottom = 0.0f;
-    left = 0.0f;
-
-    float 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;
-
-    FloatRect repaintFloatRect = FloatRect(repaintRect);
-    inflateForShadow(repaintFloatRect);
-    repaintRect = enclosingIntRect(repaintFloatRect);
-}
-
-void SVGRenderStyle::inflateForShadow(FloatRect& repaintRect) const
-{
-    ShadowData* svgShadow = shadow();
-    if (!svgShadow)
-        return;
-
-    float shadowTop;
-    float shadowRight;
-    float shadowBottom;
-    float shadowLeft;
-    getSVGShadowExtent(svgShadow, shadowTop, shadowRight, shadowBottom, shadowLeft);
-
-    repaintRect.move(shadowLeft, shadowTop);
-    repaintRect.setSize(repaintRect.size() + FloatSize(shadowRight - shadowLeft, shadowBottom - shadowTop));
-}
-
 }
 
 #endif // ENABLE(SVG)
diff --git a/WebCore/rendering/style/SVGRenderStyle.h b/WebCore/rendering/style/SVGRenderStyle.h
index f071755..d57e4cf 100644
--- a/WebCore/rendering/style/SVGRenderStyle.h
+++ b/WebCore/rendering/style/SVGRenderStyle.h
@@ -47,10 +47,6 @@ public:
     bool inheritedNotEqual(const SVGRenderStyle*) const;
     void inheritFrom(const SVGRenderStyle*);
 
-    // FIXME: These functions should move to ShadowData.
-    void inflateForShadow(IntRect&) const;
-    void inflateForShadow(FloatRect&) const;
-
     StyleDifference diff(const SVGRenderStyle*) const;
 
     bool operator==(const SVGRenderStyle&) const;
diff --git a/WebCore/rendering/style/ShadowData.cpp b/WebCore/rendering/style/ShadowData.cpp
index d4569d0..3a8f81d 100644
--- a/WebCore/rendering/style/ShadowData.cpp
+++ b/WebCore/rendering/style/ShadowData.cpp
@@ -22,6 +22,11 @@
 #include "config.h"
 #include "ShadowData.h"
 
+#include "FloatRect.h"
+#include "IntRect.h"
+
+using namespace std;
+
 namespace WebCore {
 
 ShadowData::ShadowData(const ShadowData& o)
@@ -44,4 +49,45 @@ bool ShadowData::operator==(const ShadowData& o) const
     return m_x == o.m_x && m_y == o.m_y && m_blur == o.m_blur && m_spread == o.m_spread && m_style == o.m_style && m_color == o.m_color;
 }
 
+static inline void calculateShadowExtent(const ShadowData* shadow, int additionalOutlineSize, int& shadowLeft, int& shadowRight, int& shadowTop, int& shadowBottom)
+{
+    do {
+        int blurAndSpread = shadow->blur() + shadow->spread() + additionalOutlineSize;
+        if (shadow->style() == Normal) {
+            shadowLeft = min(shadow->x() - blurAndSpread, shadowLeft);
+            shadowRight = max(shadow->x() + blurAndSpread, shadowRight);
+            shadowTop = min(shadow->y() - blurAndSpread, shadowTop);
+            shadowBottom = max(shadow->y() + blurAndSpread, shadowBottom);
+        }
+
+        shadow = shadow->next();
+    } while (shadow);
+}
+
+void ShadowData::adjustRectForShadow(IntRect& rect, int additionalOutlineSize) const
+{
+    int shadowLeft = 0;
+    int shadowRight = 0;
+    int shadowTop = 0;
+    int shadowBottom = 0;
+    calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight, shadowTop, shadowBottom);
+
+    rect.move(shadowLeft, shadowTop);
+    rect.setWidth(rect.width() - shadowLeft + shadowRight);
+    rect.setHeight(rect.height() - shadowTop + shadowBottom);
+}
+
+void ShadowData::adjustRectForShadow(FloatRect& rect, int additionalOutlineSize) const
+{
+    int shadowLeft = 0;
+    int shadowRight = 0;
+    int shadowTop = 0;
+    int shadowBottom = 0;
+    calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight, shadowTop, shadowBottom);
+
+    rect.move(shadowLeft, shadowTop);
+    rect.setWidth(rect.width() - shadowLeft + shadowRight);
+    rect.setHeight(rect.height() - shadowTop + shadowBottom);
+}
+
 } // namespace WebCore
diff --git a/WebCore/rendering/style/ShadowData.h b/WebCore/rendering/style/ShadowData.h
index 9252e13..ca83af0 100644
--- a/WebCore/rendering/style/ShadowData.h
+++ b/WebCore/rendering/style/ShadowData.h
@@ -30,6 +30,9 @@
 
 namespace WebCore {
 
+class FloatRect;
+class IntRect;
+
 enum ShadowStyle { Normal, Inset };
 
 // This struct holds information about shadows for the text-shadow and box-shadow properties.
@@ -76,6 +79,9 @@ public:
     const ShadowData* next() const { return m_next; }
     void setNext(ShadowData* shadow) { m_next = shadow; }
 
+    void adjustRectForShadow(IntRect&, int additionalOutlineSize = 0) const;
+    void adjustRectForShadow(FloatRect&, int additionalOutlineSize = 0) const;
+
 private:
     int m_x;
     int m_y;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list