[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

krit at webkit.org krit at webkit.org
Thu Apr 8 00:50:39 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit edc9218deff2fdfd901499e4a4c31eba732dffb6
Author: krit at webkit.org <krit at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Dec 27 22:22:31 2009 +0000

    2009-12-27  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            SVG: Stop rendering of objects with empty mask and filter content
            https://bugs.webkit.org/show_bug.cgi?id=32968
    
            It's not neccessary to continue rendering of an object and its' childs
            if the mask clips the complete content away.
            The same for filters, if the filter rendering is discontinued or either
            width or height are zero.
            We might also stop rendering if repaintRectInLocalCoordinates is empty.
            But it needs to be fixed first.
    
            Test: svg/custom/empty-mask.svg
    
            * rendering/RenderPath.cpp:
            (WebCore::RenderPath::paint):
            * rendering/RenderSVGContainer.cpp:
            (WebCore::RenderSVGContainer::paint):
            * rendering/RenderSVGImage.cpp:
            (WebCore::RenderSVGImage::paint):
            * rendering/RenderSVGRoot.cpp:
            (WebCore::RenderSVGRoot::paint):
            * rendering/SVGRenderSupport.cpp:
            (WebCore::SVGRenderBase::prepareToRenderSVGContent):
            * rendering/SVGRenderSupport.h:
            * rendering/SVGRootInlineBox.cpp:
            (WebCore::SVGRootInlineBox::paint):
            * svg/SVGMaskElement.cpp:
            (WebCore::SVGMaskElement::drawMaskerContent):
            * svg/SVGMaskElement.h:
            * svg/graphics/SVGResourceFilter.cpp:
            (WebCore::SVGResourceFilter::prepareFilter):
            (WebCore::SVGResourceFilter::applyFilter):
            * svg/graphics/SVGResourceFilter.h:
            * svg/graphics/SVGResourceMasker.cpp:
            (WebCore::SVGResourceMasker::SVGResourceMasker):
            (WebCore::SVGResourceMasker::applyMask):
            * svg/graphics/SVGResourceMasker.h:
    
    2009-12-27  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            SVG: Stop rendering of objects with empty mask and filter content
            https://bugs.webkit.org/show_bug.cgi?id=32968
    
            Check if the content is not drawn, if the mask clips the complete
            content away.
            mask-excessive-malloc needed an update. This patch stops rendering
            if there is no content in mask. But it's intention is to test
            big masking images.
    
            * platform/mac/svg/custom/empty-mask-expected.checksum: Added.
            * platform/mac/svg/custom/empty-mask-expected.png: Added.
            * platform/mac/svg/custom/empty-mask-expected.txt: Added.
            * platform/mac/svg/custom/mask-excessive-malloc-expected.checksum:
            * platform/mac/svg/custom/mask-excessive-malloc-expected.png:
            * platform/mac/svg/custom/mask-excessive-malloc-expected.txt:
            * svg/custom/empty-mask.svg: Added.
            * svg/custom/mask-excessive-malloc.svg:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52584 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index ae44298..17be87b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -2,6 +2,28 @@
 
         Reviewed by Nikolas Zimmermann.
 
+        SVG: Stop rendering of objects with empty mask and filter content
+        https://bugs.webkit.org/show_bug.cgi?id=32968
+
+        Check if the content is not drawn, if the mask clips the complete
+        content away.
+        mask-excessive-malloc needed an update. This patch stops rendering
+        if there is no content in mask. But it's intention is to test
+        big masking images.
+
+        * platform/mac/svg/custom/empty-mask-expected.checksum: Added.
+        * platform/mac/svg/custom/empty-mask-expected.png: Added.
+        * platform/mac/svg/custom/empty-mask-expected.txt: Added.
+        * platform/mac/svg/custom/mask-excessive-malloc-expected.checksum:
+        * platform/mac/svg/custom/mask-excessive-malloc-expected.png:
+        * platform/mac/svg/custom/mask-excessive-malloc-expected.txt:
+        * svg/custom/empty-mask.svg: Added.
+        * svg/custom/mask-excessive-malloc.svg:
+
+2009-12-27  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
         SVG Mask result wrong, if two different objects call the same mask id
         https://bugs.webkit.org/show_bug.cgi?id=32787
 
diff --git a/LayoutTests/platform/mac-tiger/svg/custom/mask-excessive-malloc-expected.checksum b/LayoutTests/platform/mac/svg/custom/empty-mask-expected.checksum
similarity index 100%
copy from LayoutTests/platform/mac-tiger/svg/custom/mask-excessive-malloc-expected.checksum
copy to LayoutTests/platform/mac/svg/custom/empty-mask-expected.checksum
diff --git a/LayoutTests/platform/mac/dom/xhtml/level3/core/canonicalform08-expected.png b/LayoutTests/platform/mac/svg/custom/empty-mask-expected.png
similarity index 100%
copy from LayoutTests/platform/mac/dom/xhtml/level3/core/canonicalform08-expected.png
copy to LayoutTests/platform/mac/svg/custom/empty-mask-expected.png
diff --git a/LayoutTests/platform/mac/svg/custom/empty-mask-expected.txt b/LayoutTests/platform/mac/svg/custom/empty-mask-expected.txt
new file mode 100644
index 0000000..b794322
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/empty-mask-expected.txt
@@ -0,0 +1,13 @@
+KCanvasResource {id="mask" [type=MASKER]}
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (20,20) size 100x100
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGContainer {mask} at (-0.50,-0.50) size 0.10x0.10
+        RenderPath {rect} at (-0.50,-0.50) size 0.10x0.10 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M-0.50,-0.50 L-0.40,-0.50 L-0.40,-0.40 L-0.50,-0.40 Z"]
+    RenderPath {rect} at (20,20) size 100x100 [fill={[type=SOLID] [color=#008000]}] [data="M20.00,20.00 L120.00,20.00 L120.00,120.00 L20.00,120.00 Z"]
+    RenderSVGText {text} at (60,60) size 21x18 contains 1 chunk(s)
+      RenderSVGTSpan {tspan} at (0,0) size 21x18
+        RenderSVGInlineText {#text} at (0,-14) size 21x18
+          chunk 1 text run 1 at (60.00,60.00) startOffset 0 endOffset 4 width 21.00: "test"
diff --git a/LayoutTests/platform/mac/svg/custom/mask-excessive-malloc-expected.checksum b/LayoutTests/platform/mac/svg/custom/mask-excessive-malloc-expected.checksum
index 759d4e5..d69a371 100644
--- a/LayoutTests/platform/mac/svg/custom/mask-excessive-malloc-expected.checksum
+++ b/LayoutTests/platform/mac/svg/custom/mask-excessive-malloc-expected.checksum
@@ -1 +1 @@
-ab530b29c2e0ac4b08a0534e355ac7f6
\ No newline at end of file
+853de00567d121bea0b7bece66a5d61c
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/mask-excessive-malloc-expected.png b/LayoutTests/platform/mac/svg/custom/mask-excessive-malloc-expected.png
index cdbb726..12fde95 100644
Binary files a/LayoutTests/platform/mac/svg/custom/mask-excessive-malloc-expected.png and b/LayoutTests/platform/mac/svg/custom/mask-excessive-malloc-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/mask-excessive-malloc-expected.txt b/LayoutTests/platform/mac/svg/custom/mask-excessive-malloc-expected.txt
index 5ef42af..89590f2 100644
--- a/LayoutTests/platform/mac/svg/custom/mask-excessive-malloc-expected.txt
+++ b/LayoutTests/platform/mac/svg/custom/mask-excessive-malloc-expected.txt
@@ -2,6 +2,7 @@ KCanvasResource {id="mask" [type=MASKER]}
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 800x600
-  RenderSVGRoot {svg} at (200,200) size 100x200
-    RenderSVGContainer {mask} at (0,0) size 0x0
+  RenderSVGRoot {svg} at (0,0) size 2147483648.00x2147483648.00
+    RenderSVGContainer {mask} at (0,0) size 2147483648.00x2147483648.00
+      RenderPath {rect} at (0,0) size 2147483648.00x2147483648.00 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M0.00,0.00 L2147483648.00,0.00 L2147483648.00,2147483648.00 L0.00,2147483648.00 Z"]
     RenderPath {path} at (200,200) size 100x200 [fill={[type=SOLID] [color=#0000FF]}] [data="M200.00,200.00 L300.00,200.00 L300.00,400.00 L200.00,400.00 Z"]
diff --git a/LayoutTests/svg/custom/empty-mask.svg b/LayoutTests/svg/custom/empty-mask.svg
new file mode 100644
index 0000000..2b9d4c1
--- /dev/null
+++ b/LayoutTests/svg/custom/empty-mask.svg
@@ -0,0 +1,9 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<defs>
+<mask id="mask">
+    <rect x="-0.5" y="-0.5" width="0.1" height="0.1" fill="white"/>
+</mask>
+</defs>
+<rect x="20" y="20" width="100" height="100" style="fill:green;mask:url(#mask);"/>
+<text x="60" y="60" style="fill:green;mask:url(#mask);"><tspan>test</tspan></text>
+</svg>
diff --git a/LayoutTests/svg/custom/mask-excessive-malloc.svg b/LayoutTests/svg/custom/mask-excessive-malloc.svg
index 5040c93..71a2bb1 100644
--- a/LayoutTests/svg/custom/mask-excessive-malloc.svg
+++ b/LayoutTests/svg/custom/mask-excessive-malloc.svg
@@ -1,5 +1,7 @@
 <?xml version="1.0"?>
 <svg xmlns="http://www.w3.org/2000/svg">
-<mask id="mask" width="1000000000000000" height="1000000000000000"/>
+<mask id="mask" width="2147483647" height="2147483647">
+    <rect x="0" y="0" width="2147483647" height="2147483647" fill="white"/>
+</mask>
 <path mask="url(#mask)" fill="blue" d="M 200 200 l 100 0 l 0 200 l -100 0 Z"/>
 </svg>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e1f3dd0..e9977c2 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,44 @@
+2009-12-27  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVG: Stop rendering of objects with empty mask and filter content
+        https://bugs.webkit.org/show_bug.cgi?id=32968
+
+        It's not neccessary to continue rendering of an object and its' childs
+        if the mask clips the complete content away.
+        The same for filters, if the filter rendering is discontinued or either
+        width or height are zero.
+        We might also stop rendering if repaintRectInLocalCoordinates is empty.
+        But it needs to be fixed first.
+
+        Test: svg/custom/empty-mask.svg
+
+        * rendering/RenderPath.cpp:
+        (WebCore::RenderPath::paint):
+        * rendering/RenderSVGContainer.cpp:
+        (WebCore::RenderSVGContainer::paint):
+        * rendering/RenderSVGImage.cpp:
+        (WebCore::RenderSVGImage::paint):
+        * rendering/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::paint):
+        * rendering/SVGRenderSupport.cpp:
+        (WebCore::SVGRenderBase::prepareToRenderSVGContent):
+        * rendering/SVGRenderSupport.h:
+        * rendering/SVGRootInlineBox.cpp:
+        (WebCore::SVGRootInlineBox::paint):
+        * svg/SVGMaskElement.cpp:
+        (WebCore::SVGMaskElement::drawMaskerContent):
+        * svg/SVGMaskElement.h:
+        * svg/graphics/SVGResourceFilter.cpp:
+        (WebCore::SVGResourceFilter::prepareFilter):
+        (WebCore::SVGResourceFilter::applyFilter):
+        * svg/graphics/SVGResourceFilter.h:
+        * svg/graphics/SVGResourceMasker.cpp:
+        (WebCore::SVGResourceMasker::SVGResourceMasker):
+        (WebCore::SVGResourceMasker::applyMask):
+        * svg/graphics/SVGResourceMasker.h:
+
 2009-12-27  Christian Dywan  <christian at twotoasts.de>
 
         Reviewed by Eric Seidel.
diff --git a/WebCore/rendering/RenderPath.cpp b/WebCore/rendering/RenderPath.cpp
index 0438ec4..320a1b6 100644
--- a/WebCore/rendering/RenderPath.cpp
+++ b/WebCore/rendering/RenderPath.cpp
@@ -190,14 +190,14 @@ void RenderPath::paint(PaintInfo& paintInfo, int, int)
     if (paintInfo.phase == PaintPhaseForeground) {
         PaintInfo savedInfo(paintInfo);
 
-        prepareToRenderSVGContent(this, paintInfo, boundingBox, filter);
-        if (style()->svgStyle()->shapeRendering() == SR_CRISPEDGES)
-            paintInfo.context->setShouldAntialias(false);
-        fillAndStrokePath(m_path, paintInfo.context, style(), this);
-
-        if (static_cast<SVGStyledElement*>(node())->supportsMarkers())
-            m_markerBounds = drawMarkersIfNeeded(paintInfo, m_path);
+        if (prepareToRenderSVGContent(this, paintInfo, boundingBox, filter)) {
+            if (style()->svgStyle()->shapeRendering() == SR_CRISPEDGES)
+                paintInfo.context->setShouldAntialias(false);
+            fillAndStrokePath(m_path, paintInfo.context, style(), this);
 
+            if (static_cast<SVGStyledElement*>(node())->supportsMarkers())
+                m_markerBounds = drawMarkersIfNeeded(paintInfo, m_path);
+        }
         finishRenderSVGContent(this, paintInfo, filter, savedInfo.context);
     }
 
diff --git a/WebCore/rendering/RenderSVGContainer.cpp b/WebCore/rendering/RenderSVGContainer.cpp
index a3d5867..e6bcdba 100644
--- a/WebCore/rendering/RenderSVGContainer.cpp
+++ b/WebCore/rendering/RenderSVGContainer.cpp
@@ -109,12 +109,16 @@ void RenderSVGContainer::paint(PaintInfo& paintInfo, int, int)
 
     SVGResourceFilter* filter = 0;
     FloatRect boundingBox = repaintRectInLocalCoordinates();
+
+    bool continueRendering = true;
     if (childPaintInfo.phase == PaintPhaseForeground)
-        prepareToRenderSVGContent(this, childPaintInfo, boundingBox, filter);
+        continueRendering = prepareToRenderSVGContent(this, childPaintInfo, boundingBox, filter);
 
-    childPaintInfo.paintingRoot = paintingRootForChildren(childPaintInfo);
-    for (RenderObject* child = firstChild(); child; child = child->nextSibling())
-        child->paint(childPaintInfo, 0, 0);
+    if (continueRendering) {
+        childPaintInfo.paintingRoot = paintingRootForChildren(childPaintInfo);
+        for (RenderObject* child = firstChild(); child; child = child->nextSibling())
+            child->paint(childPaintInfo, 0, 0);
+    }
 
     if (paintInfo.phase == PaintPhaseForeground)
         finishRenderSVGContent(this, childPaintInfo, filter, paintInfo.context);
diff --git a/WebCore/rendering/RenderSVGImage.cpp b/WebCore/rendering/RenderSVGImage.cpp
index 32d9654..a42b2a6 100644
--- a/WebCore/rendering/RenderSVGImage.cpp
+++ b/WebCore/rendering/RenderSVGImage.cpp
@@ -157,16 +157,16 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, int, int)
 
         PaintInfo savedInfo(paintInfo);
 
-        prepareToRenderSVGContent(this, paintInfo, m_localBounds, filter);
+        if (prepareToRenderSVGContent(this, paintInfo, m_localBounds, filter)) {
+            FloatRect destRect = m_localBounds;
+            FloatRect srcRect(0, 0, image()->width(), image()->height());
 
-        FloatRect destRect = m_localBounds;
-        FloatRect srcRect(0, 0, image()->width(), image()->height());
+            SVGImageElement* imageElt = static_cast<SVGImageElement*>(node());
+            if (imageElt->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
+                adjustRectsForAspectRatio(destRect, srcRect, imageElt->preserveAspectRatio());
 
-        SVGImageElement* imageElt = static_cast<SVGImageElement*>(node());
-        if (imageElt->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
-            adjustRectsForAspectRatio(destRect, srcRect, imageElt->preserveAspectRatio());
-
-        paintInfo.context->drawImage(image(), DeviceColorSpace, destRect, srcRect);
+            paintInfo.context->drawImage(image(), DeviceColorSpace, destRect, srcRect);
+        }
         finishRenderSVGContent(this, paintInfo, filter, savedInfo.context);
     }
 
diff --git a/WebCore/rendering/RenderSVGRoot.cpp b/WebCore/rendering/RenderSVGRoot.cpp
index d014277..675d9a3 100644
--- a/WebCore/rendering/RenderSVGRoot.cpp
+++ b/WebCore/rendering/RenderSVGRoot.cpp
@@ -153,10 +153,13 @@ void RenderSVGRoot::paint(PaintInfo& paintInfo, int parentX, int parentY)
 
     SVGResourceFilter* filter = 0;
     FloatRect boundingBox = repaintRectInLocalCoordinates();
+
+    bool continueRendering = true;
     if (childPaintInfo.phase == PaintPhaseForeground)
-        prepareToRenderSVGContent(this, childPaintInfo, boundingBox, filter);
+        continueRendering = prepareToRenderSVGContent(this, childPaintInfo, boundingBox, filter);
 
-    RenderBox::paint(childPaintInfo, 0, 0);
+    if (continueRendering)
+        RenderBox::paint(childPaintInfo, 0, 0);
 
     if (childPaintInfo.phase == PaintPhaseForeground)
         finishRenderSVGContent(this, childPaintInfo, filter, paintInfo.context);
diff --git a/WebCore/rendering/SVGRenderSupport.cpp b/WebCore/rendering/SVGRenderSupport.cpp
index bfaa9a8..1ff70b2 100644
--- a/WebCore/rendering/SVGRenderSupport.cpp
+++ b/WebCore/rendering/SVGRenderSupport.cpp
@@ -69,7 +69,7 @@ void SVGRenderBase::mapLocalToContainer(const RenderObject* object, RenderBoxMod
     object->parent()->mapLocalToContainer(repaintContainer, fixed, useTransforms, transformState);
 }
 
-void SVGRenderBase::prepareToRenderSVGContent(RenderObject* object, RenderObject::PaintInfo& paintInfo, const FloatRect& boundingBox, SVGResourceFilter*& filter, SVGResourceFilter* rootFilter)
+bool SVGRenderBase::prepareToRenderSVGContent(RenderObject* object, RenderObject::PaintInfo& paintInfo, const FloatRect& boundingBox, SVGResourceFilter*& filter, SVGResourceFilter* rootFilter)
 {
 #if !ENABLE(FILTERS)
     UNUSED_PARAM(filter);
@@ -131,7 +131,8 @@ void SVGRenderBase::prepareToRenderSVGContent(RenderObject* object, RenderObject
 
     if (masker) {
         masker->addClient(styledElement);
-        masker->applyMask(paintInfo.context, boundingBox);
+        if (!masker->applyMask(paintInfo.context, boundingBox))
+            return false;
     } else if (!maskerId.isEmpty())
         svgElement->document()->accessSVGExtensions()->addPendingResource(maskerId, styledElement);
 
@@ -144,10 +145,13 @@ void SVGRenderBase::prepareToRenderSVGContent(RenderObject* object, RenderObject
 #if ENABLE(FILTERS)
     if (filter) {
         filter->addClient(styledElement);
-        filter->prepareFilter(paintInfo.context, object);
+        if (!filter->prepareFilter(paintInfo.context, object))
+            return false;
     } else if (!filterId.isEmpty())
         svgElement->document()->accessSVGExtensions()->addPendingResource(filterId, styledElement);
 #endif
+
+    return true;
 }
 
 void SVGRenderBase::finishRenderSVGContent(RenderObject* object, RenderObject::PaintInfo& paintInfo, SVGResourceFilter*& filter, GraphicsContext* savedContext)
diff --git a/WebCore/rendering/SVGRenderSupport.h b/WebCore/rendering/SVGRenderSupport.h
index da2bf59..431f579 100644
--- a/WebCore/rendering/SVGRenderSupport.h
+++ b/WebCore/rendering/SVGRenderSupport.h
@@ -41,7 +41,7 @@ namespace WebCore {
         // FIXME: These are only public for SVGRootInlineBox.
         // It's unclear if these should be exposed or not.  SVGRootInlineBox may
         // pass the wrong RenderObject* and boundingBox to these functions.
-        static void prepareToRenderSVGContent(RenderObject*, RenderObject::PaintInfo&, const FloatRect& boundingBox, SVGResourceFilter*&, SVGResourceFilter* rootFilter = 0);
+        static bool prepareToRenderSVGContent(RenderObject*, RenderObject::PaintInfo&, const FloatRect& boundingBox, SVGResourceFilter*&, SVGResourceFilter* rootFilter = 0);
         static void finishRenderSVGContent(RenderObject*, RenderObject::PaintInfo&, SVGResourceFilter*&, GraphicsContext* savedContext);
 
     protected:
diff --git a/WebCore/rendering/SVGRootInlineBox.cpp b/WebCore/rendering/SVGRootInlineBox.cpp
index 5829742..aac723b 100644
--- a/WebCore/rendering/SVGRootInlineBox.cpp
+++ b/WebCore/rendering/SVGRootInlineBox.cpp
@@ -575,18 +575,18 @@ void SVGRootInlineBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
     FloatRect boundingBox(tx + x(), ty + y(), width(), height());
 
     // Initialize text rendering
-    SVGRenderBase::prepareToRenderSVGContent(renderer(), paintInfo, boundingBox, filter);
- 
-    // Render text, chunk-by-chunk
-    SVGRootInlineBoxPaintWalker walkerCallback(this, filter, paintInfo, tx, ty);
-    SVGTextChunkWalker<SVGRootInlineBoxPaintWalker> walker(&walkerCallback,
-                                                           &SVGRootInlineBoxPaintWalker::chunkPortionCallback,
-                                                           &SVGRootInlineBoxPaintWalker::chunkStartCallback,
-                                                           &SVGRootInlineBoxPaintWalker::chunkEndCallback,
-                                                           &SVGRootInlineBoxPaintWalker::chunkSetupFillCallback,
-                                                           &SVGRootInlineBoxPaintWalker::chunkSetupStrokeCallback);
-
-    walkTextChunks(&walker);
+    if (SVGRenderBase::prepareToRenderSVGContent(renderer(), paintInfo, boundingBox, filter)) {
+        // Render text, chunk-by-chunk
+        SVGRootInlineBoxPaintWalker walkerCallback(this, filter, paintInfo, tx, ty);
+        SVGTextChunkWalker<SVGRootInlineBoxPaintWalker> walker(&walkerCallback,
+                                                               &SVGRootInlineBoxPaintWalker::chunkPortionCallback,
+                                                               &SVGRootInlineBoxPaintWalker::chunkStartCallback,
+                                                               &SVGRootInlineBoxPaintWalker::chunkEndCallback,
+                                                               &SVGRootInlineBoxPaintWalker::chunkSetupFillCallback,
+                                                               &SVGRootInlineBoxPaintWalker::chunkSetupStrokeCallback);
+
+        walkTextChunks(&walker);
+    }
 
     // Finalize text rendering 
     SVGRenderBase::finishRenderSVGContent(renderer(), paintInfo, filter, savedInfo.context);
diff --git a/WebCore/svg/SVGMaskElement.cpp b/WebCore/svg/SVGMaskElement.cpp
index ba6b7a6..8ad96ab 100644
--- a/WebCore/svg/SVGMaskElement.cpp
+++ b/WebCore/svg/SVGMaskElement.cpp
@@ -133,7 +133,7 @@ void SVGMaskElement::childrenChanged(bool changedByParser, Node* beforeChange, N
         it->second->invalidate();
 }
 
-PassOwnPtr<ImageBuffer> SVGMaskElement::drawMaskerContent(const FloatRect& objectBoundingBox, FloatRect& maskDestRect) const
+PassOwnPtr<ImageBuffer> SVGMaskElement::drawMaskerContent(const FloatRect& objectBoundingBox, FloatRect& maskDestRect, bool& emptyMask) const
 {    
     // Determine specified mask size
     if (maskUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
@@ -174,8 +174,15 @@ PassOwnPtr<ImageBuffer> SVGMaskElement::drawMaskerContent(const FloatRect& objec
     repaintRect.intersect(maskDestRect);
     maskDestRect = repaintRect;
     IntRect maskImageRect = enclosingIntRect(maskDestRect);
+
     maskImageRect.setLocation(IntPoint());
 
+    // Don't create ImageBuffers with image size of 0
+    if (!maskImageRect.width() || !maskImageRect.height()) {
+        emptyMask = true;
+        return 0;
+    }
+
     // FIXME: This changes color space to linearRGB, the default color space
     // for masking operations in SVG. We need a switch for the other color-space
     // attribute values sRGB, inherit and auto.
@@ -200,9 +207,6 @@ PassOwnPtr<ImageBuffer> SVGMaskElement::drawMaskerContent(const FloatRect& objec
 
     maskImageContext->restore();
 
-    if (!maskImageRect.width() || !maskImageRect.height())
-        return maskImage.release();
-
     // create the luminance mask
     RefPtr<ImageData> imageData(maskImage->getUnmultipliedImageData(maskImageRect));
     CanvasPixelArray* srcPixelArray(imageData->data());
diff --git a/WebCore/svg/SVGMaskElement.h b/WebCore/svg/SVGMaskElement.h
index 3df8977..3da5f25 100644
--- a/WebCore/svg/SVGMaskElement.h
+++ b/WebCore/svg/SVGMaskElement.h
@@ -51,7 +51,7 @@ namespace WebCore {
         virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
         virtual SVGResource* canvasResource(const RenderObject*);
 
-        PassOwnPtr<ImageBuffer> drawMaskerContent(const FloatRect& targetRect, FloatRect& maskRect) const;
+        PassOwnPtr<ImageBuffer> drawMaskerContent(const FloatRect& targetRect, FloatRect& maskRect, bool& emptyMask) const;
 
     private:
         ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGNames::maskTagString, SVGNames::maskUnitsAttrString, int, MaskUnits, maskUnits)
diff --git a/WebCore/svg/graphics/SVGResourceFilter.cpp b/WebCore/svg/graphics/SVGResourceFilter.cpp
index 272fb10..aaa4332 100644
--- a/WebCore/svg/graphics/SVGResourceFilter.cpp
+++ b/WebCore/svg/graphics/SVGResourceFilter.cpp
@@ -86,13 +86,13 @@ bool SVGResourceFilter::fitsInMaximumImageSize(const FloatSize& size)
     return matchesFilterSize;
 }
 
-void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const RenderObject* object)
+bool SVGResourceFilter::prepareFilter(GraphicsContext*& context, const RenderObject* object)
 {
     FloatRect targetRect = object->objectBoundingBox();
     m_ownerElement->buildFilter(targetRect);
 
     if (shouldProcessFilter(this))
-        return;
+        return false;
 
     // clip sourceImage to filterRegion
     FloatRect clippedSourceRect = targetRect;
@@ -122,7 +122,8 @@ void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const RenderObj
             m_filter->setFilterResolution(FloatSize(m_scaleX, m_scaleY));
             lastEffect->calculateEffectRect(m_filter.get());
         }
-    }
+    } else
+        return false;
 
     clippedSourceRect.scale(m_scaleX, m_scaleY);
 
@@ -132,7 +133,7 @@ void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const RenderObj
     OwnPtr<ImageBuffer> sourceGraphic(ImageBuffer::create(bufferRect.size(), LinearRGB));
     
     if (!sourceGraphic.get())
-        return;
+        return false;
 
     GraphicsContext* sourceGraphicContext = sourceGraphic->context();
     sourceGraphicContext->translate(-clippedSourceRect.x(), -clippedSourceRect.y());
@@ -142,13 +143,11 @@ void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const RenderObj
     m_savedContext = context;
 
     context = sourceGraphicContext;
+    return true;
 }
 
 void SVGResourceFilter::applyFilter(GraphicsContext*& context, const RenderObject* object)
 {
-    if (shouldProcessFilter(this))
-        return;
-
     if (!m_savedContext)
         return;
 
diff --git a/WebCore/svg/graphics/SVGResourceFilter.h b/WebCore/svg/graphics/SVGResourceFilter.h
index 30f6daa..aab3414 100644
--- a/WebCore/svg/graphics/SVGResourceFilter.h
+++ b/WebCore/svg/graphics/SVGResourceFilter.h
@@ -71,7 +71,7 @@ public:
     FloatRect filterBoundingBox() { return m_filterBBox; }
     void setFilterBoundingBox(const FloatRect& rect) { m_filterBBox = rect; }
 
-    void prepareFilter(GraphicsContext*&, const RenderObject*);
+    bool prepareFilter(GraphicsContext*&, const RenderObject*);
     void applyFilter(GraphicsContext*&, const RenderObject*);
 
     bool fitsInMaximumImageSize(const FloatSize&);
diff --git a/WebCore/svg/graphics/SVGResourceMasker.cpp b/WebCore/svg/graphics/SVGResourceMasker.cpp
index 8d95bdf..e2e9a5c 100644
--- a/WebCore/svg/graphics/SVGResourceMasker.cpp
+++ b/WebCore/svg/graphics/SVGResourceMasker.cpp
@@ -46,6 +46,7 @@ namespace WebCore {
 SVGResourceMasker::SVGResourceMasker(const SVGMaskElement* ownerElement)
     : SVGResource()
     , m_ownerElement(ownerElement)
+    , m_emptyMask(false)
 {
 }
 
@@ -57,17 +58,19 @@ void SVGResourceMasker::invalidate()
 {
     SVGResource::invalidate();
     m_mask.clear();
+    m_emptyMask = false;
 }
 
-void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& boundingBox)
+bool SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& boundingBox)
 {
-    if (!m_mask)
-        m_mask = m_ownerElement->drawMaskerContent(boundingBox, m_maskRect);
+    if (!m_mask && !m_emptyMask)
+        m_mask = m_ownerElement->drawMaskerContent(boundingBox, m_maskRect, m_emptyMask);
 
     if (!m_mask)
-        return;
+        return false;
 
     context->clipToImageBuffer(m_maskRect, m_mask.get());
+    return true;
 }
 
 TextStream& SVGResourceMasker::externalRepresentation(TextStream& ts) const
diff --git a/WebCore/svg/graphics/SVGResourceMasker.h b/WebCore/svg/graphics/SVGResourceMasker.h
index 594d416..ac71818 100644
--- a/WebCore/svg/graphics/SVGResourceMasker.h
+++ b/WebCore/svg/graphics/SVGResourceMasker.h
@@ -54,7 +54,7 @@ namespace WebCore {
         virtual TextStream& externalRepresentation(TextStream&) const;
 
         // To be implemented by the specific rendering devices
-        void applyMask(GraphicsContext*, const FloatRect& boundingBox);
+        bool applyMask(GraphicsContext*, const FloatRect& boundingBox);
 
     private:
         SVGResourceMasker(const SVGMaskElement*);
@@ -63,6 +63,7 @@ namespace WebCore {
         
         OwnPtr<ImageBuffer> m_mask;
         FloatRect m_maskRect;
+        bool m_emptyMask;
     };
 
     SVGResourceMasker* getMaskerById(Document*, const AtomicString&, const RenderObject* object);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list