Skip to content
Permalink
Browse files
Implement DOMMatrix2DInit for setTransform()/addPath()
https://bugs.webkit.org/show_bug.cgi?id=176048

Patch by Sam Weinig <sam@webkit.org> on 2017-08-31
Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

* web-platform-tests/css/geometry-1/DOMMatrix-001.html:
* web-platform-tests/css/geometry-1/DOMMatrix-css-string.worker.js:
(string_appeared_here.forEach.constr.test):
* web-platform-tests/css/geometry-1/DOMMatrixInit-validate-fixup-expected.txt: Added.
* web-platform-tests/css/geometry-1/DOMMatrixInit-validate-fixup.html: Added.
* web-platform-tests/css/geometry-1/historical.html:
* web-platform-tests/css/geometry-1/interfaces-expected.txt: Added.
* web-platform-tests/css/geometry-1/interfaces.html: Added.
* web-platform-tests/css/geometry-1/interfaces.worker-expected.txt: Added.
* web-platform-tests/css/geometry-1/interfaces.worker.html: Added.
* web-platform-tests/css/geometry-1/interfaces.worker.js: Added.
* web-platform-tests/css/geometry-1/structured-serialization.html:
* web-platform-tests/css/geometry-1/w3c-import.log:

    Pull latest web-platform-tests/css/geometry-1/ and rebase the results.

Source/WebCore:

* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* CMakeLists.txt:

    Add new files.

* bindings/js/CallTracerTypes.h:
* inspector/InspectorCanvas.cpp:

    Swap out DOMMatrixInit for DOMMatrix2DInit in canvas tracing infrastructure.

* css/DOMMatrix2DInit.h: Added.
* css/DOMMatrix2DInit.idl: Added.
* css/DOMMatrixInit.h:
* css/DOMMatrixInit.idl:
Split DOMMatrixInit in two, with the 2D bits going into DOMMatrix2DInit.

* css/DOMMatrixReadOnly.cpp:
* css/DOMMatrixReadOnly.h:

    Add a validateAndFixup overload for DOMMatrix2DInit.

* html/canvas/CanvasRenderingContext2D.cpp:
* html/canvas/CanvasRenderingContext2D.h:

    Swap out DOMMatrixInit for DOMMatrix2DInit in setTransform. This
    should have no observable difference, since we ignored the 3D prior.

* html/canvas/DOMPath.cpp:
* html/canvas/DOMPath.h:
* html/canvas/DOMPath.idl:

    Update DOMPath (actually called Path2D) to take an optional DOMMatrix2DInit
    rather than an SVGMatrix. Passing an SVGMatrix is still valid, as it conforms
    as a DOMMatrix2DInit dictionary (having the necessary properties), so the
    risk of compatibility issues is minimal.

LayoutTests:

* fast/canvas/canvas-path-addPath-expected.txt:
* fast/canvas/canvas-path-addPath.html:
Update test / results now that the transform is for the path is an optional dictionary.
Mostly this means we throw a little less.

Canonical link: https://commits.webkit.org/192862@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221462 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Sam Weinig authored and webkit-commit-queue committed Sep 1, 2017
1 parent e164213 commit 9972650c04b40d6c2d753513e64eece56a0f1532
Showing 36 changed files with 1,698 additions and 91 deletions.
@@ -1,3 +1,15 @@
2017-08-31 Sam Weinig <sam@webkit.org>

Implement DOMMatrix2DInit for setTransform()/addPath()
https://bugs.webkit.org/show_bug.cgi?id=176048

Reviewed by Simon Fraser.

* fast/canvas/canvas-path-addPath-expected.txt:
* fast/canvas/canvas-path-addPath.html:
Update test / results now that the transform is for the path is an optional dictionary.
Mostly this means we throw a little less.

2017-08-31 Brady Eidson <beidson@apple.com>

Add (entirely incorrect) fetching of ServiceWorker scripts.
@@ -32,11 +32,8 @@ PASS refTest(result.data, expected.data) is true

Various tests of invalid values.
PASS pathA.addPath(matrix, pathB) threw exception TypeError: Argument 1 ('path') to Path2D.addPath must be an instance of DOMPath.
PASS pathA.addPath(pathB, ctx.canvas) threw exception TypeError: Argument 2 ('transform') to Path2D.addPath must be an instance of SVGMatrix.
PASS pathA.addPath(pathB, null) threw exception TypeError: Argument 2 ('transform') to Path2D.addPath must be an instance of SVGMatrix.
PASS pathA.addPath(pathB, undefined) threw exception TypeError: Argument 2 ('transform') to Path2D.addPath must be an instance of SVGMatrix.
PASS pathA.addPath(pathB, 0) threw exception TypeError: Argument 2 ('transform') to Path2D.addPath must be an instance of SVGMatrix.
PASS pathA.addPath(pathB, "0") threw exception TypeError: Argument 2 ('transform') to Path2D.addPath must be an instance of SVGMatrix.
PASS pathA.addPath(pathB, 0) threw exception TypeError: Type error.
PASS pathA.addPath(pathB, "0") threw exception TypeError: Type error.
PASS successfullyParsed is true

TEST COMPLETE
@@ -239,7 +239,6 @@
ctx.clearRect(0,0,300,150);
debug('');


debug('Various tests of invalid values.');
matrix.a = 1;
matrix.b = 0;
@@ -250,9 +249,6 @@
pathA = new Path2D();
pathB = new Path2D();
shouldThrow('pathA.addPath(matrix, pathB)');
shouldThrow('pathA.addPath(pathB, ctx.canvas)');
shouldThrow('pathA.addPath(pathB, null)');
shouldThrow('pathA.addPath(pathB, undefined)');
shouldThrow('pathA.addPath(pathB, 0)');
shouldThrow('pathA.addPath(pathB, "0")');

@@ -1,3 +1,26 @@
2017-08-31 Sam Weinig <sam@webkit.org>

Implement DOMMatrix2DInit for setTransform()/addPath()
https://bugs.webkit.org/show_bug.cgi?id=176048

Reviewed by Simon Fraser.

* web-platform-tests/css/geometry-1/DOMMatrix-001.html:
* web-platform-tests/css/geometry-1/DOMMatrix-css-string.worker.js:
(string_appeared_here.forEach.constr.test):
* web-platform-tests/css/geometry-1/DOMMatrixInit-validate-fixup-expected.txt: Added.
* web-platform-tests/css/geometry-1/DOMMatrixInit-validate-fixup.html: Added.
* web-platform-tests/css/geometry-1/historical.html:
* web-platform-tests/css/geometry-1/interfaces-expected.txt: Added.
* web-platform-tests/css/geometry-1/interfaces.html: Added.
* web-platform-tests/css/geometry-1/interfaces.worker-expected.txt: Added.
* web-platform-tests/css/geometry-1/interfaces.worker.html: Added.
* web-platform-tests/css/geometry-1/interfaces.worker.js: Added.
* web-platform-tests/css/geometry-1/structured-serialization.html:
* web-platform-tests/css/geometry-1/w3c-import.log:

Pull latest web-platform-tests/css/geometry-1/ and rebase the results.

2017-08-29 Youenn Fablet <youenn@apple.com>

[Fetch API] Request should throw when keep alive is true and body is a ReadableStream
@@ -16,10 +16,13 @@ PASS new DOMMatrix((float64Array) 6 elements
PASS new DOMMatrix(sequence) 16 elements
PASS new DOMMatrix(sequence) 6 elements
PASS new DOMMatrix("scale(2) translateX(5px) translateY(5px)")
FAIL new DOMMatrix("scale(2 2) translateX(5) translateY(5)") The string did not match the expected pattern.
FAIL new DOMMatrix("scale(2, 2), translateX(5) ,translateY(5)") The string did not match the expected pattern.
PASS new DOMMatrix("scale(2, 2) translateX(5px) translateY(5px)")
PASS new DOMMatrix("scale(2)translateX(5px)translateY(5px)")
PASS new DOMMatrix("scale(2) translateX(calc(2 * 2.5px)) translateY(5px)")
PASS new DOMMatrix("scale(2) translateX(5px) translateY(5px) rotate(5deg) rotate(-5deg)")
PASS new DOMMatrix("translateX (5px)")
FAIL new DOMMatrix("scale(2)translateX(5px)") assert_throws: function "function () { new self[constr](string); }" did not throw
PASS new DOMMatrix("scale(2 2) translateX(5) translateY(5)")
PASS new DOMMatrix("scale(2, 2), translateX(5) ,translateY(5)")
PASS new DOMMatrix("translateX(5em)")
PASS new DOMMatrix("translateX(5ex)")
PASS new DOMMatrix("translateX(5ch)")
@@ -29,6 +32,10 @@ FAIL new DOMMatrix("translateX(5vh)") assert_throws: function "function () { new
FAIL new DOMMatrix("translateX(5vmin)") assert_throws: function "function () { new self[constr](string); }" did not throw
FAIL new DOMMatrix("translateX(5vmax)") assert_throws: function "function () { new self[constr](string); }" did not throw
PASS new DOMMatrix("translateX(5%)")
PASS new DOMMatrix("rotate(5)")
PASS new DOMMatrix("rotate(5, 5, 5)")
PASS new DOMMatrix("rotate(5, 5px, 5px)")
PASS new DOMMatrix("rotate(5deg, 5px, 5px)")
PASS new DOMMatrix(" ")
PASS new DOMMatrix("/**/")
PASS new DOMMatrix("\0")
@@ -64,10 +71,13 @@ PASS new DOMMatrixReadOnly((float64Array) 6 elements
PASS new DOMMatrixReadOnly(sequence) 16 elements
PASS new DOMMatrixReadOnly(sequence) 6 elements
PASS new DOMMatrixReadOnly("scale(2) translateX(5px) translateY(5px)")
FAIL new DOMMatrixReadOnly("scale(2 2) translateX(5) translateY(5)") The string did not match the expected pattern.
FAIL new DOMMatrixReadOnly("scale(2, 2), translateX(5) ,translateY(5)") The string did not match the expected pattern.
PASS new DOMMatrixReadOnly("scale(2, 2) translateX(5px) translateY(5px)")
PASS new DOMMatrixReadOnly("scale(2)translateX(5px)translateY(5px)")
PASS new DOMMatrixReadOnly("scale(2) translateX(calc(2 * 2.5px)) translateY(5px)")
PASS new DOMMatrixReadOnly("scale(2) translateX(5px) translateY(5px) rotate(5deg) rotate(-5deg)")
PASS new DOMMatrixReadOnly("translateX (5px)")
FAIL new DOMMatrixReadOnly("scale(2)translateX(5px)") assert_throws: function "function () { new self[constr](string); }" did not throw
PASS new DOMMatrixReadOnly("scale(2 2) translateX(5) translateY(5)")
PASS new DOMMatrixReadOnly("scale(2, 2), translateX(5) ,translateY(5)")
PASS new DOMMatrixReadOnly("translateX(5em)")
PASS new DOMMatrixReadOnly("translateX(5ex)")
PASS new DOMMatrixReadOnly("translateX(5ch)")
@@ -77,6 +87,10 @@ FAIL new DOMMatrixReadOnly("translateX(5vh)") assert_throws: function "function
FAIL new DOMMatrixReadOnly("translateX(5vmin)") assert_throws: function "function () { new self[constr](string); }" did not throw
FAIL new DOMMatrixReadOnly("translateX(5vmax)") assert_throws: function "function () { new self[constr](string); }" did not throw
PASS new DOMMatrixReadOnly("translateX(5%)")
PASS new DOMMatrixReadOnly("rotate(5)")
PASS new DOMMatrixReadOnly("rotate(5, 5, 5)")
PASS new DOMMatrixReadOnly("rotate(5, 5px, 5px)")
PASS new DOMMatrixReadOnly("rotate(5deg, 5px, 5px)")
PASS new DOMMatrixReadOnly(" ")
PASS new DOMMatrixReadOnly("/**/")
PASS new DOMMatrixReadOnly("\0")
@@ -97,16 +97,19 @@
});

['scale(2) translateX(5px) translateY(5px)',
'scale(2 2) translateX(5) translateY(5)',
'scale(2, 2), translateX(5) ,translateY(5)',
'scale(2, 2) translateX(5px) translateY(5px)',
'scale(2)translateX(5px)translateY(5px)',
'scale(2) translateX(calc(2 * 2.5px)) translateY(5px)',
'scale(2) translateX(5px) translateY(5px) rotate(5deg) rotate(-5deg)',
].forEach(function(string) {
test(function() {
checkDOMMatrix(new self[constr](string), scaleTranslate2D);
}, `new ${constr}(${format_value(string)})`);
});

['translateX (5px)',
'scale(2)translateX(5px)',
'scale(2 2) translateX(5) translateY(5)',
'scale(2, 2), translateX(5) ,translateY(5)',
'translateX(5em)',
'translateX(5ex)',
'translateX(5ch)',
@@ -116,6 +119,10 @@
'translateX(5vmin)',
'translateX(5vmax)',
'translateX(5%)',
'rotate(5)',
'rotate(5, 5, 5)',
'rotate(5, 5px, 5px)',
'rotate(5deg, 5px, 5px)',
' ',
'/**/',
'\0',
@@ -1,9 +1,11 @@

FAIL DOMMatrix constructor with string argument in worker assert_true: DOMMatrix should exist expected true got false
FAIL DOMMatrix constructor with empty string argument in worker assert_true: DOMMatrix should exist expected true got false
FAIL DOMMatrix stringifier in worker (2d identity) undefined is not a constructor (evaluating 'new self[constr]()')
FAIL DOMMatrix stringifier in worker (3d identity) undefined is not an object (evaluating 'self[constr].fromMatrix')
FAIL DOMMatrix stringifier in worker (non-finite values) undefined is not a constructor (evaluating 'new self[constr]([1, 0, 0, NaN, Infinity, -Infinity])')
FAIL DOMMatrixReadOnly constructor with string argument in worker assert_true: DOMMatrixReadOnly should exist expected true got false
FAIL DOMMatrixReadOnly constructor with empty string argument in worker assert_true: DOMMatrixReadOnly should exist expected true got false
FAIL DOMMatrixReadOnly stringifier in worker (2d identity) undefined is not a constructor (evaluating 'new self[constr]()')
FAIL DOMMatrixReadOnly stringifier in worker (3d identity) undefined is not an object (evaluating 'self[constr].fromMatrix')
FAIL DOMMatrixReadOnly stringifier in worker (non-finite values) undefined is not a constructor (evaluating 'new self[constr]([1, 0, 0, NaN, Infinity, -Infinity])')
@@ -8,6 +8,11 @@ importScripts("/resources/testharness.js");
assert_throws(new TypeError(), () => new self[constr]('matrix(1,0,0,1,0,0)') );
}, `${constr} constructor with string argument in worker`);

test(() => {
assert_true(constr in self, `${constr} should exist`);
assert_throws(new TypeError(), () => new self[constr]('') );
}, `${constr} constructor with empty string argument in worker`);

test(() => {
const matrix = new self[constr]();
assert_equals(String(matrix), `[object ${constr}]`);
@@ -0,0 +1,93 @@

PASS {a: 1, m11: 2} (invalid)
PASS {b: 0, m12: -1} (invalid)
PASS {c: Infinity, m21: -Infinity} (invalid)
PASS {d: 0, m22: NaN} (invalid)
PASS {e: 1, m41: 1.00000001} (invalid)
PASS {f: 0, m42: 5e-324} (invalid)
PASS {m13: 1, is2D: true} (invalid)
PASS {m14: 1, is2D: true} (invalid)
PASS {m23: 1, is2D: true} (invalid)
PASS {m24: 1, is2D: true} (invalid)
PASS {m31: 1, is2D: true} (invalid)
PASS {m32: 1, is2D: true} (invalid)
PASS {m33: 0, is2D: true} (invalid)
PASS {m33: -0, is2D: true} (invalid)
PASS {m33: -1, is2D: true} (invalid)
PASS {m34: 1, is2D: true} (invalid)
PASS {m43: 1, is2D: true} (invalid)
PASS {m44: 0, is2D: true} (invalid)
PASS {} (2d)
PASS {is2D: undefined} (2d)
PASS {a: 1, m11: 1} (2d)
PASS {b: 0, m12: undefined} (2d)
PASS {c: 0, m21: 0} (2d)
PASS {c: 0, m21: -0} (2d)
PASS {c: -0, m21: 0} (2d)
PASS {c: -0, m21: -0} (2d)
PASS {d: Infinity, m22: Infinity} (2d)
PASS {e: -Infinity, m41: -Infinity} (2d)
FAIL {f: NaN, m42: NaN} (2d) init.f and init.m42 do not match
FAIL {f: NaN, m42: NaN, is2D: true} (2d) init.f and init.m42 do not match
PASS {f: 0, m42: null} (2d)
PASS {f: -0, m42: null} (2d)
PASS {a: 2} (2d)
PASS {b: 2} (2d)
PASS {c: 2} (2d)
PASS {d: 2} (2d)
PASS {e: 2} (2d)
PASS {f: 2} (2d)
PASS {a: -0, b: -0, c: -0, d: -0, e: -0, f: -0} (2d)
PASS {a: -0, b: -0, c: -0, d: -0, e: -0, f: -0, is2D: true} (2d)
PASS {m11: 2} (2d)
PASS {m12: 2} (2d)
PASS {m21: 2} (2d)
PASS {m22: 2} (2d)
PASS {m41: 2} (2d)
PASS {m42: 2} (2d)
PASS {m11: -0, m12: -0, m21: -0, m22: -0, m41: -0, m42: -0} (2d)
PASS {m11: -0, m12: -0, m21: -0, m22: -0, m41: -0, m42: -0, is2D: true} (2d)
PASS {m13: 0, is2D: true} (2d)
PASS {m13: -0, is2D: true} (2d)
PASS {m14: 0, is2D: true} (2d)
PASS {m14: -0, is2D: true} (2d)
PASS {m23: 0, is2D: true} (2d)
PASS {m23: -0, is2D: true} (2d)
PASS {m24: 0, is2D: true} (2d)
PASS {m24: -0, is2D: true} (2d)
PASS {m31: 0, is2D: true} (2d)
PASS {m31: -0, is2D: true} (2d)
PASS {m32: 0, is2D: true} (2d)
PASS {m32: -0, is2D: true} (2d)
PASS {m33: 1, is2D: true} (2d)
PASS {m34: 0, is2D: true} (2d)
PASS {m34: -0, is2D: true} (2d)
PASS {m43: 0, is2D: true} (2d)
PASS {m43: -0, is2D: true} (2d)
PASS {m44: 1, is2D: true} (2d)
PASS {is2D: true} (2d)
PASS {m13: 1, is2D: false} (3d)
PASS {m14: 1, is2D: false} (3d)
PASS {m23: 1, is2D: false} (3d)
PASS {m24: 1, is2D: false} (3d)
PASS {m31: 1, is2D: false} (3d)
PASS {m32: 1, is2D: false} (3d)
PASS {m33: 0, is2D: false} (3d)
PASS {m33: -0, is2D: false} (3d)
PASS {m33: -1, is2D: false} (3d)
PASS {m34: 1, is2D: false} (3d)
PASS {m43: 1, is2D: false} (3d)
PASS {m44: 0, is2D: false} (3d)
PASS {m13: 1} (3d)
PASS {m14: 1} (3d)
PASS {m23: 1} (3d)
PASS {m24: 1} (3d)
PASS {m31: 1} (3d)
PASS {m32: 1} (3d)
PASS {m33: 0} (3d)
PASS {m34: 1} (3d)
PASS {m43: 1} (3d)
PASS {m44: 0} (3d)
PASS {is2D: false} (3d)
PASS {is2D: null} (3d)

0 comments on commit 9972650

Please sign in to comment.