Diff
Added: trunk/LayoutTests/fast/canvas/drawImage-with-small-values-expected.txt (0 => 158861)
--- trunk/LayoutTests/fast/canvas/drawImage-with-small-values-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/canvas/drawImage-with-small-values-expected.txt 2013-11-07 20:11:13 UTC (rev 158861)
@@ -0,0 +1,13 @@
+Test canvas context after draw too small surface.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Test left box.
+PASS imgdata[0] is 128
+Test right box.
+PASS imgdata[0] is 128
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/canvas/drawImage-with-small-values.html (0 => 158861)
--- trunk/LayoutTests/fast/canvas/drawImage-with-small-values.html (rev 0)
+++ trunk/LayoutTests/fast/canvas/drawImage-with-small-values.html 2013-11-07 20:11:13 UTC (rev 158861)
@@ -0,0 +1,9 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+</body>
Added: trunk/LayoutTests/fast/canvas/script-tests/drawImage-with-small-values.js (0 => 158861)
--- trunk/LayoutTests/fast/canvas/script-tests/drawImage-with-small-values.js (rev 0)
+++ trunk/LayoutTests/fast/canvas/script-tests/drawImage-with-small-values.js 2013-11-07 20:11:13 UTC (rev 158861)
@@ -0,0 +1,24 @@
+description("Test canvas context after draw too small surface.");
+if (self.testRunner)
+ testRunner.overridePreference("WebKitCanvasUsesAcceleratedDrawing", 0);
+
+var tmpimg = document.createElement('canvas');
+tmpimg.width = 720;
+tmpimg.height = 960;
+ctx = tmpimg.getContext('2d');
+
+var img = document.createElement('canvas');
+img.width = 300;
+img.height = 233;
+
+ctx.drawImage(img, 337.208496, 735.022339, 225.473785, 0.005207);
+ctx.fillStyle = '#808080';
+ctx.fillRect(0, 0, 100, 100);
+ctx.fillRect(200, 0, 100, 100);
+
+debug("Test left box.");
+imgdata = ctx.getImageData(0, 0, 1, 1).data;
+shouldBe("imgdata[0]", "128");
+debug("Test right box.");
+imgdata = ctx.getImageData(200, 0, 1, 1).data;
+shouldBe("imgdata[0]", "128");
Modified: trunk/Source/WebCore/ChangeLog (158860 => 158861)
--- trunk/Source/WebCore/ChangeLog 2013-11-07 19:45:13 UTC (rev 158860)
+++ trunk/Source/WebCore/ChangeLog 2013-11-07 20:11:13 UTC (rev 158861)
@@ -1,3 +1,18 @@
+2013-11-07 Cidorvan Leite <[email protected]>
+
+ Avoid invalid cairo matrix when drawing surfaces too small
+ https://bugs.webkit.org/show_bug.cgi?id=123810
+
+ Drawing surfaces too small makes inverse matrix with values too big,
+ when this happen, cairo context is not valid anymore and it stops to draw anything.
+
+ Reviewed by Martin Robinson.
+
+ Test: fast/canvas/drawImage-with-small-values.html
+
+ * platform/graphics/cairo/PlatformContextCairo.cpp:
+ (WebCore::PlatformContextCairo::drawSurfaceToContext):
+
2013-11-07 Antti Koivisto <[email protected]>
Simple line layout crashes with SVG fonts
Modified: trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp (158860 => 158861)
--- trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp 2013-11-07 19:45:13 UTC (rev 158860)
+++ trunk/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp 2013-11-07 20:11:13 UTC (rev 158861)
@@ -156,6 +156,10 @@
void PlatformContextCairo::drawSurfaceToContext(cairo_surface_t* surface, const FloatRect& destRect, const FloatRect& originalSrcRect, GraphicsContext* context)
{
+ // Avoid invalid cairo matrix with small values.
+ if (std::fabs(destRect.width()) < 0.5f || std::fabs(destRect.height()) < 0.5f)
+ return;
+
FloatRect srcRect = originalSrcRect;
// We need to account for negative source dimensions by flipping the rectangle.