Skip to content

Commit

Permalink
Add scaleNonUniform in DOMMatrixReadOnly
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=263748
rdar://problem/117875678

Reviewed by Matt Woodrow.

This patch is to align WebKit with Blink / Chromium, Gecko / Firefox and Web-Specification [1]
by adding 'scaleNonUniform' support:

[1] https://drafts.fxtf.org/geometry/#dommatrixreadonly

* Source/WebCore/css/DOMMatrixReadOnly.cpp:
(DOMMatrixReadOnly::scaleNonUniform):
* Source/WebCore/css/DOMMatrixReadOnly.h:
* Source/WebCore/css/DOMMatrixReadOnly.idl:
* LayoutTests/imported/w3c/web-platform-tests/css/geometry/DOMMatrix-002-expected.txt: Rebaselined
* LayoutTests/imported/w3c/web-platform-tests/css/geometry/DOMMatrix-003-expected.txt: Rebaselined
* LayoutTests/imported/w3c/web-platform-tests/css/geometry/idlharness-expected.txt: Rebaselined
* LayoutTests/imported/w3c/web-platform-tests/css/geometry/idlharness.worker-expected.txt: Rebaselined

Canonical link: https://commits.webkit.org/271030@main
  • Loading branch information
Ahmad-S792 authored and Ahmad Saleem committed Nov 22, 2023
1 parent a64ff93 commit d0f9805
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Test DOMMatrixReadOnly methods do not mutate the object

PASS test translate() doesn't mutate
PASS test scale() doesn't mutate
FAIL test scaleNonUniform() doesn't mutate matrix.scaleNonUniform is not a function. (In 'matrix.scaleNonUniform(1,5)', 'matrix.scaleNonUniform' is undefined)
PASS test scaleNonUniform() doesn't mutate
PASS test scale3d() doesn't mutate
PASS test rotate() doesn't mutate
PASS test rotateFromVector() doesn't mutate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ PASS test translate()
PASS test scale() without offsets
PASS test scale() with offsets
PASS test scale() with identity scale and nonzero originZ
FAIL test scaleNonUniform() initialDOMMatrix().scaleNonUniform is not a function. (In 'initialDOMMatrix().scaleNonUniform()', 'initialDOMMatrix().scaleNonUniform' is undefined)
FAIL test scaleNonUniform() with sx initialDOMMatrix().scaleNonUniform is not a function. (In 'initialDOMMatrix().scaleNonUniform(6)', 'initialDOMMatrix().scaleNonUniform' is undefined)
FAIL test scaleNonUniform() with sx, sy initialDOMMatrix().scaleNonUniform is not a function. (In 'initialDOMMatrix().scaleNonUniform(5, 7)', 'initialDOMMatrix().scaleNonUniform' is undefined)
PASS test scaleNonUniform()
PASS test scaleNonUniform() with sx
PASS test scaleNonUniform() with sx, sy
PASS test scale3d()
PASS test rotate() 2d
PASS test rotate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ PASS DOMMatrixReadOnly interface: attribute is2D
PASS DOMMatrixReadOnly interface: attribute isIdentity
PASS DOMMatrixReadOnly interface: operation translate(optional unrestricted double, optional unrestricted double, optional unrestricted double)
PASS DOMMatrixReadOnly interface: operation scale(optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double)
FAIL DOMMatrixReadOnly interface: operation scaleNonUniform(optional unrestricted double, optional unrestricted double) assert_own_property: interface prototype object missing non-static operation expected property "scaleNonUniform" missing
PASS DOMMatrixReadOnly interface: operation scaleNonUniform(optional unrestricted double, optional unrestricted double)
PASS DOMMatrixReadOnly interface: operation scale3d(optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double)
PASS DOMMatrixReadOnly interface: operation rotate(optional unrestricted double, optional unrestricted double, optional unrestricted double)
PASS DOMMatrixReadOnly interface: operation rotateFromVector(optional unrestricted double, optional unrestricted double)
Expand Down Expand Up @@ -252,8 +252,8 @@ PASS DOMMatrixReadOnly interface: new DOMMatrixReadOnly() must inherit property
PASS DOMMatrixReadOnly interface: calling translate(optional unrestricted double, optional unrestricted double, optional unrestricted double) on new DOMMatrixReadOnly() with too few arguments must throw TypeError
PASS DOMMatrixReadOnly interface: new DOMMatrixReadOnly() must inherit property "scale(optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double)" with the proper type
PASS DOMMatrixReadOnly interface: calling scale(optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double) on new DOMMatrixReadOnly() with too few arguments must throw TypeError
FAIL DOMMatrixReadOnly interface: new DOMMatrixReadOnly() must inherit property "scaleNonUniform(optional unrestricted double, optional unrestricted double)" with the proper type assert_inherits: property "scaleNonUniform" not found in prototype chain
FAIL DOMMatrixReadOnly interface: calling scaleNonUniform(optional unrestricted double, optional unrestricted double) on new DOMMatrixReadOnly() with too few arguments must throw TypeError assert_inherits: property "scaleNonUniform" not found in prototype chain
PASS DOMMatrixReadOnly interface: new DOMMatrixReadOnly() must inherit property "scaleNonUniform(optional unrestricted double, optional unrestricted double)" with the proper type
PASS DOMMatrixReadOnly interface: calling scaleNonUniform(optional unrestricted double, optional unrestricted double) on new DOMMatrixReadOnly() with too few arguments must throw TypeError
PASS DOMMatrixReadOnly interface: new DOMMatrixReadOnly() must inherit property "scale3d(optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double)" with the proper type
PASS DOMMatrixReadOnly interface: calling scale3d(optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double) on new DOMMatrixReadOnly() with too few arguments must throw TypeError
PASS DOMMatrixReadOnly interface: new DOMMatrixReadOnly() must inherit property "rotate(optional unrestricted double, optional unrestricted double, optional unrestricted double)" with the proper type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ PASS DOMMatrixReadOnly interface: attribute is2D
PASS DOMMatrixReadOnly interface: attribute isIdentity
PASS DOMMatrixReadOnly interface: operation translate(optional unrestricted double, optional unrestricted double, optional unrestricted double)
PASS DOMMatrixReadOnly interface: operation scale(optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double)
FAIL DOMMatrixReadOnly interface: operation scaleNonUniform(optional unrestricted double, optional unrestricted double) assert_own_property: interface prototype object missing non-static operation expected property "scaleNonUniform" missing
PASS DOMMatrixReadOnly interface: operation scaleNonUniform(optional unrestricted double, optional unrestricted double)
PASS DOMMatrixReadOnly interface: operation scale3d(optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double)
PASS DOMMatrixReadOnly interface: operation rotate(optional unrestricted double, optional unrestricted double, optional unrestricted double)
PASS DOMMatrixReadOnly interface: operation rotateFromVector(optional unrestricted double, optional unrestricted double)
Expand Down Expand Up @@ -232,8 +232,8 @@ PASS DOMMatrixReadOnly interface: new DOMMatrixReadOnly() must inherit property
PASS DOMMatrixReadOnly interface: calling translate(optional unrestricted double, optional unrestricted double, optional unrestricted double) on new DOMMatrixReadOnly() with too few arguments must throw TypeError
PASS DOMMatrixReadOnly interface: new DOMMatrixReadOnly() must inherit property "scale(optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double)" with the proper type
PASS DOMMatrixReadOnly interface: calling scale(optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double) on new DOMMatrixReadOnly() with too few arguments must throw TypeError
FAIL DOMMatrixReadOnly interface: new DOMMatrixReadOnly() must inherit property "scaleNonUniform(optional unrestricted double, optional unrestricted double)" with the proper type assert_inherits: property "scaleNonUniform" not found in prototype chain
FAIL DOMMatrixReadOnly interface: calling scaleNonUniform(optional unrestricted double, optional unrestricted double) on new DOMMatrixReadOnly() with too few arguments must throw TypeError assert_inherits: property "scaleNonUniform" not found in prototype chain
PASS DOMMatrixReadOnly interface: new DOMMatrixReadOnly() must inherit property "scaleNonUniform(optional unrestricted double, optional unrestricted double)" with the proper type
PASS DOMMatrixReadOnly interface: calling scaleNonUniform(optional unrestricted double, optional unrestricted double) on new DOMMatrixReadOnly() with too few arguments must throw TypeError
PASS DOMMatrixReadOnly interface: new DOMMatrixReadOnly() must inherit property "scale3d(optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double)" with the proper type
PASS DOMMatrixReadOnly interface: calling scale3d(optional unrestricted double, optional unrestricted double, optional unrestricted double, optional unrestricted double) on new DOMMatrixReadOnly() with too few arguments must throw TypeError
PASS DOMMatrixReadOnly interface: new DOMMatrixReadOnly() must inherit property "rotate(optional unrestricted double, optional unrestricted double, optional unrestricted double)" with the proper type
Expand Down
6 changes: 6 additions & 0 deletions Source/WebCore/css/DOMMatrixReadOnly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ Ref<DOMMatrix> DOMMatrixReadOnly::scale3d(double scale, double originX, double o
return matrix->scale3dSelf(scale, originX, originY, originZ);
}

Ref<DOMMatrix> DOMMatrixReadOnly::scaleNonUniform(double scaleX, double scaleY)
{
auto matrix = cloneAsDOMMatrix();
return matrix->scaleSelf(scaleX, scaleY, 1, 0, 0, 0);
}

Ref<DOMMatrix> DOMMatrixReadOnly::rotate(double rotX, std::optional<double> rotY, std::optional<double> rotZ)
{
auto matrix = cloneAsDOMMatrix();
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/css/DOMMatrixReadOnly.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class DOMMatrixReadOnly : public ScriptWrappable, public RefCounted<DOMMatrixRea
Ref<DOMMatrix> flipY();
Ref<DOMMatrix> scale(double scaleX = 1, std::optional<double> scaleY = std::nullopt, double scaleZ = 1, double originX = 0, double originY = 0, double originZ = 0);
Ref<DOMMatrix> scale3d(double scale = 1, double originX = 0, double originY = 0, double originZ = 0);
Ref<DOMMatrix> scaleNonUniform(double scaleX = 1, double scaleY = 1);
Ref<DOMMatrix> rotate(double rotX = 0, std::optional<double> rotY = std::nullopt, std::optional<double> rotZ = std::nullopt); // Angles are in degrees.
Ref<DOMMatrix> rotateFromVector(double x = 0, double y = 0);
Ref<DOMMatrix> rotateAxisAngle(double x = 0, double y = 0, double z = 0, double angle = 0); // Angle is in degrees.
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/css/DOMMatrixReadOnly.idl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/

// https://drafts.fxtf.org/geometry/#dommatrixreadonly

[
ExportMacro=WEBCORE_EXPORT,
Exposed=(Window,Worker),
Expand Down Expand Up @@ -76,6 +78,8 @@
optional unrestricted double originX = 0,
optional unrestricted double originY = 0,
optional unrestricted double originZ = 0);
[NewObject] DOMMatrix scaleNonUniform(optional unrestricted double scaleX = 1,
optional unrestricted double scaleY = 1);
[NewObject] DOMMatrix rotate(optional unrestricted double rotX = 0,
optional unrestricted double rotY,
optional unrestricted double rotZ); // Angles are in degrees.
Expand Down

0 comments on commit d0f9805

Please sign in to comment.