Title: [243703] trunk
Revision
243703
Author
[email protected]
Date
2019-04-01 11:46:44 -0700 (Mon, 01 Apr 2019)

Log Message

SVGMatrix.IDL methods do not conform to the specs
https://bugs.webkit.org/show_bug.cgi?id=196263

Patch by Said Abou-Hallawa <[email protected]> on 2019-04-01
Reviewed by Simon Fraser.

Source/WebCore:

I think there was a misconception about these functions. The specs link
is: https://www.w3.org/TR/SVG11/coords.html#InterfaceSVGMatrix.

Notice that the specs does not state that the SVGMethod methods should
raise the exception NO_MODIFICATION_ALLOWED_ERR if the object is read
only. Notice setting the attribute 'a' for example may raise this
exception. Therefore, I think the specs wanted to make these operations
read-only. None of the methods should raise the exception
NO_MODIFICATION_ALLOWED_ERR.

In fact the SVG code was doing the right thing. For example SVGMatrix::scale()
was calling SVGMatrixValue::scale() which was making a copy of itself,
applying the scale on the copy and then returning the copy. When
SVGMatrix::scale() receives the copy of the SVGMatrixValue it creates and
returns a new SVGMatrix object.

* WebCore.xcodeproj/project.pbxproj:
* svg/SVGMatrix.h:
(WebCore::SVGMatrix::create):
(WebCore::SVGMatrix::a const):
(WebCore::SVGMatrix::b const):
(WebCore::SVGMatrix::c const):
(WebCore::SVGMatrix::d const):
(WebCore::SVGMatrix::e const):
(WebCore::SVGMatrix::f const):
(WebCore::SVGMatrix::multiply const):
(WebCore::SVGMatrix::inverse const):
(WebCore::SVGMatrix::translate const):
(WebCore::SVGMatrix::scale const):
(WebCore::SVGMatrix::scaleNonUniform const):
(WebCore::SVGMatrix::rotate const):
(WebCore::SVGMatrix::rotateFromVector const):
(WebCore::SVGMatrix::flipX const):
(WebCore::SVGMatrix::flipY const):
(WebCore::SVGMatrix::skewX const):
(WebCore::SVGMatrix::skewY const):
(WebCore::SVGMatrix::a): Deleted.
(WebCore::SVGMatrix::b): Deleted.
(WebCore::SVGMatrix::c): Deleted.
(WebCore::SVGMatrix::d): Deleted.
(WebCore::SVGMatrix::e): Deleted.
(WebCore::SVGMatrix::f): Deleted.
(WebCore::SVGMatrix::multiply): Deleted.
(WebCore::SVGMatrix::inverse): Deleted.
(WebCore::SVGMatrix::translate): Deleted.
(WebCore::SVGMatrix::scale): Deleted.
(WebCore::SVGMatrix::scaleNonUniform): Deleted.
(WebCore::SVGMatrix::rotate): Deleted.
(WebCore::SVGMatrix::rotateFromVector): Deleted.
(WebCore::SVGMatrix::flipX): Deleted.
(WebCore::SVGMatrix::flipY): Deleted.
(WebCore::SVGMatrix::skewX): Deleted.
(WebCore::SVGMatrix::skewY): Deleted.
(WebCore::SVGMatrix::SVGMatrix): Deleted.
* svg/SVGMatrix.idl:
* svg/SVGMatrixValue.h: Removed.
* svg/SVGTransform.cpp:
(WebCore::SVGTransform::matrix):
* svg/SVGTransformDistance.cpp:
(WebCore::SVGTransformDistance::addToSVGTransform const):
* svg/SVGTransformValue.h:
(WebCore::SVGTransformValue::matrix const):
(WebCore::SVGTransformValue::matrix):
(WebCore::SVGTransformValue::svgMatrix): Deleted.
(WebCore::operator==): Deleted.
(WebCore::operator!=): Deleted.
* svg/properties/SVGMatrixTearOff.h:
* svg/properties/SVGPropertyTearOff.h:
(WebCore::SVGPropertyTearOff::propertyReference const):

LayoutTests:

* svg/dom/SVGMatrix-expected.txt:
* svg/dom/SVGMatrix.html:
Clean this test. Make it test the case when valid arguments are passed to
the methods of the SVGMatrix. Make sure the methods are read-only. All
of them should be making a copy of the matrix, applying the transform and
returning the copy.

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (243702 => 243703)


--- trunk/LayoutTests/ChangeLog	2019-04-01 18:33:45 UTC (rev 243702)
+++ trunk/LayoutTests/ChangeLog	2019-04-01 18:46:44 UTC (rev 243703)
@@ -1,3 +1,17 @@
+2019-04-01  Said Abou-Hallawa  <[email protected]>
+
+        SVGMatrix.IDL methods do not conform to the specs
+        https://bugs.webkit.org/show_bug.cgi?id=196263
+
+        Reviewed by Simon Fraser.
+
+        * svg/dom/SVGMatrix-expected.txt:
+        * svg/dom/SVGMatrix.html:
+        Clean this test. Make it test the case when valid arguments are passed to
+        the methods of the SVGMatrix. Make sure the methods are read-only. All
+        of them should be making a copy of the matrix, applying the transform and
+        returning the copy.
+
 2019-04-01  Shawn Roberts  <[email protected]>
 
         storage/indexeddb/modern/deletedatabase-2-private.html is a flaky failure on Mac Debug

Modified: trunk/LayoutTests/svg/dom/SVGMatrix-expected.txt (243702 => 243703)


--- trunk/LayoutTests/svg/dom/SVGMatrix-expected.txt	2019-04-01 18:33:45 UTC (rev 243702)
+++ trunk/LayoutTests/svg/dom/SVGMatrix-expected.txt	2019-04-01 18:46:44 UTC (rev 243703)
@@ -5,12 +5,7 @@
 
 
 Check initial matrix values
-PASS matrix.a is 1
-PASS matrix.b is 0
-PASS matrix.c is 0
-PASS matrix.d is 1
-PASS matrix.e is 0
-PASS matrix.f is 0
+PASS matrixToString(matrix) is "{ a: 1, b: 0, c: 0, d: 1, e: 0, f: 0}"
 
 Check assigning matrices
 PASS matrix.a = 2 is 2
@@ -25,6 +20,8 @@
 PASS matrix.a = 0 is 0
 PASS matrix.a = 'aString' is 'aString'
 PASS matrix.a is NaN
+PASS matrix.a = null is null
+PASS matrix.a is 0
 PASS matrix.a = 2 is 2
 PASS matrix.b = matrix is matrix
 PASS matrix.b is NaN
@@ -34,6 +31,8 @@
 PASS matrix.b = 0 is 0
 PASS matrix.b = 'aString' is 'aString'
 PASS matrix.b is NaN
+PASS matrix.b = null is null
+PASS matrix.b is 0
 PASS matrix.b = 0 is 0
 PASS matrix.c = matrix is matrix
 PASS matrix.c is NaN
@@ -43,6 +42,8 @@
 PASS matrix.c = 0 is 0
 PASS matrix.c = 'aString' is 'aString'
 PASS matrix.c is NaN
+PASS matrix.c = null is null
+PASS matrix.c is 0
 PASS matrix.c = 0 is 0
 PASS matrix.d = matrix is matrix
 PASS matrix.d is NaN
@@ -52,6 +53,8 @@
 PASS matrix.d = 0 is 0
 PASS matrix.d = 'aString' is 'aString'
 PASS matrix.d is NaN
+PASS matrix.d = null is null
+PASS matrix.d is 0
 PASS matrix.d = 1 is 1
 PASS matrix.e = matrix is matrix
 PASS matrix.e is NaN
@@ -61,6 +64,8 @@
 PASS matrix.e = 0 is 0
 PASS matrix.e = 'aString' is 'aString'
 PASS matrix.e is NaN
+PASS matrix.e = null is null
+PASS matrix.e is 0
 PASS matrix.e = 0 is 0
 PASS matrix.f = matrix is matrix
 PASS matrix.f is NaN
@@ -70,25 +75,13 @@
 PASS matrix.f = 0 is 0
 PASS matrix.f = 'aString' is 'aString'
 PASS matrix.f is NaN
+PASS matrix.f = null is null
+PASS matrix.f is 0
 PASS matrix.f = 200 is 200
 
 Check that the matrix is still containing the correct values
-PASS matrix.a is 2
-PASS matrix.b is 0
-PASS matrix.c is 0
-PASS matrix.d is 1
-PASS matrix.e is 0
-PASS matrix.f is 200
+PASS matrixToString(matrix) is "{ a: 2, b: 0, c: 0, d: 1, e: 0, f: 200}"
 
-Check assigning null works as expected
-PASS matrix.f = null is null
-PASS matrix.a is 2
-PASS matrix.b is 0
-PASS matrix.c is 0
-PASS matrix.d is 1
-PASS matrix.e is 0
-PASS matrix.f is 0
-
 Check calling 'multiply' with invalid arguments
 PASS matrix.multiply() threw exception TypeError: Not enough arguments.
 PASS matrix.multiply(true) threw exception TypeError: Argument 1 ('secondMatrix') to SVGMatrix.multiply must be an instance of SVGMatrix.
@@ -154,6 +147,23 @@
 PASS matrix.skewY() threw exception TypeError: Not enough arguments.
 PASS matrix.skewY('aString') is non-null.
 PASS matrix.skewY(svgElement) is non-null.
+
+Check calling SVGMatrix methods with valid arguments
+PASS matrixToString(matrix.translate(10, 20)) is "{ a: 2, b: 0, c: 0, d: 1, e: 20, f: 220}"
+PASS matrixToString(matrix.scale(5)) is "{ a: 10, b: 0, c: 0, d: 5, e: 0, f: 200}"
+PASS matrixToString(matrix.scaleNonUniform(2, 3)) is "{ a: 4, b: 0, c: 0, d: 3, e: 0, f: 200}"
+PASS matrixToString(matrix.skewX(90)) is "{ a: 2, b: 0, c: 32662478706390740, d: 1, e: 0, f: 200}"
+PASS matrixToString(matrix.skewY(90)) is "{ a: 2, b: 16331239353195370, c: 0, d: 1, e: 0, f: 200}"
+
+Check that the matrix is still containing the correct values
+PASS matrixToString(matrix) is "{ a: 2, b: 0, c: 0, d: 1, e: 0, f: 200}"
+
+Calling methods that throw exceptions
+PASS matrix.rotateFromVector(0, 4) threw exception TypeError: Type error.
+PASS matrix.rotateFromVector(4, 0) threw exception TypeError: Type error.
+PASS matrix.a = 0 is 0
+PASS matrix.inverse() threw exception InvalidStateError: Matrix is not invertible.
+
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/svg/dom/SVGMatrix.html (243702 => 243703)


--- trunk/LayoutTests/svg/dom/SVGMatrix.html	2019-04-01 18:33:45 UTC (rev 243702)
+++ trunk/LayoutTests/svg/dom/SVGMatrix.html	2019-04-01 18:46:44 UTC (rev 243703)
@@ -7,190 +7,122 @@
 <p id="description"></p>
 <div id="console"></div>
 <script>
-description("This test checks the SVGMatrix API");
 
 var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
 var matrix = svgElement.createSVGMatrix();
 
-debug("");
-debug("Check initial matrix values");
-shouldBe("matrix.a", "1");
-shouldBe("matrix.b", "0");
-shouldBe("matrix.c", "0");
-shouldBe("matrix.d", "1");
-shouldBe("matrix.e", "0");
-shouldBe("matrix.f", "0");
+function matrixToString(matrix)
+{
+	return "{ a: " + matrix.a + ", b: " + matrix.b + ", c: " + matrix.c + ", d: " + matrix.d + ", e: " + matrix.e + ", f: " + matrix.f + "}";
+}
 
-debug("");
-debug("Check assigning matrices");
-shouldBe("matrix.a = 2", "2");
-shouldBe("matrix.f = 200", "200");
+function checkAttributeSetting(matrix, name) {
+	var value = matrix[name];
 
-debug("");
-debug("Check assigning invalid matrices");
-shouldBe("matrix.a = matrix", "matrix");
-shouldBe("matrix.a", "NaN");
-shouldBe("matrix.a = 0", "0");
-shouldBe("matrix.a = svgElement", "svgElement");
-shouldBe("matrix.a", "NaN");
-shouldBe("matrix.a = 0", "0");
-shouldBe("matrix.a = 'aString'", "'aString'");
-shouldBe("matrix.a", "NaN");
-// Reset to previous value.
-shouldBe("matrix.a = 2", "2");
+	shouldBe("matrix." + name + " = matrix", "matrix");
+	shouldBe("matrix." + name, "NaN");
+	shouldBe("matrix." + name + " = 0", "0");
+	shouldBe("matrix." + name + " = svgElement", "svgElement");
+	shouldBe("matrix." + name, "NaN");
+	shouldBe("matrix." + name + " = 0", "0");
+	shouldBe("matrix." + name + " = 'aString'", "'aString'");
+	shouldBe("matrix." + name, "NaN");
+	//Check assigning null works as expected
+	shouldBeNull("matrix." + name + " = null");
+	shouldBe("matrix." + name, "0");
+	// Reset to previous value.
+	shouldBe("matrix." + name + " = " + value.toString(), value.toString());
+}
 
-shouldBe("matrix.b = matrix", "matrix");
-shouldBe("matrix.b", "NaN");
-shouldBe("matrix.b = 0", "0");
-shouldBe("matrix.b = svgElement", "svgElement");
-shouldBe("matrix.b", "NaN");
-shouldBe("matrix.b = 0", "0");
-shouldBe("matrix.b = 'aString'", "'aString'");
-shouldBe("matrix.b", "NaN");
-// Reset to previous value.
-shouldBe("matrix.b = 0", "0");
+function checkMethodCallingOneMatrixArgument(matrix, name) {
+	debug("");
+	debug("Check calling '" + name + "' with invalid arguments");
+	shouldThrow("matrix." + name + "()");
+	shouldThrow("matrix." + name + "(true)");
+	shouldThrow("matrix." + name + "(2)");
+	shouldThrow("matrix." + name + "('aString')");
+	shouldThrow("matrix." + name + "(svgElement)");
+}
 
-shouldBe("matrix.c = matrix", "matrix");
-shouldBe("matrix.c", "NaN");
-shouldBe("matrix.c = 0", "0");
-shouldBe("matrix.c = svgElement", "svgElement");
-shouldBe("matrix.c", "NaN");
-shouldBe("matrix.c = 0", "0");
-shouldBe("matrix.c = 'aString'", "'aString'");
-shouldBe("matrix.c", "NaN");
-// Reset to previous value.
-shouldBe("matrix.c = 0", "0");
+function checkMethodCallingOneNumericArgument(matrix, name) {
+	debug("");
+	debug("Check calling '" + name + "' with invalid arguments");
+	shouldThrow("matrix." + name + "()");
+	shouldBeNonNull("matrix." + name + "('aString')");
+	shouldBeNonNull("matrix." + name + "(svgElement)");
+}
 
-shouldBe("matrix.d = matrix", "matrix");
-shouldBe("matrix.d", "NaN");
-shouldBe("matrix.d = 0", "0");
-shouldBe("matrix.d = svgElement", "svgElement");
-shouldBe("matrix.d", "NaN");
-shouldBe("matrix.d = 0", "0");
-shouldBe("matrix.d = 'aString'", "'aString'");
-shouldBe("matrix.d", "NaN");
-// Reset to previous value.
-shouldBe("matrix.d = 1", "1");
+function checkMethodCallingTwoNumericArguments(matrix, name) {
+	debug("");
+	debug("Check calling '" + name + "' with invalid arguments");
+	shouldThrow("matrix." + name + "()");
+	shouldThrow("matrix." + name + "(true)");
+	shouldThrow("matrix." + name + "(2)");
+	shouldThrow("matrix." + name + "('aString')");
+	shouldThrow("matrix." + name + "(svgElement)");
+	shouldBeNonNull("matrix." + name + "('aString', 'aString')");
+	shouldBeNonNull("matrix." + name + "(svgElement, svgElement)");
+	shouldBeNonNull("matrix." + name + "(2, 'aString')");
+	shouldBeNonNull("matrix." + name + "(2, svgElement)");
+	shouldBeNonNull("matrix." + name + "('aString', 2)");
+	shouldBeNonNull("matrix." + name + "(svgElement, 2)");
+}
 
-shouldBe("matrix.e = matrix", "matrix");
-shouldBe("matrix.e", "NaN");
-shouldBe("matrix.e = 0", "0");
-shouldBe("matrix.e = svgElement", "svgElement");
-shouldBe("matrix.e", "NaN");
-shouldBe("matrix.e = 0", "0");
-shouldBe("matrix.e = 'aString'", "'aString'");
-shouldBe("matrix.e", "NaN");
-// Reset to previous value.
-shouldBe("matrix.e = 0", "0");
+description("This test checks the SVGMatrix API");
 
-shouldBe("matrix.f = matrix", "matrix");
-shouldBe("matrix.f", "NaN");
-shouldBe("matrix.f = 0", "0");
-shouldBe("matrix.f = svgElement", "svgElement");
-shouldBe("matrix.f", "NaN");
-shouldBe("matrix.f = 0", "0");
-shouldBe("matrix.f = 'aString'", "'aString'");
-shouldBe("matrix.f", "NaN");
-// Reset to previous value.
-shouldBe("matrix.f = 200", "200");
-
 debug("");
-debug("Check that the matrix is still containing the correct values");
-shouldBe("matrix.a", "2");
-shouldBe("matrix.b", "0");
-shouldBe("matrix.c", "0");
-shouldBe("matrix.d", "1");
-shouldBe("matrix.e", "0");
-shouldBe("matrix.f", "200");
+debug("Check initial matrix values");
+shouldBeEqualToString("matrixToString(matrix)", "{ a: 1, b: 0, c: 0, d: 1, e: 0, f: 0}");
 
 debug("");
-debug("Check assigning null works as expected");
-shouldBeNull("matrix.f = null");
-shouldBe("matrix.a", "2");
-shouldBe("matrix.b", "0");
-shouldBe("matrix.c", "0");
-shouldBe("matrix.d", "1");
-shouldBe("matrix.e", "0");
-shouldBe("matrix.f", "0");
+debug("Check assigning matrices");
+shouldBe("matrix.a = 2", "2");
+shouldBe("matrix.f = 200", "200");
 
 debug("");
-debug("Check calling 'multiply' with invalid arguments");
-shouldThrow("matrix.multiply()");
-shouldThrow("matrix.multiply(true)");
-shouldThrow("matrix.multiply(2)");
-shouldThrow("matrix.multiply('aString')");
-shouldThrow("matrix.multiply(svgElement)");
+debug("Check assigning invalid matrices");
+checkAttributeSetting(matrix, "a");
+checkAttributeSetting(matrix, "b");
+checkAttributeSetting(matrix, "c");
+checkAttributeSetting(matrix, "d");
+checkAttributeSetting(matrix, "e");
+checkAttributeSetting(matrix, "f");
 
 debug("");
-debug("Check calling 'translate' with invalid arguments");
-shouldThrow("matrix.translate()");
-shouldThrow("matrix.translate(true)");
-shouldThrow("matrix.translate(2)");
-shouldThrow("matrix.translate('aString')");
-shouldThrow("matrix.translate(svgElement)");
-// The following string and object arguments convert to NaN
-// per ECMA-262, 9.3, "ToNumber".
-shouldBeNonNull("matrix.translate('aString', 'aString')");
-shouldBeNonNull("matrix.translate(svgElement, svgElement)");
-shouldBeNonNull("matrix.translate(2, 'aString')");
-shouldBeNonNull("matrix.translate(2, svgElement)");
-shouldBeNonNull("matrix.translate('aString', 2)");
-shouldBeNonNull("matrix.translate(svgElement, 2)");
+debug("Check that the matrix is still containing the correct values");
+shouldBeEqualToString("matrixToString(matrix)", "{ a: 2, b: 0, c: 0, d: 1, e: 0, f: 200}");
 
-debug("");
-debug("Check calling 'scale' with invalid arguments");
-shouldThrow("matrix.scale()");
-shouldBeNonNull("matrix.scale('aString')");
-shouldBeNonNull("matrix.scale(svgElement)");
+checkMethodCallingOneMatrixArgument(matrix, "multiply")
+checkMethodCallingTwoNumericArguments(matrix, "translate");
+checkMethodCallingOneNumericArgument(matrix, "scale");
+checkMethodCallingTwoNumericArguments(matrix, "scaleNonUniform");
+checkMethodCallingOneNumericArgument(matrix, "rotate");
+checkMethodCallingTwoNumericArguments(matrix, "rotateFromVector");
+checkMethodCallingOneNumericArgument(matrix, "skewX");
+checkMethodCallingOneNumericArgument(matrix, "skewY");
 
-
 debug("");
-debug("Check calling 'scaleNonUniform' with invalid arguments");
-shouldThrow("matrix.scaleNonUniform()");
-shouldThrow("matrix.scaleNonUniform(true)");
-shouldThrow("matrix.scaleNonUniform(2)");
-shouldThrow("matrix.scaleNonUniform('aString')");
-shouldThrow("matrix.scaleNonUniform(svgElement)");
-shouldBeNonNull("matrix.scaleNonUniform('aString', 'aString')");
-shouldBeNonNull("matrix.scaleNonUniform(svgElement, svgElement)");
-shouldBeNonNull("matrix.scaleNonUniform(2, 'aString')");
-shouldBeNonNull("matrix.scaleNonUniform(2, svgElement)");
-shouldBeNonNull("matrix.scaleNonUniform('aString', 2)");
-shouldBeNonNull("matrix.scaleNonUniform(svgElement, 2)");
+debug("Check calling SVGMatrix methods with valid arguments");
+shouldBeEqualToString("matrixToString(matrix.translate(10, 20))", "{ a: 2, b: 0, c: 0, d: 1, e: 20, f: 220}");
+shouldBeEqualToString("matrixToString(matrix.scale(5))", "{ a: 10, b: 0, c: 0, d: 5, e: 0, f: 200}");
+shouldBeEqualToString("matrixToString(matrix.scaleNonUniform(2, 3))", "{ a: 4, b: 0, c: 0, d: 3, e: 0, f: 200}");
+shouldBeEqualToString("matrixToString(matrix.skewX(90))", "{ a: 2, b: 0, c: 32662478706390740, d: 1, e: 0, f: 200}");
+shouldBeEqualToString("matrixToString(matrix.skewY(90))", "{ a: 2, b: 16331239353195370, c: 0, d: 1, e: 0, f: 200}");
 
 debug("");
-debug("Check calling 'rotate' with invalid arguments");
-shouldThrow("matrix.rotate()");
-shouldBeNonNull("matrix.rotate('aString')");
-shouldBeNonNull("matrix.rotate(svgElement)");
+debug("Check that the matrix is still containing the correct values");
+shouldBeEqualToString("matrixToString(matrix)", "{ a: 2, b: 0, c: 0, d: 1, e: 0, f: 200}");
 
 debug("");
-debug("Check calling 'rotateFromVector' with invalid arguments");
-shouldThrow("matrix.rotateFromVector()");
-shouldThrow("matrix.rotateFromVector(true)");
-shouldThrow("matrix.rotateFromVector(2)");
-shouldThrow("matrix.rotateFromVector('aString')");
-shouldThrow("matrix.rotateFromVector(svgElement)");
-shouldBeNonNull("matrix.rotateFromVector('aString', 'aString')");
-shouldBeNonNull("matrix.rotateFromVector(svgElement, svgElement)");
-shouldBeNonNull("matrix.rotateFromVector(2, 'aString')");
-shouldBeNonNull("matrix.rotateFromVector(2, svgElement)");
-shouldBeNonNull("matrix.rotateFromVector('aString', 2)");
-shouldBeNonNull("matrix.rotateFromVector(svgElement, 2)");
+debug("Calling methods that throw exceptions");
+shouldThrow("matrix.rotateFromVector(0, 4)");
+shouldThrow("matrix.rotateFromVector(4, 0)");
+shouldBe("matrix.a = 0", "0");
+shouldThrow("matrix.inverse()");
 
 debug("");
-debug("Check calling 'skewX' with invalid arguments");
-shouldThrow("matrix.skewX()");
-shouldBeNonNull("matrix.skewX('aString')");
-shouldBeNonNull("matrix.skewX(svgElement)");
+successfullyParsed = true;
 
-debug("");
-debug("Check calling 'skewY' with invalid arguments");
-shouldThrow("matrix.skewY()");
-shouldBeNonNull("matrix.skewY('aString')");
-shouldBeNonNull("matrix.skewY(svgElement)");
-
-successfullyParsed = true;
 </script>
 <script src=""
 </body>

Modified: trunk/Source/WebCore/ChangeLog (243702 => 243703)


--- trunk/Source/WebCore/ChangeLog	2019-04-01 18:33:45 UTC (rev 243702)
+++ trunk/Source/WebCore/ChangeLog	2019-04-01 18:46:44 UTC (rev 243703)
@@ -1,3 +1,80 @@
+2019-04-01  Said Abou-Hallawa  <[email protected]>
+
+        SVGMatrix.IDL methods do not conform to the specs
+        https://bugs.webkit.org/show_bug.cgi?id=196263
+
+        Reviewed by Simon Fraser.
+
+        I think there was a misconception about these functions. The specs link
+        is: https://www.w3.org/TR/SVG11/coords.html#InterfaceSVGMatrix.
+
+        Notice that the specs does not state that the SVGMethod methods should
+        raise the exception NO_MODIFICATION_ALLOWED_ERR if the object is read
+        only. Notice setting the attribute 'a' for example may raise this
+        exception. Therefore, I think the specs wanted to make these operations
+        read-only. None of the methods should raise the exception
+        NO_MODIFICATION_ALLOWED_ERR.
+
+        In fact the SVG code was doing the right thing. For example SVGMatrix::scale()
+        was calling SVGMatrixValue::scale() which was making a copy of itself,
+        applying the scale on the copy and then returning the copy. When 
+        SVGMatrix::scale() receives the copy of the SVGMatrixValue it creates and
+        returns a new SVGMatrix object.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * svg/SVGMatrix.h:
+        (WebCore::SVGMatrix::create):
+        (WebCore::SVGMatrix::a const):
+        (WebCore::SVGMatrix::b const):
+        (WebCore::SVGMatrix::c const):
+        (WebCore::SVGMatrix::d const):
+        (WebCore::SVGMatrix::e const):
+        (WebCore::SVGMatrix::f const):
+        (WebCore::SVGMatrix::multiply const):
+        (WebCore::SVGMatrix::inverse const):
+        (WebCore::SVGMatrix::translate const):
+        (WebCore::SVGMatrix::scale const):
+        (WebCore::SVGMatrix::scaleNonUniform const):
+        (WebCore::SVGMatrix::rotate const):
+        (WebCore::SVGMatrix::rotateFromVector const):
+        (WebCore::SVGMatrix::flipX const):
+        (WebCore::SVGMatrix::flipY const):
+        (WebCore::SVGMatrix::skewX const):
+        (WebCore::SVGMatrix::skewY const):
+        (WebCore::SVGMatrix::a): Deleted.
+        (WebCore::SVGMatrix::b): Deleted.
+        (WebCore::SVGMatrix::c): Deleted.
+        (WebCore::SVGMatrix::d): Deleted.
+        (WebCore::SVGMatrix::e): Deleted.
+        (WebCore::SVGMatrix::f): Deleted.
+        (WebCore::SVGMatrix::multiply): Deleted.
+        (WebCore::SVGMatrix::inverse): Deleted.
+        (WebCore::SVGMatrix::translate): Deleted.
+        (WebCore::SVGMatrix::scale): Deleted.
+        (WebCore::SVGMatrix::scaleNonUniform): Deleted.
+        (WebCore::SVGMatrix::rotate): Deleted.
+        (WebCore::SVGMatrix::rotateFromVector): Deleted.
+        (WebCore::SVGMatrix::flipX): Deleted.
+        (WebCore::SVGMatrix::flipY): Deleted.
+        (WebCore::SVGMatrix::skewX): Deleted.
+        (WebCore::SVGMatrix::skewY): Deleted.
+        (WebCore::SVGMatrix::SVGMatrix): Deleted.
+        * svg/SVGMatrix.idl:
+        * svg/SVGMatrixValue.h: Removed.
+        * svg/SVGTransform.cpp:
+        (WebCore::SVGTransform::matrix):
+        * svg/SVGTransformDistance.cpp:
+        (WebCore::SVGTransformDistance::addToSVGTransform const):
+        * svg/SVGTransformValue.h:
+        (WebCore::SVGTransformValue::matrix const):
+        (WebCore::SVGTransformValue::matrix):
+        (WebCore::SVGTransformValue::svgMatrix): Deleted.
+        (WebCore::operator==): Deleted.
+        (WebCore::operator!=): Deleted.
+        * svg/properties/SVGMatrixTearOff.h:
+        * svg/properties/SVGPropertyTearOff.h:
+        (WebCore::SVGPropertyTearOff::propertyReference const):
+
 2019-04-01  Simon Fraser  <[email protected]>
 
         Plumb through a ScrollType value that indicates whether a scroll was a user or programmatic scroll

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (243702 => 243703)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-04-01 18:33:45 UTC (rev 243702)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-04-01 18:46:44 UTC (rev 243703)
@@ -2337,7 +2337,6 @@
 		7CE58D4A1DD64A5B00128552 /* SVGPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D491DD64A5B00128552 /* SVGPoint.h */; };
 		7CE58D501DD69A1E00128552 /* SVGNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D4F1DD69A1E00128552 /* SVGNumber.h */; };
 		7CE58D581DD7D96D00128552 /* SVGTransformValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D561DD7D96D00128552 /* SVGTransformValue.h */; };
-		7CE58D5C1DD7EC9C00128552 /* SVGMatrixValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D5B1DD7EC9C00128552 /* SVGMatrixValue.h */; };
 		7CE68344192143A800F4D928 /* UserMessageHandlerDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CE68342192143A800F4D928 /* UserMessageHandlerDescriptor.cpp */; };
 		7CE68345192143A800F4D928 /* UserMessageHandlerDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE68343192143A800F4D928 /* UserMessageHandlerDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7CE683471921821500F4D928 /* UserMessageHandlerDescriptorTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE683461921821500F4D928 /* UserMessageHandlerDescriptorTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9875,7 +9874,6 @@
 		7CE58D551DD7D96D00128552 /* SVGTransformValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTransformValue.cpp; sourceTree = "<group>"; };
 		7CE58D561DD7D96D00128552 /* SVGTransformValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTransformValue.h; sourceTree = "<group>"; };
 		7CE58D591DD7DE5200128552 /* SVGTransform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTransform.cpp; sourceTree = "<group>"; };
-		7CE58D5B1DD7EC9C00128552 /* SVGMatrixValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGMatrixValue.h; sourceTree = "<group>"; };
 		7CE68342192143A800F4D928 /* UserMessageHandlerDescriptor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMessageHandlerDescriptor.cpp; sourceTree = "<group>"; };
 		7CE68343192143A800F4D928 /* UserMessageHandlerDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMessageHandlerDescriptor.h; sourceTree = "<group>"; };
 		7CE683461921821500F4D928 /* UserMessageHandlerDescriptorTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMessageHandlerDescriptorTypes.h; sourceTree = "<group>"; };
@@ -24030,7 +24028,6 @@
 				B22278B20D00BF200071B782 /* SVGMaskElement.idl */,
 				0806E57912893045007CED32 /* SVGMatrix.h */,
 				B22278B30D00BF200071B782 /* SVGMatrix.idl */,
-				7CE58D5B1DD7EC9C00128552 /* SVGMatrixValue.h */,
 				B22278B40D00BF200071B782 /* SVGMetadataElement.cpp */,
 				B22278B50D00BF200071B782 /* SVGMetadataElement.h */,
 				B22278B60D00BF200071B782 /* SVGMetadataElement.idl */,
@@ -31640,7 +31637,6 @@
 				B2227A470D00BF220071B782 /* SVGMaskElement.h in Headers */,
 				0806E57A12893045007CED32 /* SVGMatrix.h in Headers */,
 				08CA3D4412894A3800FFF260 /* SVGMatrixTearOff.h in Headers */,
-				7CE58D5C1DD7EC9C00128552 /* SVGMatrixValue.h in Headers */,
 				B2227A4B0D00BF220071B782 /* SVGMetadataElement.h in Headers */,
 				B2A1F2B10CEF0ABF00442F6A /* SVGMissingGlyphElement.h in Headers */,
 				B2227A4E0D00BF220071B782 /* SVGMPathElement.h in Headers */,

Modified: trunk/Source/WebCore/svg/SVGMatrix.h (243702 => 243703)


--- trunk/Source/WebCore/svg/SVGMatrix.h	2019-04-01 18:33:45 UTC (rev 243702)
+++ trunk/Source/WebCore/svg/SVGMatrix.h	2019-04-01 18:46:44 UTC (rev 243703)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -25,20 +25,23 @@
 
 #pragma once
 
-#include "SVGMatrixValue.h"
+#include "AffineTransform.h"
 #include "SVGPropertyTearOff.h"
 
 namespace WebCore {
 
 // FIXME: Remove this class once SVGMatrix becomes an alias to DOMMatrix.
-class SVGMatrix : public SVGPropertyTearOff<SVGMatrixValue> {
+class SVGMatrix : public SVGPropertyTearOff<AffineTransform> {
+    using Base = SVGPropertyTearOff<AffineTransform>;
+    using Base::Base;
+
 public:
-    static Ref<SVGMatrix> create(SVGLegacyAnimatedProperty& animatedProperty, SVGPropertyRole role, SVGMatrixValue& value)
+    static Ref<SVGMatrix> create(SVGLegacyAnimatedProperty& animatedProperty, SVGPropertyRole role, AffineTransform& value)
     {
-        return adoptRef(*new SVGMatrix(animatedProperty, role, value));
+        return adoptRef(*new SVGMatrix(&animatedProperty, role, value));
     }
 
-    static Ref<SVGMatrix> create(const SVGMatrixValue& initialValue = { })
+    static Ref<SVGMatrix> create(const AffineTransform& initialValue = { })
     {
         return adoptRef(*new SVGMatrix(initialValue));
     }
@@ -50,7 +53,7 @@
         return create(initialValue.releaseReturnValue());
     }
 
-    double a()
+    double a() const
     {
         return propertyReference().a();
     }
@@ -66,7 +69,7 @@
         return { };
     }
 
-    double b()
+    double b() const
     {
         return propertyReference().b();
     }
@@ -82,7 +85,7 @@
         return { };
     }
 
-    double c()
+    double c() const
     {
         return propertyReference().c();
     }
@@ -98,7 +101,7 @@
         return { };
     }
 
-    double d()
+    double d() const
     {
         return propertyReference().d();
     }
@@ -114,7 +117,7 @@
         return { };
     }
 
-    double e()
+    double e() const
     {
         return propertyReference().e();
     }
@@ -130,7 +133,7 @@
         return { };
     }
 
-    double f()
+    double f() const
     {
         return propertyReference().f();
     }
@@ -146,146 +149,87 @@
         return { };
     }
 
-    ExceptionOr<Ref<SVGMatrix>> multiply(SVGMatrix& secondMatrix)
+    Ref<SVGMatrix> multiply(SVGMatrix& secondMatrix) const
     {
-        if (isReadOnly())
-            return Exception { NoModificationAllowedError };
-
-        auto result = propertyReference().multiply(secondMatrix.propertyReference());
-        commitChange();
-
-        return SVGMatrix::create(result);
+        auto copy = propertyReference();
+        copy.multiply(secondMatrix.propertyReference());
+        return SVGMatrix::create(copy);
     }
 
-    ExceptionOr<Ref<SVGMatrix>> inverse()
+    ExceptionOr<Ref<SVGMatrix>> inverse() const
     {
-        if (isReadOnly())
-            return Exception { NoModificationAllowedError };
+        auto inverse = propertyReference().inverse();
+        if (!inverse)
+            return Exception { InvalidStateError, "Matrix is not invertible"_s };
 
-        auto result = propertyReference().inverse();
-        if (result.hasException())
-            return result.releaseException();
-        
-        commitChange();
-        return SVGMatrix::create(result.releaseReturnValue());
+        return SVGMatrix::create(*inverse);
     }
 
-    ExceptionOr<Ref<SVGMatrix>> translate(float x, float y)
+    Ref<SVGMatrix> translate(float x, float y) const
     {
-        if (isReadOnly())
-            return Exception { NoModificationAllowedError };
-
-        auto result = propertyReference().translate(x, y);        
-        commitChange();
-
-        return SVGMatrix::create(result);
+        auto copy = propertyReference();
+        copy.translate(x, y);
+        return SVGMatrix::create(copy);
     }
 
-    ExceptionOr<Ref<SVGMatrix>> scale(float scaleFactor)
+    Ref<SVGMatrix> scale(float scaleFactor) const
     {
-        if (isReadOnly())
-            return Exception { NoModificationAllowedError };
-
-        auto result = propertyReference().scale(scaleFactor);        
-        commitChange();
-
-        return SVGMatrix::create(result);
+        auto copy = propertyReference();
+        copy.scale(scaleFactor);
+        return SVGMatrix::create(copy);
     }
 
-    ExceptionOr<Ref<SVGMatrix>> scaleNonUniform(float scaleFactorX, float scaleFactorY)
+    Ref<SVGMatrix> scaleNonUniform(float scaleFactorX, float scaleFactorY) const
     {
-        if (isReadOnly())
-            return Exception { NoModificationAllowedError };
-
-        auto result = propertyReference().scaleNonUniform(scaleFactorX, scaleFactorY);        
-        commitChange();
-
-        return SVGMatrix::create(result);
+        auto copy = propertyReference();
+        copy.scaleNonUniform(scaleFactorX, scaleFactorY);
+        return SVGMatrix::create(copy);
     }
 
-    ExceptionOr<Ref<SVGMatrix>> rotate(float angle)
+    Ref<SVGMatrix> rotate(float angle) const
     {
-        if (isReadOnly())
-            return Exception { NoModificationAllowedError };
-
-        auto result = propertyReference().rotate(angle);        
-        commitChange();
-
-        return SVGMatrix::create(result);
+        auto copy = propertyReference();
+        copy.rotate(angle);
+        return SVGMatrix::create(copy);
     }
 
-    ExceptionOr<Ref<SVGMatrix>> rotateFromVector(float x, float y)
+    ExceptionOr<Ref<SVGMatrix>> rotateFromVector(float x, float y) const
     {
-        if (isReadOnly())
-            return Exception { NoModificationAllowedError };
+        if (!x || !y)
+            return Exception { TypeError };
 
-        auto result = propertyReference().rotateFromVector(x, y);        
-        if (result.hasException())
-            return result.releaseException();
-        
-        commitChange();
-        return SVGMatrix::create(result.releaseReturnValue());
+        auto copy = propertyReference();
+        copy.rotateFromVector(x, y);
+        return SVGMatrix::create(copy);
     }
 
-    ExceptionOr<Ref<SVGMatrix>> flipX()
+    Ref<SVGMatrix> flipX() const
     {
-        if (isReadOnly())
-            return Exception { NoModificationAllowedError };
-
-        auto result = propertyReference().flipX();        
-        commitChange();
-
-        return SVGMatrix::create(result);
+        auto copy = propertyReference();
+        copy.flipX();
+        return SVGMatrix::create(copy);
     }
 
-    ExceptionOr<Ref<SVGMatrix>> flipY()
+    Ref<SVGMatrix> flipY() const
     {
-        if (isReadOnly())
-            return Exception { NoModificationAllowedError };
-
-        auto result = propertyReference().flipY();        
-        commitChange();
-
-        return SVGMatrix::create(result);
+        auto copy = propertyReference();
+        copy.flipY();
+        return SVGMatrix::create(copy);
     }
 
-    ExceptionOr<Ref<SVGMatrix>> skewX(float angle)
+    Ref<SVGMatrix> skewX(float angle) const
     {
-        if (isReadOnly())
-            return Exception { NoModificationAllowedError };
-
-        auto result = propertyReference().skewX(angle);        
-        commitChange();
-
-        return SVGMatrix::create(result);
+        auto copy = propertyReference();
+        copy.skewX(angle);
+        return SVGMatrix::create(copy);
     }
 
-    ExceptionOr<Ref<SVGMatrix>> skewY(float angle)
+    Ref<SVGMatrix> skewY(float angle) const
     {
-        if (isReadOnly())
-            return Exception { NoModificationAllowedError };
-
-        auto result = propertyReference().skewY(angle);        
-        commitChange();
-
-        return SVGMatrix::create(result);
+        auto copy = propertyReference();
+        copy.skewY(angle);
+        return SVGMatrix::create(copy);
     }
-
-protected:
-    SVGMatrix(SVGLegacyAnimatedProperty& animatedProperty, SVGPropertyRole role, SVGMatrixValue& value)
-        : SVGPropertyTearOff<SVGMatrixValue>(&animatedProperty, role, value)
-    {
-    }
-
-    explicit SVGMatrix(const SVGMatrixValue& initialValue)
-        : SVGPropertyTearOff<SVGMatrixValue>(initialValue)
-    {
-    }
-
-    explicit SVGMatrix(const SVGMatrixValue* initialValue)
-        : SVGPropertyTearOff<SVGMatrixValue>(initialValue)
-    {
-    }
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/svg/SVGMatrix.idl (243702 => 243703)


--- trunk/Source/WebCore/svg/SVGMatrix.idl	2019-04-01 18:33:45 UTC (rev 243702)
+++ trunk/Source/WebCore/svg/SVGMatrix.idl	2019-04-01 18:46:44 UTC (rev 243703)
@@ -33,15 +33,15 @@
     attribute unrestricted double e;
     attribute unrestricted double f;
 
-    [MayThrowException] SVGMatrix multiply(SVGMatrix secondMatrix);
-    [MayThrowException] SVGMatrix inverse();
-    [MayThrowException] SVGMatrix translate(unrestricted float x, unrestricted float y);
-    [MayThrowException] SVGMatrix scale(unrestricted float scaleFactor);
-    [MayThrowException] SVGMatrix scaleNonUniform(unrestricted float scaleFactorX, unrestricted float scaleFactorY);
-    [MayThrowException] SVGMatrix rotate(unrestricted float angle);
-    [MayThrowException] SVGMatrix rotateFromVector(unrestricted float x, unrestricted float y);
-    [MayThrowException] SVGMatrix flipX();
-    [MayThrowException] SVGMatrix flipY();
-    [MayThrowException] SVGMatrix skewX(unrestricted float angle);
-    [MayThrowException] SVGMatrix skewY(unrestricted float angle);
+    [NewObject] SVGMatrix multiply(SVGMatrix secondMatrix);
+    [MayThrowException, NewObject] SVGMatrix inverse();
+    [NewObject] SVGMatrix translate(unrestricted float x, unrestricted float y);
+    [NewObject] SVGMatrix scale(unrestricted float scaleFactor);
+    [NewObject] SVGMatrix scaleNonUniform(unrestricted float scaleFactorX, unrestricted float scaleFactorY);
+    [NewObject] SVGMatrix rotate(unrestricted float angle);
+    [MayThrowException, NewObject] SVGMatrix rotateFromVector(unrestricted float x, unrestricted float y);
+    [NewObject] SVGMatrix flipX();
+    [NewObject] SVGMatrix flipY();
+    [NewObject] SVGMatrix skewX(unrestricted float angle);
+    [NewObject] SVGMatrix skewY(unrestricted float angle);
 };

Deleted: trunk/Source/WebCore/svg/SVGMatrixValue.h (243702 => 243703)


--- trunk/Source/WebCore/svg/SVGMatrixValue.h	2019-04-01 18:33:45 UTC (rev 243702)
+++ trunk/Source/WebCore/svg/SVGMatrixValue.h	2019-04-01 18:46:44 UTC (rev 243703)
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#pragma once
-
-#include "AffineTransform.h"
-#include "ExceptionOr.h"
-
-namespace WebCore {
-
-class SVGMatrixValue final : public AffineTransform {
-public:
-    SVGMatrixValue() = default;
-
-    SVGMatrixValue(const AffineTransform& other)
-        : AffineTransform(other)
-    {
-    }
-
-    SVGMatrixValue(double a, double b, double c, double d, double e, double f)
-        : AffineTransform(a, b, c, d, e, f)
-    {
-    }
-
-    SVGMatrixValue translate(double tx, double ty)
-    {
-        AffineTransform copy { *this };
-        copy.translate(tx, ty);
-        return SVGMatrixValue { copy };
-    }
-
-    SVGMatrixValue scale(double s)
-    {
-        AffineTransform copy { *this };
-        copy.scale(s, s);
-        return SVGMatrixValue { copy };
-    }
-
-    SVGMatrixValue scaleNonUniform(double sx, double sy)
-    {
-        AffineTransform copy { *this };
-        copy.scale(sx, sy);
-        return SVGMatrixValue { copy };
-    }
-
-    SVGMatrixValue rotate(double d)
-    {
-        AffineTransform copy { *this };
-        copy.rotate(d);
-        return SVGMatrixValue { copy };
-    }
-
-    SVGMatrixValue flipX()
-    {
-        AffineTransform copy { *this };
-        copy.flipX();
-        return SVGMatrixValue { copy };
-    }
-
-    SVGMatrixValue flipY()
-    {
-        AffineTransform copy { *this };
-        copy.flipY();
-        return SVGMatrixValue { copy };
-    }
-
-    SVGMatrixValue skewX(double angle)
-    {
-        AffineTransform copy { *this };
-        copy.skewX(angle);
-        return SVGMatrixValue { copy };
-    }
-
-    SVGMatrixValue skewY(double angle)
-    {
-        AffineTransform copy { *this };
-        copy.skewY(angle);
-        return SVGMatrixValue { copy };
-    }
-
-    SVGMatrixValue multiply(const SVGMatrixValue& other)
-    {
-        AffineTransform copy { *this };
-        copy *= static_cast<const AffineTransform&>(other);
-        return SVGMatrixValue { copy };
-    }
-
-    ExceptionOr<SVGMatrixValue> inverse() const
-    {
-        if (auto inverse = AffineTransform::inverse())
-            return SVGMatrixValue { inverse.value() };
-        
-        return Exception { InvalidStateError, "Matrix is not invertible"_s };
-    }
-
-    ExceptionOr<SVGMatrixValue> rotateFromVector(double x, double y)
-    {
-        if (!x || !y)
-            return Exception { TypeError };
-
-        AffineTransform copy { *this };
-        copy.rotateFromVector(x, y);
-        return SVGMatrixValue { copy };
-    }
-
-};
-
-} // namespace WebCore

Modified: trunk/Source/WebCore/svg/SVGTransform.cpp (243702 => 243703)


--- trunk/Source/WebCore/svg/SVGTransform.cpp	2019-04-01 18:33:45 UTC (rev 243702)
+++ trunk/Source/WebCore/svg/SVGTransform.cpp	2019-04-01 18:46:44 UTC (rev 243703)
@@ -32,7 +32,7 @@
 
 Ref<SVGMatrix> SVGTransform::matrix()
 {
-    return SVGMatrixTearOff::create(*this, propertyReference().svgMatrix());
+    return SVGMatrixTearOff::create(*this, propertyReference().matrix());
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/svg/SVGTransformDistance.cpp (243702 => 243703)


--- trunk/Source/WebCore/svg/SVGTransformDistance.cpp	2019-04-01 18:33:45 UTC (rev 243702)
+++ trunk/Source/WebCore/svg/SVGTransformDistance.cpp	2019-04-01 18:46:44 UTC (rev 243703)
@@ -160,7 +160,7 @@
 
 SVGTransformValue SVGTransformDistance::addToSVGTransform(const SVGTransformValue& transform) const
 {
-    ASSERT(m_type == transform.type() || transform == SVGTransformValue());
+    ASSERT(m_type == transform.type() || !transform.isValid());
     
     SVGTransformValue newTransform(transform);
     

Modified: trunk/Source/WebCore/svg/SVGTransformValue.h (243702 => 243703)


--- trunk/Source/WebCore/svg/SVGTransformValue.h	2019-04-01 18:33:45 UTC (rev 243702)
+++ trunk/Source/WebCore/svg/SVGTransformValue.h	2019-04-01 18:46:44 UTC (rev 243703)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <[email protected]>
  * Copyright (C) 2004, 2005 Rob Buis <[email protected]>
+ * Copyright (C) 2019 Apple Inc.  All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -20,8 +21,8 @@
 
 #pragma once
 
+#include "AffineTransform.h"
 #include "FloatPoint.h"
-#include "SVGMatrixValue.h"
 
 namespace WebCore {
 
@@ -50,8 +51,8 @@
 
     SVGTransformType type() const { return m_type; }
 
-    SVGMatrixValue& svgMatrix() { return static_cast<SVGMatrixValue&>(m_matrix); }
-    AffineTransform matrix() const { return m_matrix; }
+    const AffineTransform& matrix() const { return m_matrix; }
+    AffineTransform& matrix() { return m_matrix; }
     void updateSVGMatrix();
 
     float angle() const { return m_angle; }
@@ -73,8 +74,6 @@
     static const String& transformTypePrefixForParsing(SVGTransformType);
 
 private:
-    friend bool operator==(const SVGTransformValue&, const SVGTransformValue&);
-
     SVGTransformType m_type { SVG_TRANSFORM_UNKNOWN };
     float m_angle { 0 };
     FloatPoint m_center;
@@ -81,14 +80,4 @@
     AffineTransform m_matrix;
 };
 
-inline bool operator==(const SVGTransformValue& a, const SVGTransformValue& b)
-{
-    return a.m_type == b.m_type && a.m_angle == b.m_angle && a.m_matrix == b.m_matrix;
-}
-
-inline bool operator!=(const SVGTransformValue& a, const SVGTransformValue& b)
-{
-    return !(a == b);
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/svg/properties/SVGMatrixTearOff.h (243702 => 243703)


--- trunk/Source/WebCore/svg/properties/SVGMatrixTearOff.h	2019-04-01 18:33:45 UTC (rev 243702)
+++ trunk/Source/WebCore/svg/properties/SVGMatrixTearOff.h	2019-04-01 18:46:44 UTC (rev 243703)
@@ -26,17 +26,18 @@
 
 class SVGMatrixTearOff final : public SVGMatrix {
 public:
-    static Ref<SVGMatrixTearOff> create(SVGTransform& parent, SVGMatrixValue& value)
+    static Ref<SVGMatrixTearOff> create(SVGTransform& parent, AffineTransform& value)
     {
-        ASSERT_UNUSED(value, &parent.propertyReference().svgMatrix() == &value);
+        ASSERT_UNUSED(value, &parent.propertyReference().matrix() == &value);
         auto result = adoptRef(*new SVGMatrixTearOff(parent));
         parent.addChild(makeWeakPtr(result.get()));
         return result;
     }
 
-    SVGMatrixValue& propertyReference() final { return m_parent->propertyReference().svgMatrix(); }
+    const AffineTransform& propertyReference() const final { return m_parent->propertyReference().matrix(); }
+    AffineTransform& propertyReference() final { return m_parent->propertyReference().matrix(); }
 
-    void setValue(SVGMatrixValue& value) final { m_parent->propertyReference().setMatrix(value); }
+    void setValue(AffineTransform& value) final { m_parent->propertyReference().setMatrix(value); }
 
     void commitChange() final
     {

Modified: trunk/Source/WebCore/svg/properties/SVGPropertyTearOff.h (243702 => 243703)


--- trunk/Source/WebCore/svg/properties/SVGPropertyTearOff.h	2019-04-01 18:33:45 UTC (rev 243702)
+++ trunk/Source/WebCore/svg/properties/SVGPropertyTearOff.h	2019-04-01 18:46:44 UTC (rev 243703)
@@ -60,6 +60,7 @@
         return create(initialValue.releaseReturnValue());
     }
 
+    virtual const PropertyType& propertyReference() const { return *m_value; }
     virtual PropertyType& propertyReference() { return *m_value; }
     SVGLegacyAnimatedProperty* animatedProperty() const { return m_animatedProperty.get(); }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to