Diff
Modified: trunk/LayoutTests/ChangeLog (204877 => 204878)
--- trunk/LayoutTests/ChangeLog 2016-08-24 02:03:43 UTC (rev 204877)
+++ trunk/LayoutTests/ChangeLog 2016-08-24 02:13:09 UTC (rev 204878)
@@ -1,3 +1,19 @@
+2016-08-23 Chris Dumez <[email protected]>
+
+ Add support for CanvasRenderingContext2D.resetTransform()
+ https://bugs.webkit.org/show_bug.cgi?id=161089
+
+ Reviewed by Simon Fraser.
+
+ Import corresponding Blink test.
+
+ * imported/blink/fast/canvas/canvas-resetTransform-expected.txt: Added.
+ * imported/blink/fast/canvas/canvas-resetTransform.html: Added.
+ * imported/blink/fast/canvas/script-tests/canvas-resetTransform.js: Added.
+
+ * platform/ios-simulator/TestExpectations:
+ Skip new Canvas test on iOS as it is failing (very small visual difference).
+
2016-08-23 Simon Fraser <[email protected]>
Hook up UIScriptController in DumpRenderTree
Added: trunk/LayoutTests/imported/blink/fast/canvas/canvas-resetTransform-expected.txt (0 => 204878)
--- trunk/LayoutTests/imported/blink/fast/canvas/canvas-resetTransform-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/blink/fast/canvas/canvas-resetTransform-expected.txt 2016-08-24 02:13:09 UTC (rev 204878)
@@ -0,0 +1,36 @@
+This test checks resetTransform in canvas v5
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+resetTransform should reset other transforms.
+PASS imgdata[0] is 0
+PASS imgdata[1] is 128
+PASS imgdata[2] is 0
+resetTransform should not affect CTM outside of save() and restore().
+PASS imgdata[0] is 0
+PASS imgdata[1] is 128
+PASS imgdata[2] is 0
+PASS imgdata[0] is 255
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+resetTransform should restore the path transform to identity.
+PASS imgdata[0] is 0
+PASS imgdata[1] is 128
+PASS imgdata[2] is 0
+resetTransform should resolve the non-invertible CTM state.
+PASS imgdata[0] is 0
+PASS imgdata[1] is 128
+PASS imgdata[2] is 0
+The path object should not be updated on the non-invertible CTM state.
+resetTransform should restore the path object just before CTM became non-invertible.
+PASS imgdata[0] is 255
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+PASS imgdata[0] is 0
+PASS imgdata[1] is 128
+PASS imgdata[2] is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/imported/blink/fast/canvas/canvas-resetTransform.html (0 => 204878)
--- trunk/LayoutTests/imported/blink/fast/canvas/canvas-resetTransform.html (rev 0)
+++ trunk/LayoutTests/imported/blink/fast/canvas/canvas-resetTransform.html 2016-08-24 02:13:09 UTC (rev 204878)
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/imported/blink/fast/canvas/script-tests/canvas-resetTransform.js (0 => 204878)
--- trunk/LayoutTests/imported/blink/fast/canvas/script-tests/canvas-resetTransform.js (rev 0)
+++ trunk/LayoutTests/imported/blink/fast/canvas/script-tests/canvas-resetTransform.js 2016-08-24 02:13:09 UTC (rev 204878)
@@ -0,0 +1,117 @@
+description("This test checks resetTransform in canvas v5");
+
+var canvas = document.createElement('canvas');
+document.body.appendChild(canvas);
+canvas.setAttribute('width', '100');
+canvas.setAttribute('height', '100');
+var ctx = canvas.getContext('2d');
+
+debug("resetTransform should reset other transforms.");
+ctx.save();
+ctx.scale(0.5, 0.5);
+ctx.resetTransform();
+ctx.fillStyle = 'green';
+ctx.fillRect(0, 0, 100, 100);
+ctx.restore();
+
+var imageData = ctx.getImageData(98, 98, 1, 1);
+var imgdata = imageData.data;
+shouldBe("imgdata[0]", "0");
+shouldBe("imgdata[1]", "128");
+shouldBe("imgdata[2]", "0");
+
+debug("resetTransform should not affect CTM outside of save() and restore().");
+ctx.save();
+ctx.scale(0.5, 0.5);
+ctx.save();
+ctx.resetTransform();
+ctx.fillStyle = 'green';
+ctx.fillRect(0, 0, 100, 100);
+ctx.restore();
+ctx.fillStyle = 'red';
+ctx.fillRect(0, 0, 100, 100);
+ctx.restore();
+
+imageData = ctx.getImageData(98, 98, 1, 1);
+imgdata = imageData.data;
+shouldBe("imgdata[0]", "0");
+shouldBe("imgdata[1]", "128");
+shouldBe("imgdata[2]", "0");
+
+imageData = ctx.getImageData(48, 48, 1, 1);
+imgdata = imageData.data;
+shouldBe("imgdata[0]", "255");
+shouldBe("imgdata[1]", "0");
+shouldBe("imgdata[2]", "0");
+
+debug("resetTransform should restore the path transform to identity.");
+/* This should draw a green rectangle on on top of a red one. The red should not be visible. */
+ctx.save();
+ctx.beginPath();
+ctx.moveTo(0, 0);
+ctx.lineTo(100, 0);
+ctx.lineTo(100, 100);
+ctx.lineTo(0, 100);
+ctx.fillStyle = 'red';
+ctx.fill();
+ctx.translate(200, 0);
+ctx.resetTransform();
+ctx.fillStyle = 'green';
+ctx.fill();
+ctx.restore();
+
+imageData = ctx.getImageData(50, 50, 1, 1);
+imgdata = imageData.data;
+shouldBe("imgdata[0]", "0");
+shouldBe("imgdata[1]", "128");
+shouldBe("imgdata[2]", "0");
+
+debug("resetTransform should resolve the non-invertible CTM state.");
+ctx.save();
+ctx.fillStyle = 'red';
+ctx.fillRect(0, 0, 100, 100);
+ctx.beginPath();
+ctx.moveTo(0, 0);
+ctx.lineTo(100, 0);
+ctx.lineTo(100, 100);
+ctx.lineTo(0, 100);
+ctx.scale(0, 0);
+ctx.resetTransform();
+ctx.fillStyle = 'green';
+ctx.fill();
+ctx.restore();
+
+imageData = ctx.getImageData(98, 98, 1, 1);
+imgdata = imageData.data;
+shouldBe("imgdata[0]", "0");
+shouldBe("imgdata[1]", "128");
+shouldBe("imgdata[2]", "0");
+
+debug("The path object should not be updated on the non-invertible CTM state.");
+debug("resetTransform should restore the path object just before CTM became non-invertible.");
+ctx.save();
+ctx.fillStyle = 'red';
+ctx.fillRect(0, 0, 100, 100);
+ctx.beginPath();
+ctx.moveTo(0, 0);
+ctx.lineTo(100, 0);
+ctx.lineTo(100, 50);
+ctx.scale(0, 0);
+ctx.lineTo(100, 100);
+ctx.resetTransform();
+ctx.lineTo(0, 100);
+ctx.fillStyle = 'green';
+ctx.fill();
+ctx.restore();
+
+imageData = ctx.getImageData(98, 98, 1, 1);
+imgdata = imageData.data;
+shouldBe("imgdata[0]", "255");
+shouldBe("imgdata[1]", "0");
+shouldBe("imgdata[2]", "0");
+
+imageData = ctx.getImageData(98, 48, 1, 1);
+imgdata = imageData.data;
+shouldBe("imgdata[0]", "0");
+shouldBe("imgdata[1]", "128");
+shouldBe("imgdata[2]", "0");
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (204877 => 204878)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2016-08-24 02:03:43 UTC (rev 204877)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2016-08-24 02:13:09 UTC (rev 204878)
@@ -1,5 +1,19 @@
2016-08-23 Chris Dumez <[email protected]>
+ Add support for CanvasRenderingContext2D.resetTransform()
+ https://bugs.webkit.org/show_bug.cgi?id=161089
+
+ Reviewed by Simon Fraser.
+
+ * web-platform-tests/2dcontext/transformations/canvas_transformations_reset_001-expected.html: Added.
+ * web-platform-tests/2dcontext/transformations/canvas_transformations_reset_001.html: Added.
+ Import W3C test to cover CanvasRenderingContext2D.resetTransform().
+
+ * web-platform-tests/html/dom/interfaces-expected.txt:
+ Rebaseline existing test now that more checks are passing.
+
+2016-08-23 Chris Dumez <[email protected]>
+
HTMLAreaElement should have a stringifier
https://bugs.webkit.org/show_bug.cgi?id=161105
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/2dcontext/transformations/canvas_transformations_reset_001-expected.html (0 => 204878)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/2dcontext/transformations/canvas_transformations_reset_001-expected.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/2dcontext/transformations/canvas_transformations_reset_001-expected.html 2016-08-24 02:13:09 UTC (rev 204878)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<body>
+<style>
+ html, body, div {
+ margin: 0;
+ padding: 0;
+ }
+ div {
+ width: 75px;
+ height: 75px;
+ float: left;
+ }
+</style>
+
+<div style="background-color:red"></div>
+<div style="clear:left"></div>
+<div style="background-color:blue"></div>
+
+</body>
+</html>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/2dcontext/transformations/canvas_transformations_reset_001.html (0 => 204878)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/2dcontext/transformations/canvas_transformations_reset_001.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/2dcontext/transformations/canvas_transformations_reset_001.html 2016-08-24 02:13:09 UTC (rev 204878)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<link rel="match" href=""
+<style>
+ html, body {
+ margin: 0;
+ padding: 0;
+ }
+</style>
+<canvas id="c" width="150" height="150"></canvas>
+<script>
+var c = document.getElementById("c");
+var ctx = c.getContext("2d");
+
+ctx.translate(75, 75);
+ctx.fillStyle = 'blue';
+ctx.fillRect(0, 0, 75, 75);
+
+ctx.resetTransform();
+ctx.fillStyle = 'red';
+ctx.fillRect(0, 0, 75, 75);
+</script>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt (204877 => 204878)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt 2016-08-24 02:03:43 UTC (rev 204877)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt 2016-08-24 02:13:09 UTC (rev 204878)
@@ -4802,7 +4802,7 @@
FAIL CanvasRenderingContext2D interface: operation getTransform() assert_own_property: interface prototype object missing non-static operation expected property "getTransform" missing
FAIL CanvasRenderingContext2D interface: operation setTransform(unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double) assert_equals: property has wrong .length expected 0 but got 6
FAIL CanvasRenderingContext2D interface: operation setTransform(DOMMatrixInit) assert_equals: property has wrong .length expected 0 but got 6
-FAIL CanvasRenderingContext2D interface: operation resetTransform() assert_own_property: interface prototype object missing non-static operation expected property "resetTransform" missing
+PASS CanvasRenderingContext2D interface: operation resetTransform()
PASS CanvasRenderingContext2D interface: attribute globalAlpha
PASS CanvasRenderingContext2D interface: attribute globalCompositeOperation
PASS CanvasRenderingContext2D interface: attribute imageSmoothingEnabled
@@ -4889,7 +4889,7 @@
PASS CanvasRenderingContext2D interface: calling setTransform(unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double) on document.createElement("canvas").getContext("2d") with too few arguments must throw TypeError
PASS CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "setTransform" with the proper type (9)
PASS CanvasRenderingContext2D interface: calling setTransform(DOMMatrixInit) on document.createElement("canvas").getContext("2d") with too few arguments must throw TypeError
-FAIL CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "resetTransform" with the proper type (10) assert_inherits: property "resetTransform" not found in prototype chain
+PASS CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "resetTransform" with the proper type (10)
PASS CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "globalAlpha" with the proper type (11)
PASS CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "globalCompositeOperation" with the proper type (12)
PASS CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "imageSmoothingEnabled" with the proper type (13)
Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (204877 => 204878)
--- trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-08-24 02:03:43 UTC (rev 204877)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-08-24 02:13:09 UTC (rev 204878)
@@ -383,6 +383,7 @@
webkit.org/b/137530 canvas/philip/tests/2d.text.draw.space.collapse.space.html [ Failure ]
webkit.org/b/137530 canvas/philip/tests/2d.text.draw.space.collapse.start.html [ Failure ]
webkit.org/b/137530 canvas/philip/tests/2d.text.measure.width.space.html [ Failure ]
+webkit.org/b/137530 imported/w3c/web-platform-tests/2dcontext/transformations/canvas_transformations_reset_001.html [ ImageOnlyFailure ]
# Canvas tests that have stderr:
canvas/philip/tests/2d.canvas.readonly.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (204877 => 204878)
--- trunk/Source/WebCore/ChangeLog 2016-08-24 02:03:43 UTC (rev 204877)
+++ trunk/Source/WebCore/ChangeLog 2016-08-24 02:13:09 UTC (rev 204878)
@@ -1,3 +1,25 @@
+2016-08-23 Chris Dumez <[email protected]>
+
+ Add support for CanvasRenderingContext2D.resetTransform()
+ https://bugs.webkit.org/show_bug.cgi?id=161089
+
+ Reviewed by Simon Fraser.
+
+ Add support for CanvasRenderingContext2D.resetTransform():
+ - https://html.spec.whatwg.org/#dom-context-2d-resettransform
+
+ Firefox and Chrome already support this.
+
+ Tests:
+ imported/blink/fast/canvas/canvas-resetTransform.html
+ imported/w3c/web-platform-tests/2dcontext/transformations/canvas_transformations_reset_001.html
+
+ * html/canvas/CanvasRenderingContext2D.cpp:
+ (WebCore::CanvasRenderingContext2D::setTransform):
+ (WebCore::CanvasRenderingContext2D::resetTransform):
+ * html/canvas/CanvasRenderingContext2D.h:
+ * html/canvas/CanvasRenderingContext2D.idl:
+
2016-08-23 Said Abou-Hallawa <[email protected]>
REGRESSION: SVG clip-path doesn't work on root <svg>
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (204877 => 204878)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2016-08-24 02:03:43 UTC (rev 204877)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2016-08-24 02:13:09 UTC (rev 204878)
@@ -807,18 +807,28 @@
if (!std::isfinite(m11) | !std::isfinite(m21) | !std::isfinite(dx) | !std::isfinite(m12) | !std::isfinite(m22) | !std::isfinite(dy))
return;
- AffineTransform ctm = state().transform;
- if (!ctm.isInvertible())
+ resetTransform();
+ transform(m11, m12, m21, m22, dx, dy);
+}
+
+void CanvasRenderingContext2D::resetTransform()
+{
+ GraphicsContext* c = drawingContext();
+ if (!c)
return;
+ AffineTransform ctm = state().transform;
+ bool hasInvertibleTransform = state().hasInvertibleTransform;
+
realizeSaves();
-
+
c->setCTM(canvas()->baseTransform());
modifiableState().transform = AffineTransform();
- m_path.transform(ctm);
+ if (hasInvertibleTransform)
+ m_path.transform(ctm);
+
modifiableState().hasInvertibleTransform = true;
- transform(m11, m12, m21, m22, dx, dy);
}
void CanvasRenderingContext2D::setStrokeColor(const String& color, Optional<float> alpha)
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (204877 => 204878)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h 2016-08-24 02:03:43 UTC (rev 204877)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h 2016-08-24 02:13:09 UTC (rev 204878)
@@ -117,6 +117,7 @@
void translate(float tx, float ty);
void transform(float m11, float m12, float m21, float m22, float dx, float dy);
void setTransform(float m11, float m12, float m21, float m22, float dx, float dy);
+ void resetTransform();
void setStrokeColor(const String& color, Optional<float> alpha = Nullopt);
void setStrokeColor(float grayLevel, float alpha = 1.0);
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl (204877 => 204878)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl 2016-08-24 02:03:43 UTC (rev 204877)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl 2016-08-24 02:13:09 UTC (rev 204878)
@@ -47,6 +47,7 @@
unrestricted float dx, unrestricted float dy);
void setTransform(unrestricted float m11, unrestricted float m12, unrestricted float m21, unrestricted float m22,
unrestricted float dx, unrestricted float dy);
+ void resetTransform();
attribute unrestricted float globalAlpha;