Title: [126977] trunk
- Revision
- 126977
- Author
- [email protected]
- Date
- 2012-08-29 03:17:51 -0700 (Wed, 29 Aug 2012)
Log Message
Use SVGImage instead of cached image when drawing without a render tree.
https://bugs.webkit.org/show_bug.cgi?id=95002
Reviewed by Nikolas Zimmermann.
Source/WebCore:
Previously if we tried to use canvas.context2d.drawImage() with an SVG image
that was not in the render tree, we would crash. This patch changes this behavior
so that we use SVGImage::draw() to draw images that are not in the render tree.
Test: svg/as-image/svg-canvas-draw-image-detached.html
* svg/graphics/SVGImageCache.cpp:
(WebCore::SVGImageCache::requestedSizeAndScales):
(WebCore::SVGImageCache::lookupOrCreateBitmapImageForRenderer):
LayoutTests:
* svg/as-image/svg-canvas-draw-image-detached-expected.txt: Added.
* svg/as-image/svg-canvas-draw-image-detached.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (126976 => 126977)
--- trunk/LayoutTests/ChangeLog 2012-08-29 10:15:58 UTC (rev 126976)
+++ trunk/LayoutTests/ChangeLog 2012-08-29 10:17:51 UTC (rev 126977)
@@ -1,3 +1,13 @@
+2012-08-29 Philip Rogers <[email protected]>
+
+ Use SVGImage instead of cached image when drawing without a render tree.
+ https://bugs.webkit.org/show_bug.cgi?id=95002
+
+ Reviewed by Nikolas Zimmermann.
+
+ * svg/as-image/svg-canvas-draw-image-detached-expected.txt: Added.
+ * svg/as-image/svg-canvas-draw-image-detached.html: Added.
+
2012-08-22 Simon Hausmann <[email protected]>
[Qt] REGRESSION(r125428): fast/profiler/nested-start-and-stop-profiler.html fails
Added: trunk/LayoutTests/svg/as-image/svg-canvas-draw-image-detached-expected.txt (0 => 126977)
--- trunk/LayoutTests/svg/as-image/svg-canvas-draw-image-detached-expected.txt (rev 0)
+++ trunk/LayoutTests/svg/as-image/svg-canvas-draw-image-detached-expected.txt 2012-08-29 10:17:51 UTC (rev 126977)
@@ -0,0 +1,3 @@
+This test passes if there are two green boxes and no crash.
+
+
Added: trunk/LayoutTests/svg/as-image/svg-canvas-draw-image-detached.html (0 => 126977)
--- trunk/LayoutTests/svg/as-image/svg-canvas-draw-image-detached.html (rev 0)
+++ trunk/LayoutTests/svg/as-image/svg-canvas-draw-image-detached.html 2012-08-29 10:17:51 UTC (rev 126977)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<body>
+ This test passes if there are two green boxes and no crash.
+ <div style="width: 100px; height: 100px; background: url(resources/100px-green-rect.svg);"></div>
+ <br/>
+ <canvas id="canvas" width="100" height="100"></canvas>
+ <script>
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ var svg = new Image();
+ svg.src = '';
+
+ svg._onload_ = function() {
+ var canvas = document.getElementById('canvas');
+ canvas.getContext('2d').drawImage(svg, 0, 0);
+
+ if (window.testRunner)
+ testRunner.notifyDone();
+ };
+ </script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (126976 => 126977)
--- trunk/Source/WebCore/ChangeLog 2012-08-29 10:15:58 UTC (rev 126976)
+++ trunk/Source/WebCore/ChangeLog 2012-08-29 10:17:51 UTC (rev 126977)
@@ -1,3 +1,20 @@
+2012-08-29 Philip Rogers <[email protected]>
+
+ Use SVGImage instead of cached image when drawing without a render tree.
+ https://bugs.webkit.org/show_bug.cgi?id=95002
+
+ Reviewed by Nikolas Zimmermann.
+
+ Previously if we tried to use canvas.context2d.drawImage() with an SVG image
+ that was not in the render tree, we would crash. This patch changes this behavior
+ so that we use SVGImage::draw() to draw images that are not in the render tree.
+
+ Test: svg/as-image/svg-canvas-draw-image-detached.html
+
+ * svg/graphics/SVGImageCache.cpp:
+ (WebCore::SVGImageCache::requestedSizeAndScales):
+ (WebCore::SVGImageCache::lookupOrCreateBitmapImageForRenderer):
+
2012-08-22 Simon Hausmann <[email protected]>
[Qt] REGRESSION(r125428): fast/profiler/nested-start-and-stop-profiler.html fails
Modified: trunk/Source/WebCore/svg/graphics/SVGImageCache.cpp (126976 => 126977)
--- trunk/Source/WebCore/svg/graphics/SVGImageCache.cpp 2012-08-29 10:15:58 UTC (rev 126976)
+++ trunk/Source/WebCore/svg/graphics/SVGImageCache.cpp 2012-08-29 10:17:51 UTC (rev 126977)
@@ -76,7 +76,8 @@
SVGImageCache::SizeAndScales SVGImageCache::requestedSizeAndScales(const CachedImageClient* client) const
{
- ASSERT(client);
+ if (!client)
+ return SizeAndScales();
SizeAndScalesMap::const_iterator it = m_sizeAndScalesMap.find(client);
if (it == m_sizeAndScalesMap.end())
return SizeAndScales();
@@ -131,7 +132,9 @@
Image* SVGImageCache::lookupOrCreateBitmapImageForRenderer(const RenderObject* renderer)
{
- ASSERT(renderer);
+ if (!renderer)
+ return Image::nullImage();
+
const CachedImageClient* client = renderer;
// The cache needs to know the size of the renderer before querying an image for it.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes