+2008-12-29 Oliver Hunt <oliver@apple.com>
+
+ Reviewed by Cameron Zwarich.
+
+ Bug 23030: Cannot setTransform with a non-invertible ctm
+
+ Tests to ensure correct behaviour when the canvas context does not
+ have an invertible CTM.
+
+ * fast/canvas/canvas-set-properties-with-non-invertible-ctm-expected.txt: Added.
+ * fast/canvas/canvas-set-properties-with-non-invertible-ctm.html: Added.
+ * fast/canvas/resources/canvas-set-properties-with-non-invertible-ctm.js: Added.
+ (testPixel):
+
2008-12-29 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Mark Rowe.
--- /dev/null
+Tests to make sure we can assign to non-ctm effected properties with a non-invertible ctm set
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS ctx.fillStyle is "green"
+PASS imageData.data[0] is 0
+PASS imageData.data[1] is 128
+PASS imageData.data[2] is 0
+PASS ctx.strokeStyle is "green"
+PASS imageData.data[0] is 0
+PASS imageData.data[1] is 128
+PASS imageData.data[2] is 0
+PASS imageData.data[0] is 0
+PASS imageData.data[1] is 128
+PASS imageData.data[2] is 0
+PASS imageData.data[0] is 0
+PASS imageData.data[1] is 128
+PASS imageData.data[2] is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/canvas-set-properties-with-non-invertible-ctm.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
--- /dev/null
+description("Tests to make sure we can assign to non-ctm effected properties with a non-invertible ctm set");
+var canvas = document.createElement("canvas");
+canvas.width = 100;
+canvas.height = 100;
+var ctx = canvas.getContext('2d');
+document.body.appendChild(canvas);
+
+function testPixel(x,y, r, g, b) {
+ imageData = ctx.getImageData(x, y, 1, 1);
+ shouldBe("imageData.data[0]", ""+r);
+ shouldBe("imageData.data[1]", ""+g);
+ shouldBe("imageData.data[2]", ""+b);
+}
+
+// Test our ability to set fillStyle
+ctx.save();
+ctx.scale(0, 0);
+ctx.fillStyle = "green";
+shouldBe('ctx.fillStyle', '"green"');
+ctx.setTransform(1, 0, 0, 1, 0, 0);
+ctx.fillRect(0,0,100,100);
+testPixel(50, 50, 0, 128, 0);
+ctx.restore();
+
+// Test our ability to set strokeStyle
+ctx.save();
+ctx.fillStyle = "red";
+ctx.fillRect(0,0,100,100);
+ctx.scale(0, 0);
+ctx.strokeStyle = "green";
+shouldBe('ctx.strokeStyle', '"green"');
+ctx.lineWidth = 100;
+ctx.setTransform(1, 0, 0, 1, 0, 0);
+ctx.strokeRect(0,0,100,100);
+testPixel(50, 50, 0, 128, 0);
+ctx.restore();
+
+
+// test closePath
+ctx.save();
+ctx.fillStyle = "red";
+ctx.fillRect(0,0,100,100);
+
+ctx.beginPath();
+ctx.strokeStyle = "green";
+ctx.lineWidth = 100;
+ctx.moveTo(-100, 50);
+ctx.lineTo(-100, -100);
+ctx.lineTo( 200, -100);
+ctx.lineTo( 200, 50);
+ctx.scale(0, 0);
+ctx.closePath();
+ctx.setTransform(1, 0, 0, 1, 0, 0);
+ctx.stroke();
+ctx.restore();
+testPixel(50, 50, 0, 128, 0);
+
+// Test beginPath behaviour
+ctx.fillStyle = "green";
+ctx.fillRect(0,0,100,100);
+ctx.fillStyle = "red";
+ctx.rect(0,0,100,100);
+ctx.scale(0,0);
+ctx.beginPath();
+ctx.setTransform(1, 0, 0, 1, 0, 0);
+ctx.fill();
+
+testPixel(50, 50, 0, 128, 0);
+
+successfullyParsed = true;
+2008-12-29 Oliver Hunt <oliver@apple.com>
+
+ Reviewed by Cameron Zwarich.
+
+ Bug 23030: Cannot setTransform with a non-invertible ctm
+
+ Removed a series of unnecessary and incorrect checks for an invertible
+ transform.
+
+ Test: fast/canvas/canvas-set-properties-with-non-invertible-ctm.html
+
+ * html/CanvasRenderingContext2D.cpp:
+ (WebCore::CanvasRenderingContext2D::setStrokeStyle):
+ (WebCore::CanvasRenderingContext2D::setFillStyle):
+ These properties are not effected by the current CTM, so there
+ is no need to prevent them from being assigned.
+
+ (WebCore::CanvasRenderingContext2D::setTransform):
+ The whole point of tracking whether the current CTM was expected to be
+ non-invertible was to allow setTransform to be used when the CTM had become
+ non-invertible.
+
+ (WebCore::CanvasRenderingContext2D::beginPath):
+ (WebCore::CanvasRenderingContext2D::closePath):
+ beginPath and closePath change the state of the path, but not any of
+ its coordinates so there is no need prevent them from being called.
+
2008-12-29 Josh Roesslein <jroesslein@gmail.com>
Reviewed by Oliver Hunt.
GraphicsContext* c = drawingContext();
if (!c)
return;
- if (!state().m_invertibleCTM)
- return;
state().m_strokeStyle->applyStrokeColor(c);
}
GraphicsContext* c = drawingContext();
if (!c)
return;
- if (!state().m_invertibleCTM)
- return;
state().m_fillStyle->applyFillColor(c);
}
GraphicsContext* c = drawingContext();
if (!c)
return;
- if (!state().m_invertibleCTM)
- return;
// HTML5 3.14.11.1 -- ignore any calls that pass non-finite numbers
if (!isfinite(m11) | !isfinite(m21) | !isfinite(dx) |
state().m_transform.multiply(ctm.inverse());
m_path.transform(ctm);
+ state().m_invertibleCTM = true;
transform(m11, m12, m21, m22, dx, dy);
}
void CanvasRenderingContext2D::beginPath()
{
- if (!state().m_invertibleCTM)
- return;
m_path.clear();
}
void CanvasRenderingContext2D::closePath()
{
- if (!state().m_invertibleCTM)
- return;
m_path.closeSubpath();
}