Title: [110563] trunk
Revision
110563
Author
[email protected]
Date
2012-03-13 08:14:57 -0700 (Tue, 13 Mar 2012)

Log Message

Crash in WebCore::GraphicsContext::paintingDisabled
https://bugs.webkit.org/show_bug.cgi?id=80669

Reviewed by Nikolas Zimmermann.

Source/WebCore: 

The SVGImageBufferTools::clipToImageBuffer method deletes the clip
image when it thinks it is not needed. However, there are cases when
it is in fact still needed, particularly when the clip buffer is
coming from higher up in the stack where it may be needed again.

So this patch adds a flag to only allow deletion of the image buffer
if it was created at the most recent call site.

Tests: svg/custom/circular-clip-path-references-crash-expected.svg
       svg/custom/circular-clip-path-references-crash.svg

* rendering/svg/RenderSVGResourceClipper.cpp:
(WebCore::RenderSVGResourceClipper::applyClippingToContext):
* rendering/svg/RenderSVGResourceGradient.cpp:
(WebCore::clipToTextMask):
* rendering/svg/RenderSVGResourceMasker.cpp:
(WebCore::RenderSVGResourceMasker::applyResource):
* rendering/svg/SVGImageBufferTools.cpp:
(WebCore::SVGImageBufferTools::clipToImageBuffer):
* rendering/svg/SVGImageBufferTools.h:
(SVGImageBufferTools):

LayoutTests: 

* svg/custom/circular-clip-path-references-crash-expected.svg: Added.
* svg/custom/circular-clip-path-references-crash.svg: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (110562 => 110563)


--- trunk/LayoutTests/ChangeLog	2012-03-13 15:02:49 UTC (rev 110562)
+++ trunk/LayoutTests/ChangeLog	2012-03-13 15:14:57 UTC (rev 110563)
@@ -1,3 +1,13 @@
+2012-03-13  Stephen Chenney  <[email protected]>
+
+        Crash in WebCore::GraphicsContext::paintingDisabled
+        https://bugs.webkit.org/show_bug.cgi?id=80669
+
+        Reviewed by Nikolas Zimmermann.
+
+        * svg/custom/circular-clip-path-references-crash-expected.svg: Added.
+        * svg/custom/circular-clip-path-references-crash.svg: Added.
+
 2012-03-13  Ádám Kallai  <[email protected]>
 
         [Qt] Skip some tests until fix.

Added: trunk/LayoutTests/svg/custom/circular-clip-path-references-crash-expected.svg (0 => 110563)


--- trunk/LayoutTests/svg/custom/circular-clip-path-references-crash-expected.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/circular-clip-path-references-crash-expected.svg	2012-03-13 15:14:57 UTC (rev 110563)
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+
+<text x="10" y="75">This test passes if it does not crash.</text>
+
+</svg>

Added: trunk/LayoutTests/svg/custom/circular-clip-path-references-crash.svg (0 => 110563)


--- trunk/LayoutTests/svg/custom/circular-clip-path-references-crash.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/circular-clip-path-references-crash.svg	2012-03-13 15:14:57 UTC (rev 110563)
@@ -0,0 +1,25 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+    <clipPath id="clip0">
+        <rect width="1" height="1" clip-path="url(#clip)" />
+
+    </clipPath>
+
+    <clipPath id="clip2">
+        <rect width="100" height="100" clip-path="url(#clip0)"/>
+    </clipPath>
+
+    <clipPath id="clip">
+        <rect width="1" height="1" clip-path="url(#clip2)"/>
+    </clipPath>
+
+    <mask id="mask1" x="0" y="0" width="1" height="1" maskContentUnits="objectBoundingBox">
+        <rect width="1" height="1" clip-path="url(#clip)" />
+    </mask>
+</defs>
+
+<text x="10" y="75">This test passes if it does not crash.</text>
+
+<circle r="50" mask="url(#mask1)"/>
+
+</svg>

Modified: trunk/Source/WebCore/ChangeLog (110562 => 110563)


--- trunk/Source/WebCore/ChangeLog	2012-03-13 15:02:49 UTC (rev 110562)
+++ trunk/Source/WebCore/ChangeLog	2012-03-13 15:14:57 UTC (rev 110563)
@@ -1,3 +1,32 @@
+2012-03-13  Stephen Chenney  <[email protected]>
+
+        Crash in WebCore::GraphicsContext::paintingDisabled
+        https://bugs.webkit.org/show_bug.cgi?id=80669
+
+        Reviewed by Nikolas Zimmermann.
+
+        The SVGImageBufferTools::clipToImageBuffer method deletes the clip
+        image when it thinks it is not needed. However, there are cases when
+        it is in fact still needed, particularly when the clip buffer is
+        coming from higher up in the stack where it may be needed again.
+
+        So this patch adds a flag to only allow deletion of the image buffer
+        if it was created at the most recent call site.
+
+        Tests: svg/custom/circular-clip-path-references-crash-expected.svg
+               svg/custom/circular-clip-path-references-crash.svg
+
+        * rendering/svg/RenderSVGResourceClipper.cpp:
+        (WebCore::RenderSVGResourceClipper::applyClippingToContext):
+        * rendering/svg/RenderSVGResourceGradient.cpp:
+        (WebCore::clipToTextMask):
+        * rendering/svg/RenderSVGResourceMasker.cpp:
+        (WebCore::RenderSVGResourceMasker::applyResource):
+        * rendering/svg/SVGImageBufferTools.cpp:
+        (WebCore::SVGImageBufferTools::clipToImageBuffer):
+        * rendering/svg/SVGImageBufferTools.h:
+        (SVGImageBufferTools):
+
 2012-03-13  Gavin Peters  <[email protected]>
 
         Fix an enumeration name in ReasonsFrameCannotBeInPageCache.

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp (110562 => 110563)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp	2012-03-13 15:02:49 UTC (rev 110562)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp	2012-03-13 15:14:57 UTC (rev 110563)
@@ -155,7 +155,8 @@
 bool RenderSVGResourceClipper::applyClippingToContext(RenderObject* object, const FloatRect& objectBoundingBox,
                                                       const FloatRect& repaintRect, GraphicsContext* context)
 {
-    if (!m_clipper.contains(object))
+    bool missingClipperData = !m_clipper.contains(object);
+    if (missingClipperData)
         m_clipper.set(object, new ClipperData);
 
     bool shouldCreateClipData = false;
@@ -201,7 +202,7 @@
     if (!clipperData->clipMaskImage)
         return false;
 
-    SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, repaintRect, clipperData->clipMaskImage);
+    SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, repaintRect, clipperData->clipMaskImage, missingClipperData);
     return true;
 }
 

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp (110562 => 110563)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp	2012-03-13 15:02:49 UTC (rev 110562)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp	2012-03-13 15:14:57 UTC (rev 110563)
@@ -98,7 +98,7 @@
     SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(textRootBlock, absoluteTransform);
 
     targetRect = textRootBlock->repaintRectInLocalCoordinates();
-    SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, targetRect, imageBuffer);
+    SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, targetRect, imageBuffer, false);
 
     AffineTransform matrix;
     if (boundingBoxMode) {

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp (110562 => 110563)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp	2012-03-13 15:02:49 UTC (rev 110562)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp	2012-03-13 15:14:57 UTC (rev 110563)
@@ -86,7 +86,8 @@
     ASSERT(context);
     ASSERT_UNUSED(resourceMode, resourceMode == ApplyToDefaultMode);
 
-    if (!m_masker.contains(object))
+    bool missingMaskerData = !m_masker.contains(object);
+    if (missingMaskerData)
         m_masker.set(object, new MaskerData);
 
     MaskerData* maskerData = m_masker.get(object);
@@ -116,7 +117,7 @@
     if (!maskerData->maskImage)
         return false;
 
-    SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, repaintRect, maskerData->maskImage);
+    SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, repaintRect, maskerData->maskImage, missingMaskerData);
     return true;
 }
 

Modified: trunk/Source/WebCore/rendering/svg/SVGImageBufferTools.cpp (110562 => 110563)


--- trunk/Source/WebCore/rendering/svg/SVGImageBufferTools.cpp	2012-03-13 15:02:49 UTC (rev 110562)
+++ trunk/Source/WebCore/rendering/svg/SVGImageBufferTools.cpp	2012-03-13 15:14:57 UTC (rev 110563)
@@ -121,7 +121,7 @@
     contentTransformation = savedContentTransformation;
 }
 
-void SVGImageBufferTools::clipToImageBuffer(GraphicsContext* context, const AffineTransform& absoluteTransform, const FloatRect& targetRect, OwnPtr<ImageBuffer>& imageBuffer)
+void SVGImageBufferTools::clipToImageBuffer(GraphicsContext* context, const AffineTransform& absoluteTransform, const FloatRect& targetRect, OwnPtr<ImageBuffer>& imageBuffer, bool safeToClear)
 {
     ASSERT(context);
     ASSERT(imageBuffer);
@@ -136,7 +136,7 @@
 
     // When nesting resources, with objectBoundingBox as content unit types, there's no use in caching the
     // resulting image buffer as the parent resource already caches the result.
-    if (!currentContentTransformation().isIdentity())
+    if (safeToClear && !currentContentTransformation().isIdentity())
         imageBuffer.clear();
 }
 

Modified: trunk/Source/WebCore/rendering/svg/SVGImageBufferTools.h (110562 => 110563)


--- trunk/Source/WebCore/rendering/svg/SVGImageBufferTools.h	2012-03-13 15:02:49 UTC (rev 110562)
+++ trunk/Source/WebCore/rendering/svg/SVGImageBufferTools.h	2012-03-13 15:14:57 UTC (rev 110563)
@@ -42,7 +42,7 @@
     static bool createImageBufferForPattern(const FloatRect& absoluteTargetRect, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>&, ColorSpace, RenderingMode);
 
     static void renderSubtreeToImageBuffer(ImageBuffer*, RenderObject*, const AffineTransform&);
-    static void clipToImageBuffer(GraphicsContext*, const AffineTransform& absoluteTransform, const FloatRect& targetRect, OwnPtr<ImageBuffer>&);
+    static void clipToImageBuffer(GraphicsContext*, const AffineTransform& absoluteTransform, const FloatRect& targetRect, OwnPtr<ImageBuffer>&, bool safeToClear);
 
     static void calculateTransformationToOutermostSVGCoordinateSystem(const RenderObject*, AffineTransform& absoluteTransform);
     static IntSize clampedAbsoluteSize(const IntSize&);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to