Changeset 243703 in webkit
- Timestamp:
- Apr 1, 2019 11:46:44 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r243696 r243703 1 2019-04-01 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 SVGMatrix.IDL methods do not conform to the specs 4 https://bugs.webkit.org/show_bug.cgi?id=196263 5 6 Reviewed by Simon Fraser. 7 8 * svg/dom/SVGMatrix-expected.txt: 9 * svg/dom/SVGMatrix.html: 10 Clean this test. Make it test the case when valid arguments are passed to 11 the methods of the SVGMatrix. Make sure the methods are read-only. All 12 of them should be making a copy of the matrix, applying the transform and 13 returning the copy. 14 1 15 2019-04-01 Shawn Roberts <sroberts@apple.com> 2 16 -
trunk/LayoutTests/svg/dom/SVGMatrix-expected.txt
r165640 r243703 6 6 7 7 Check initial matrix values 8 PASS matrix.a is 1 9 PASS matrix.b is 0 10 PASS matrix.c is 0 11 PASS matrix.d is 1 12 PASS matrix.e is 0 13 PASS matrix.f is 0 8 PASS matrixToString(matrix) is "{ a: 1, b: 0, c: 0, d: 1, e: 0, f: 0}" 14 9 15 10 Check assigning matrices … … 26 21 PASS matrix.a = 'aString' is 'aString' 27 22 PASS matrix.a is NaN 23 PASS matrix.a = null is null 24 PASS matrix.a is 0 28 25 PASS matrix.a = 2 is 2 29 26 PASS matrix.b = matrix is matrix … … 35 32 PASS matrix.b = 'aString' is 'aString' 36 33 PASS matrix.b is NaN 34 PASS matrix.b = null is null 35 PASS matrix.b is 0 37 36 PASS matrix.b = 0 is 0 38 37 PASS matrix.c = matrix is matrix … … 44 43 PASS matrix.c = 'aString' is 'aString' 45 44 PASS matrix.c is NaN 45 PASS matrix.c = null is null 46 PASS matrix.c is 0 46 47 PASS matrix.c = 0 is 0 47 48 PASS matrix.d = matrix is matrix … … 53 54 PASS matrix.d = 'aString' is 'aString' 54 55 PASS matrix.d is NaN 56 PASS matrix.d = null is null 57 PASS matrix.d is 0 55 58 PASS matrix.d = 1 is 1 56 59 PASS matrix.e = matrix is matrix … … 62 65 PASS matrix.e = 'aString' is 'aString' 63 66 PASS matrix.e is NaN 67 PASS matrix.e = null is null 68 PASS matrix.e is 0 64 69 PASS matrix.e = 0 is 0 65 70 PASS matrix.f = matrix is matrix … … 71 76 PASS matrix.f = 'aString' is 'aString' 72 77 PASS matrix.f is NaN 78 PASS matrix.f = null is null 79 PASS matrix.f is 0 73 80 PASS matrix.f = 200 is 200 74 81 75 82 Check that the matrix is still containing the correct values 76 PASS matrix.a is 2 77 PASS matrix.b is 0 78 PASS matrix.c is 0 79 PASS matrix.d is 1 80 PASS matrix.e is 0 81 PASS matrix.f is 200 82 83 Check assigning null works as expected 84 PASS matrix.f = null is null 85 PASS matrix.a is 2 86 PASS matrix.b is 0 87 PASS matrix.c is 0 88 PASS matrix.d is 1 89 PASS matrix.e is 0 90 PASS matrix.f is 0 83 PASS matrixToString(matrix) is "{ a: 2, b: 0, c: 0, d: 1, e: 0, f: 200}" 91 84 92 85 Check calling 'multiply' with invalid arguments … … 155 148 PASS matrix.skewY('aString') is non-null. 156 149 PASS matrix.skewY(svgElement) is non-null. 150 151 Check calling SVGMatrix methods with valid arguments 152 PASS matrixToString(matrix.translate(10, 20)) is "{ a: 2, b: 0, c: 0, d: 1, e: 20, f: 220}" 153 PASS matrixToString(matrix.scale(5)) is "{ a: 10, b: 0, c: 0, d: 5, e: 0, f: 200}" 154 PASS matrixToString(matrix.scaleNonUniform(2, 3)) is "{ a: 4, b: 0, c: 0, d: 3, e: 0, f: 200}" 155 PASS matrixToString(matrix.skewX(90)) is "{ a: 2, b: 0, c: 32662478706390740, d: 1, e: 0, f: 200}" 156 PASS matrixToString(matrix.skewY(90)) is "{ a: 2, b: 16331239353195370, c: 0, d: 1, e: 0, f: 200}" 157 158 Check that the matrix is still containing the correct values 159 PASS matrixToString(matrix) is "{ a: 2, b: 0, c: 0, d: 1, e: 0, f: 200}" 160 161 Calling methods that throw exceptions 162 PASS matrix.rotateFromVector(0, 4) threw exception TypeError: Type error. 163 PASS matrix.rotateFromVector(4, 0) threw exception TypeError: Type error. 164 PASS matrix.a = 0 is 0 165 PASS matrix.inverse() threw exception InvalidStateError: Matrix is not invertible. 166 157 167 PASS successfullyParsed is true 158 168 -
trunk/LayoutTests/svg/dom/SVGMatrix.html
r217390 r243703 8 8 <div id="console"></div> 9 9 <script> 10 description("This test checks the SVGMatrix API");11 10 12 11 var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); 13 12 var matrix = svgElement.createSVGMatrix(); 14 13 14 function matrixToString(matrix) 15 { 16 return "{ a: " + matrix.a + ", b: " + matrix.b + ", c: " + matrix.c + ", d: " + matrix.d + ", e: " + matrix.e + ", f: " + matrix.f + "}"; 17 } 18 19 function checkAttributeSetting(matrix, name) { 20 var value = matrix[name]; 21 22 shouldBe("matrix." + name + " = matrix", "matrix"); 23 shouldBe("matrix." + name, "NaN"); 24 shouldBe("matrix." + name + " = 0", "0"); 25 shouldBe("matrix." + name + " = svgElement", "svgElement"); 26 shouldBe("matrix." + name, "NaN"); 27 shouldBe("matrix." + name + " = 0", "0"); 28 shouldBe("matrix." + name + " = 'aString'", "'aString'"); 29 shouldBe("matrix." + name, "NaN"); 30 //Check assigning null works as expected 31 shouldBeNull("matrix." + name + " = null"); 32 shouldBe("matrix." + name, "0"); 33 // Reset to previous value. 34 shouldBe("matrix." + name + " = " + value.toString(), value.toString()); 35 } 36 37 function checkMethodCallingOneMatrixArgument(matrix, name) { 38 debug(""); 39 debug("Check calling '" + name + "' with invalid arguments"); 40 shouldThrow("matrix." + name + "()"); 41 shouldThrow("matrix." + name + "(true)"); 42 shouldThrow("matrix." + name + "(2)"); 43 shouldThrow("matrix." + name + "('aString')"); 44 shouldThrow("matrix." + name + "(svgElement)"); 45 } 46 47 function checkMethodCallingOneNumericArgument(matrix, name) { 48 debug(""); 49 debug("Check calling '" + name + "' with invalid arguments"); 50 shouldThrow("matrix." + name + "()"); 51 shouldBeNonNull("matrix." + name + "('aString')"); 52 shouldBeNonNull("matrix." + name + "(svgElement)"); 53 } 54 55 function checkMethodCallingTwoNumericArguments(matrix, name) { 56 debug(""); 57 debug("Check calling '" + name + "' with invalid arguments"); 58 shouldThrow("matrix." + name + "()"); 59 shouldThrow("matrix." + name + "(true)"); 60 shouldThrow("matrix." + name + "(2)"); 61 shouldThrow("matrix." + name + "('aString')"); 62 shouldThrow("matrix." + name + "(svgElement)"); 63 shouldBeNonNull("matrix." + name + "('aString', 'aString')"); 64 shouldBeNonNull("matrix." + name + "(svgElement, svgElement)"); 65 shouldBeNonNull("matrix." + name + "(2, 'aString')"); 66 shouldBeNonNull("matrix." + name + "(2, svgElement)"); 67 shouldBeNonNull("matrix." + name + "('aString', 2)"); 68 shouldBeNonNull("matrix." + name + "(svgElement, 2)"); 69 } 70 71 description("This test checks the SVGMatrix API"); 72 15 73 debug(""); 16 74 debug("Check initial matrix values"); 17 shouldBe("matrix.a", "1"); 18 shouldBe("matrix.b", "0"); 19 shouldBe("matrix.c", "0"); 20 shouldBe("matrix.d", "1"); 21 shouldBe("matrix.e", "0"); 22 shouldBe("matrix.f", "0"); 75 shouldBeEqualToString("matrixToString(matrix)", "{ a: 1, b: 0, c: 0, d: 1, e: 0, f: 0}"); 23 76 24 77 debug(""); … … 29 82 debug(""); 30 83 debug("Check assigning invalid matrices"); 31 shouldBe("matrix.a = matrix", "matrix"); 32 shouldBe("matrix.a", "NaN"); 33 shouldBe("matrix.a = 0", "0"); 34 shouldBe("matrix.a = svgElement", "svgElement"); 35 shouldBe("matrix.a", "NaN"); 36 shouldBe("matrix.a = 0", "0"); 37 shouldBe("matrix.a = 'aString'", "'aString'"); 38 shouldBe("matrix.a", "NaN"); 39 // Reset to previous value. 40 shouldBe("matrix.a = 2", "2"); 41 42 shouldBe("matrix.b = matrix", "matrix"); 43 shouldBe("matrix.b", "NaN"); 44 shouldBe("matrix.b = 0", "0"); 45 shouldBe("matrix.b = svgElement", "svgElement"); 46 shouldBe("matrix.b", "NaN"); 47 shouldBe("matrix.b = 0", "0"); 48 shouldBe("matrix.b = 'aString'", "'aString'"); 49 shouldBe("matrix.b", "NaN"); 50 // Reset to previous value. 51 shouldBe("matrix.b = 0", "0"); 52 53 shouldBe("matrix.c = matrix", "matrix"); 54 shouldBe("matrix.c", "NaN"); 55 shouldBe("matrix.c = 0", "0"); 56 shouldBe("matrix.c = svgElement", "svgElement"); 57 shouldBe("matrix.c", "NaN"); 58 shouldBe("matrix.c = 0", "0"); 59 shouldBe("matrix.c = 'aString'", "'aString'"); 60 shouldBe("matrix.c", "NaN"); 61 // Reset to previous value. 62 shouldBe("matrix.c = 0", "0"); 63 64 shouldBe("matrix.d = matrix", "matrix"); 65 shouldBe("matrix.d", "NaN"); 66 shouldBe("matrix.d = 0", "0"); 67 shouldBe("matrix.d = svgElement", "svgElement"); 68 shouldBe("matrix.d", "NaN"); 69 shouldBe("matrix.d = 0", "0"); 70 shouldBe("matrix.d = 'aString'", "'aString'"); 71 shouldBe("matrix.d", "NaN"); 72 // Reset to previous value. 73 shouldBe("matrix.d = 1", "1"); 74 75 shouldBe("matrix.e = matrix", "matrix"); 76 shouldBe("matrix.e", "NaN"); 77 shouldBe("matrix.e = 0", "0"); 78 shouldBe("matrix.e = svgElement", "svgElement"); 79 shouldBe("matrix.e", "NaN"); 80 shouldBe("matrix.e = 0", "0"); 81 shouldBe("matrix.e = 'aString'", "'aString'"); 82 shouldBe("matrix.e", "NaN"); 83 // Reset to previous value. 84 shouldBe("matrix.e = 0", "0"); 85 86 shouldBe("matrix.f = matrix", "matrix"); 87 shouldBe("matrix.f", "NaN"); 88 shouldBe("matrix.f = 0", "0"); 89 shouldBe("matrix.f = svgElement", "svgElement"); 90 shouldBe("matrix.f", "NaN"); 91 shouldBe("matrix.f = 0", "0"); 92 shouldBe("matrix.f = 'aString'", "'aString'"); 93 shouldBe("matrix.f", "NaN"); 94 // Reset to previous value. 95 shouldBe("matrix.f = 200", "200"); 84 checkAttributeSetting(matrix, "a"); 85 checkAttributeSetting(matrix, "b"); 86 checkAttributeSetting(matrix, "c"); 87 checkAttributeSetting(matrix, "d"); 88 checkAttributeSetting(matrix, "e"); 89 checkAttributeSetting(matrix, "f"); 96 90 97 91 debug(""); 98 92 debug("Check that the matrix is still containing the correct values"); 99 shouldBe("matrix.a", "2"); 100 shouldBe("matrix.b", "0"); 101 shouldBe("matrix.c", "0"); 102 shouldBe("matrix.d", "1"); 103 shouldBe("matrix.e", "0"); 104 shouldBe("matrix.f", "200"); 93 shouldBeEqualToString("matrixToString(matrix)", "{ a: 2, b: 0, c: 0, d: 1, e: 0, f: 200}"); 94 95 checkMethodCallingOneMatrixArgument(matrix, "multiply") 96 checkMethodCallingTwoNumericArguments(matrix, "translate"); 97 checkMethodCallingOneNumericArgument(matrix, "scale"); 98 checkMethodCallingTwoNumericArguments(matrix, "scaleNonUniform"); 99 checkMethodCallingOneNumericArgument(matrix, "rotate"); 100 checkMethodCallingTwoNumericArguments(matrix, "rotateFromVector"); 101 checkMethodCallingOneNumericArgument(matrix, "skewX"); 102 checkMethodCallingOneNumericArgument(matrix, "skewY"); 105 103 106 104 debug(""); 107 debug("Check assigning null works as expected"); 108 shouldBeNull("matrix.f = null"); 109 shouldBe("matrix.a", "2"); 110 shouldBe("matrix.b", "0"); 111 shouldBe("matrix.c", "0"); 112 shouldBe("matrix.d", "1"); 113 shouldBe("matrix.e", "0"); 114 shouldBe("matrix.f", "0"); 105 debug("Check calling SVGMatrix methods with valid arguments"); 106 shouldBeEqualToString("matrixToString(matrix.translate(10, 20))", "{ a: 2, b: 0, c: 0, d: 1, e: 20, f: 220}"); 107 shouldBeEqualToString("matrixToString(matrix.scale(5))", "{ a: 10, b: 0, c: 0, d: 5, e: 0, f: 200}"); 108 shouldBeEqualToString("matrixToString(matrix.scaleNonUniform(2, 3))", "{ a: 4, b: 0, c: 0, d: 3, e: 0, f: 200}"); 109 shouldBeEqualToString("matrixToString(matrix.skewX(90))", "{ a: 2, b: 0, c: 32662478706390740, d: 1, e: 0, f: 200}"); 110 shouldBeEqualToString("matrixToString(matrix.skewY(90))", "{ a: 2, b: 16331239353195370, c: 0, d: 1, e: 0, f: 200}"); 115 111 116 112 debug(""); 117 debug("Check calling 'multiply' with invalid arguments"); 118 shouldThrow("matrix.multiply()"); 119 shouldThrow("matrix.multiply(true)"); 120 shouldThrow("matrix.multiply(2)"); 121 shouldThrow("matrix.multiply('aString')"); 122 shouldThrow("matrix.multiply(svgElement)"); 113 debug("Check that the matrix is still containing the correct values"); 114 shouldBeEqualToString("matrixToString(matrix)", "{ a: 2, b: 0, c: 0, d: 1, e: 0, f: 200}"); 123 115 124 116 debug(""); 125 debug("Check calling 'translate' with invalid arguments"); 126 shouldThrow("matrix.translate()"); 127 shouldThrow("matrix.translate(true)"); 128 shouldThrow("matrix.translate(2)"); 129 shouldThrow("matrix.translate('aString')"); 130 shouldThrow("matrix.translate(svgElement)"); 131 // The following string and object arguments convert to NaN 132 // per ECMA-262, 9.3, "ToNumber". 133 shouldBeNonNull("matrix.translate('aString', 'aString')"); 134 shouldBeNonNull("matrix.translate(svgElement, svgElement)"); 135 shouldBeNonNull("matrix.translate(2, 'aString')"); 136 shouldBeNonNull("matrix.translate(2, svgElement)"); 137 shouldBeNonNull("matrix.translate('aString', 2)"); 138 shouldBeNonNull("matrix.translate(svgElement, 2)"); 117 debug("Calling methods that throw exceptions"); 118 shouldThrow("matrix.rotateFromVector(0, 4)"); 119 shouldThrow("matrix.rotateFromVector(4, 0)"); 120 shouldBe("matrix.a = 0", "0"); 121 shouldThrow("matrix.inverse()"); 139 122 140 123 debug(""); 141 debug("Check calling 'scale' with invalid arguments"); 142 shouldThrow("matrix.scale()"); 143 shouldBeNonNull("matrix.scale('aString')"); 144 shouldBeNonNull("matrix.scale(svgElement)"); 124 successfullyParsed = true; 145 125 146 147 debug("");148 debug("Check calling 'scaleNonUniform' with invalid arguments");149 shouldThrow("matrix.scaleNonUniform()");150 shouldThrow("matrix.scaleNonUniform(true)");151 shouldThrow("matrix.scaleNonUniform(2)");152 shouldThrow("matrix.scaleNonUniform('aString')");153 shouldThrow("matrix.scaleNonUniform(svgElement)");154 shouldBeNonNull("matrix.scaleNonUniform('aString', 'aString')");155 shouldBeNonNull("matrix.scaleNonUniform(svgElement, svgElement)");156 shouldBeNonNull("matrix.scaleNonUniform(2, 'aString')");157 shouldBeNonNull("matrix.scaleNonUniform(2, svgElement)");158 shouldBeNonNull("matrix.scaleNonUniform('aString', 2)");159 shouldBeNonNull("matrix.scaleNonUniform(svgElement, 2)");160 161 debug("");162 debug("Check calling 'rotate' with invalid arguments");163 shouldThrow("matrix.rotate()");164 shouldBeNonNull("matrix.rotate('aString')");165 shouldBeNonNull("matrix.rotate(svgElement)");166 167 debug("");168 debug("Check calling 'rotateFromVector' with invalid arguments");169 shouldThrow("matrix.rotateFromVector()");170 shouldThrow("matrix.rotateFromVector(true)");171 shouldThrow("matrix.rotateFromVector(2)");172 shouldThrow("matrix.rotateFromVector('aString')");173 shouldThrow("matrix.rotateFromVector(svgElement)");174 shouldBeNonNull("matrix.rotateFromVector('aString', 'aString')");175 shouldBeNonNull("matrix.rotateFromVector(svgElement, svgElement)");176 shouldBeNonNull("matrix.rotateFromVector(2, 'aString')");177 shouldBeNonNull("matrix.rotateFromVector(2, svgElement)");178 shouldBeNonNull("matrix.rotateFromVector('aString', 2)");179 shouldBeNonNull("matrix.rotateFromVector(svgElement, 2)");180 181 debug("");182 debug("Check calling 'skewX' with invalid arguments");183 shouldThrow("matrix.skewX()");184 shouldBeNonNull("matrix.skewX('aString')");185 shouldBeNonNull("matrix.skewX(svgElement)");186 187 debug("");188 debug("Check calling 'skewY' with invalid arguments");189 shouldThrow("matrix.skewY()");190 shouldBeNonNull("matrix.skewY('aString')");191 shouldBeNonNull("matrix.skewY(svgElement)");192 193 successfullyParsed = true;194 126 </script> 195 127 <script src="../../resources/js-test-post.js"></script> -
trunk/Source/WebCore/ChangeLog
r243701 r243703 1 2019-04-01 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 SVGMatrix.IDL methods do not conform to the specs 4 https://bugs.webkit.org/show_bug.cgi?id=196263 5 6 Reviewed by Simon Fraser. 7 8 I think there was a misconception about these functions. The specs link 9 is: https://www.w3.org/TR/SVG11/coords.html#InterfaceSVGMatrix. 10 11 Notice that the specs does not state that the SVGMethod methods should 12 raise the exception NO_MODIFICATION_ALLOWED_ERR if the object is read 13 only. Notice setting the attribute 'a' for example may raise this 14 exception. Therefore, I think the specs wanted to make these operations 15 read-only. None of the methods should raise the exception 16 NO_MODIFICATION_ALLOWED_ERR. 17 18 In fact the SVG code was doing the right thing. For example SVGMatrix::scale() 19 was calling SVGMatrixValue::scale() which was making a copy of itself, 20 applying the scale on the copy and then returning the copy. When 21 SVGMatrix::scale() receives the copy of the SVGMatrixValue it creates and 22 returns a new SVGMatrix object. 23 24 * WebCore.xcodeproj/project.pbxproj: 25 * svg/SVGMatrix.h: 26 (WebCore::SVGMatrix::create): 27 (WebCore::SVGMatrix::a const): 28 (WebCore::SVGMatrix::b const): 29 (WebCore::SVGMatrix::c const): 30 (WebCore::SVGMatrix::d const): 31 (WebCore::SVGMatrix::e const): 32 (WebCore::SVGMatrix::f const): 33 (WebCore::SVGMatrix::multiply const): 34 (WebCore::SVGMatrix::inverse const): 35 (WebCore::SVGMatrix::translate const): 36 (WebCore::SVGMatrix::scale const): 37 (WebCore::SVGMatrix::scaleNonUniform const): 38 (WebCore::SVGMatrix::rotate const): 39 (WebCore::SVGMatrix::rotateFromVector const): 40 (WebCore::SVGMatrix::flipX const): 41 (WebCore::SVGMatrix::flipY const): 42 (WebCore::SVGMatrix::skewX const): 43 (WebCore::SVGMatrix::skewY const): 44 (WebCore::SVGMatrix::a): Deleted. 45 (WebCore::SVGMatrix::b): Deleted. 46 (WebCore::SVGMatrix::c): Deleted. 47 (WebCore::SVGMatrix::d): Deleted. 48 (WebCore::SVGMatrix::e): Deleted. 49 (WebCore::SVGMatrix::f): Deleted. 50 (WebCore::SVGMatrix::multiply): Deleted. 51 (WebCore::SVGMatrix::inverse): Deleted. 52 (WebCore::SVGMatrix::translate): Deleted. 53 (WebCore::SVGMatrix::scale): Deleted. 54 (WebCore::SVGMatrix::scaleNonUniform): Deleted. 55 (WebCore::SVGMatrix::rotate): Deleted. 56 (WebCore::SVGMatrix::rotateFromVector): Deleted. 57 (WebCore::SVGMatrix::flipX): Deleted. 58 (WebCore::SVGMatrix::flipY): Deleted. 59 (WebCore::SVGMatrix::skewX): Deleted. 60 (WebCore::SVGMatrix::skewY): Deleted. 61 (WebCore::SVGMatrix::SVGMatrix): Deleted. 62 * svg/SVGMatrix.idl: 63 * svg/SVGMatrixValue.h: Removed. 64 * svg/SVGTransform.cpp: 65 (WebCore::SVGTransform::matrix): 66 * svg/SVGTransformDistance.cpp: 67 (WebCore::SVGTransformDistance::addToSVGTransform const): 68 * svg/SVGTransformValue.h: 69 (WebCore::SVGTransformValue::matrix const): 70 (WebCore::SVGTransformValue::matrix): 71 (WebCore::SVGTransformValue::svgMatrix): Deleted. 72 (WebCore::operator==): Deleted. 73 (WebCore::operator!=): Deleted. 74 * svg/properties/SVGMatrixTearOff.h: 75 * svg/properties/SVGPropertyTearOff.h: 76 (WebCore::SVGPropertyTearOff::propertyReference const): 77 1 78 2019-04-01 Simon Fraser <simon.fraser@apple.com> 2 79 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r243682 r243703 2338 2338 7CE58D501DD69A1E00128552 /* SVGNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D4F1DD69A1E00128552 /* SVGNumber.h */; }; 2339 2339 7CE58D581DD7D96D00128552 /* SVGTransformValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D561DD7D96D00128552 /* SVGTransformValue.h */; }; 2340 7CE58D5C1DD7EC9C00128552 /* SVGMatrixValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D5B1DD7EC9C00128552 /* SVGMatrixValue.h */; };2341 2340 7CE68344192143A800F4D928 /* UserMessageHandlerDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CE68342192143A800F4D928 /* UserMessageHandlerDescriptor.cpp */; }; 2342 2341 7CE68345192143A800F4D928 /* UserMessageHandlerDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE68343192143A800F4D928 /* UserMessageHandlerDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 9876 9875 7CE58D561DD7D96D00128552 /* SVGTransformValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTransformValue.h; sourceTree = "<group>"; }; 9877 9876 7CE58D591DD7DE5200128552 /* SVGTransform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTransform.cpp; sourceTree = "<group>"; }; 9878 7CE58D5B1DD7EC9C00128552 /* SVGMatrixValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGMatrixValue.h; sourceTree = "<group>"; };9879 9877 7CE68342192143A800F4D928 /* UserMessageHandlerDescriptor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMessageHandlerDescriptor.cpp; sourceTree = "<group>"; }; 9880 9878 7CE68343192143A800F4D928 /* UserMessageHandlerDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMessageHandlerDescriptor.h; sourceTree = "<group>"; }; … … 24031 24029 0806E57912893045007CED32 /* SVGMatrix.h */, 24032 24030 B22278B30D00BF200071B782 /* SVGMatrix.idl */, 24033 7CE58D5B1DD7EC9C00128552 /* SVGMatrixValue.h */,24034 24031 B22278B40D00BF200071B782 /* SVGMetadataElement.cpp */, 24035 24032 B22278B50D00BF200071B782 /* SVGMetadataElement.h */, … … 31641 31638 0806E57A12893045007CED32 /* SVGMatrix.h in Headers */, 31642 31639 08CA3D4412894A3800FFF260 /* SVGMatrixTearOff.h in Headers */, 31643 7CE58D5C1DD7EC9C00128552 /* SVGMatrixValue.h in Headers */,31644 31640 B2227A4B0D00BF220071B782 /* SVGMetadataElement.h in Headers */, 31645 31641 B2A1F2B10CEF0ABF00442F6A /* SVGMissingGlyphElement.h in Headers */, -
trunk/Source/WebCore/svg/SVGMatrix.h
r242978 r243703 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #include " SVGMatrixValue.h"28 #include "AffineTransform.h" 29 29 #include "SVGPropertyTearOff.h" 30 30 … … 32 32 33 33 // FIXME: Remove this class once SVGMatrix becomes an alias to DOMMatrix. 34 class SVGMatrix : public SVGPropertyTearOff<SVGMatrixValue> { 34 class SVGMatrix : public SVGPropertyTearOff<AffineTransform> { 35 using Base = SVGPropertyTearOff<AffineTransform>; 36 using Base::Base; 37 35 38 public: 36 static Ref<SVGMatrix> create(SVGLegacyAnimatedProperty& animatedProperty, SVGPropertyRole role, SVGMatrixValue& value)37 { 38 return adoptRef(*new SVGMatrix( animatedProperty, role, value));39 } 40 41 static Ref<SVGMatrix> create(const SVGMatrixValue& initialValue = { })39 static Ref<SVGMatrix> create(SVGLegacyAnimatedProperty& animatedProperty, SVGPropertyRole role, AffineTransform& value) 40 { 41 return adoptRef(*new SVGMatrix(&animatedProperty, role, value)); 42 } 43 44 static Ref<SVGMatrix> create(const AffineTransform& initialValue = { }) 42 45 { 43 46 return adoptRef(*new SVGMatrix(initialValue)); … … 51 54 } 52 55 53 double a() 56 double a() const 54 57 { 55 58 return propertyReference().a(); … … 67 70 } 68 71 69 double b() 72 double b() const 70 73 { 71 74 return propertyReference().b(); … … 83 86 } 84 87 85 double c() 88 double c() const 86 89 { 87 90 return propertyReference().c(); … … 99 102 } 100 103 101 double d() 104 double d() const 102 105 { 103 106 return propertyReference().d(); … … 115 118 } 116 119 117 double e() 120 double e() const 118 121 { 119 122 return propertyReference().e(); … … 131 134 } 132 135 133 double f() 136 double f() const 134 137 { 135 138 return propertyReference().f(); … … 147 150 } 148 151 149 ExceptionOr<Ref<SVGMatrix>> multiply(SVGMatrix& secondMatrix) 150 { 151 if (isReadOnly()) 152 return Exception { NoModificationAllowedError }; 153 154 auto result = propertyReference().multiply(secondMatrix.propertyReference()); 155 commitChange(); 156 157 return SVGMatrix::create(result); 158 } 159 160 ExceptionOr<Ref<SVGMatrix>> inverse() 161 { 162 if (isReadOnly()) 163 return Exception { NoModificationAllowedError }; 164 165 auto result = propertyReference().inverse(); 166 if (result.hasException()) 167 return result.releaseException(); 168 169 commitChange(); 170 return SVGMatrix::create(result.releaseReturnValue()); 171 } 172 173 ExceptionOr<Ref<SVGMatrix>> translate(float x, float y) 174 { 175 if (isReadOnly()) 176 return Exception { NoModificationAllowedError }; 177 178 auto result = propertyReference().translate(x, y); 179 commitChange(); 180 181 return SVGMatrix::create(result); 182 } 183 184 ExceptionOr<Ref<SVGMatrix>> scale(float scaleFactor) 185 { 186 if (isReadOnly()) 187 return Exception { NoModificationAllowedError }; 188 189 auto result = propertyReference().scale(scaleFactor); 190 commitChange(); 191 192 return SVGMatrix::create(result); 193 } 194 195 ExceptionOr<Ref<SVGMatrix>> scaleNonUniform(float scaleFactorX, float scaleFactorY) 196 { 197 if (isReadOnly()) 198 return Exception { NoModificationAllowedError }; 199 200 auto result = propertyReference().scaleNonUniform(scaleFactorX, scaleFactorY); 201 commitChange(); 202 203 return SVGMatrix::create(result); 204 } 205 206 ExceptionOr<Ref<SVGMatrix>> rotate(float angle) 207 { 208 if (isReadOnly()) 209 return Exception { NoModificationAllowedError }; 210 211 auto result = propertyReference().rotate(angle); 212 commitChange(); 213 214 return SVGMatrix::create(result); 215 } 216 217 ExceptionOr<Ref<SVGMatrix>> rotateFromVector(float x, float y) 218 { 219 if (isReadOnly()) 220 return Exception { NoModificationAllowedError }; 221 222 auto result = propertyReference().rotateFromVector(x, y); 223 if (result.hasException()) 224 return result.releaseException(); 225 226 commitChange(); 227 return SVGMatrix::create(result.releaseReturnValue()); 228 } 229 230 ExceptionOr<Ref<SVGMatrix>> flipX() 231 { 232 if (isReadOnly()) 233 return Exception { NoModificationAllowedError }; 234 235 auto result = propertyReference().flipX(); 236 commitChange(); 237 238 return SVGMatrix::create(result); 239 } 240 241 ExceptionOr<Ref<SVGMatrix>> flipY() 242 { 243 if (isReadOnly()) 244 return Exception { NoModificationAllowedError }; 245 246 auto result = propertyReference().flipY(); 247 commitChange(); 248 249 return SVGMatrix::create(result); 250 } 251 252 ExceptionOr<Ref<SVGMatrix>> skewX(float angle) 253 { 254 if (isReadOnly()) 255 return Exception { NoModificationAllowedError }; 256 257 auto result = propertyReference().skewX(angle); 258 commitChange(); 259 260 return SVGMatrix::create(result); 261 } 262 263 ExceptionOr<Ref<SVGMatrix>> skewY(float angle) 264 { 265 if (isReadOnly()) 266 return Exception { NoModificationAllowedError }; 267 268 auto result = propertyReference().skewY(angle); 269 commitChange(); 270 271 return SVGMatrix::create(result); 272 } 273 274 protected: 275 SVGMatrix(SVGLegacyAnimatedProperty& animatedProperty, SVGPropertyRole role, SVGMatrixValue& value) 276 : SVGPropertyTearOff<SVGMatrixValue>(&animatedProperty, role, value) 277 { 278 } 279 280 explicit SVGMatrix(const SVGMatrixValue& initialValue) 281 : SVGPropertyTearOff<SVGMatrixValue>(initialValue) 282 { 283 } 284 285 explicit SVGMatrix(const SVGMatrixValue* initialValue) 286 : SVGPropertyTearOff<SVGMatrixValue>(initialValue) 287 { 152 Ref<SVGMatrix> multiply(SVGMatrix& secondMatrix) const 153 { 154 auto copy = propertyReference(); 155 copy.multiply(secondMatrix.propertyReference()); 156 return SVGMatrix::create(copy); 157 } 158 159 ExceptionOr<Ref<SVGMatrix>> inverse() const 160 { 161 auto inverse = propertyReference().inverse(); 162 if (!inverse) 163 return Exception { InvalidStateError, "Matrix is not invertible"_s }; 164 165 return SVGMatrix::create(*inverse); 166 } 167 168 Ref<SVGMatrix> translate(float x, float y) const 169 { 170 auto copy = propertyReference(); 171 copy.translate(x, y); 172 return SVGMatrix::create(copy); 173 } 174 175 Ref<SVGMatrix> scale(float scaleFactor) const 176 { 177 auto copy = propertyReference(); 178 copy.scale(scaleFactor); 179 return SVGMatrix::create(copy); 180 } 181 182 Ref<SVGMatrix> scaleNonUniform(float scaleFactorX, float scaleFactorY) const 183 { 184 auto copy = propertyReference(); 185 copy.scaleNonUniform(scaleFactorX, scaleFactorY); 186 return SVGMatrix::create(copy); 187 } 188 189 Ref<SVGMatrix> rotate(float angle) const 190 { 191 auto copy = propertyReference(); 192 copy.rotate(angle); 193 return SVGMatrix::create(copy); 194 } 195 196 ExceptionOr<Ref<SVGMatrix>> rotateFromVector(float x, float y) const 197 { 198 if (!x || !y) 199 return Exception { TypeError }; 200 201 auto copy = propertyReference(); 202 copy.rotateFromVector(x, y); 203 return SVGMatrix::create(copy); 204 } 205 206 Ref<SVGMatrix> flipX() const 207 { 208 auto copy = propertyReference(); 209 copy.flipX(); 210 return SVGMatrix::create(copy); 211 } 212 213 Ref<SVGMatrix> flipY() const 214 { 215 auto copy = propertyReference(); 216 copy.flipY(); 217 return SVGMatrix::create(copy); 218 } 219 220 Ref<SVGMatrix> skewX(float angle) const 221 { 222 auto copy = propertyReference(); 223 copy.skewX(angle); 224 return SVGMatrix::create(copy); 225 } 226 227 Ref<SVGMatrix> skewY(float angle) const 228 { 229 auto copy = propertyReference(); 230 copy.skewY(angle); 231 return SVGMatrix::create(copy); 288 232 } 289 233 }; -
trunk/Source/WebCore/svg/SVGMatrix.idl
r222429 r243703 34 34 attribute unrestricted double f; 35 35 36 [ MayThrowException] SVGMatrix multiply(SVGMatrix secondMatrix);37 [MayThrowException ] SVGMatrix inverse();38 [ MayThrowException] SVGMatrix translate(unrestricted float x, unrestricted float y);39 [ MayThrowException] SVGMatrix scale(unrestricted float scaleFactor);40 [ MayThrowException] SVGMatrix scaleNonUniform(unrestricted float scaleFactorX, unrestricted float scaleFactorY);41 [ MayThrowException] SVGMatrix rotate(unrestricted float angle);42 [MayThrowException ] SVGMatrix rotateFromVector(unrestricted float x, unrestricted float y);43 [ MayThrowException] SVGMatrix flipX();44 [ MayThrowException] SVGMatrix flipY();45 [ MayThrowException] SVGMatrix skewX(unrestricted float angle);46 [ MayThrowException] SVGMatrix skewY(unrestricted float angle);36 [NewObject] SVGMatrix multiply(SVGMatrix secondMatrix); 37 [MayThrowException, NewObject] SVGMatrix inverse(); 38 [NewObject] SVGMatrix translate(unrestricted float x, unrestricted float y); 39 [NewObject] SVGMatrix scale(unrestricted float scaleFactor); 40 [NewObject] SVGMatrix scaleNonUniform(unrestricted float scaleFactorX, unrestricted float scaleFactorY); 41 [NewObject] SVGMatrix rotate(unrestricted float angle); 42 [MayThrowException, NewObject] SVGMatrix rotateFromVector(unrestricted float x, unrestricted float y); 43 [NewObject] SVGMatrix flipX(); 44 [NewObject] SVGMatrix flipY(); 45 [NewObject] SVGMatrix skewX(unrestricted float angle); 46 [NewObject] SVGMatrix skewY(unrestricted float angle); 47 47 }; -
trunk/Source/WebCore/svg/SVGTransform.cpp
r208705 r243703 33 33 Ref<SVGMatrix> SVGTransform::matrix() 34 34 { 35 return SVGMatrixTearOff::create(*this, propertyReference(). svgMatrix());35 return SVGMatrixTearOff::create(*this, propertyReference().matrix()); 36 36 } 37 37 -
trunk/Source/WebCore/svg/SVGTransformDistance.cpp
r208705 r243703 161 161 SVGTransformValue SVGTransformDistance::addToSVGTransform(const SVGTransformValue& transform) const 162 162 { 163 ASSERT(m_type == transform.type() || transform == SVGTransformValue());163 ASSERT(m_type == transform.type() || !transform.isValid()); 164 164 165 165 SVGTransformValue newTransform(transform); -
trunk/Source/WebCore/svg/SVGTransformValue.h
r208705 r243703 2 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 3 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> 4 * Copyright (C) 2019 Apple Inc. All rights reserved. 4 5 * 5 6 * This library is free software; you can redistribute it and/or … … 21 22 #pragma once 22 23 24 #include "AffineTransform.h" 23 25 #include "FloatPoint.h" 24 #include "SVGMatrixValue.h"25 26 26 27 namespace WebCore { … … 51 52 SVGTransformType type() const { return m_type; } 52 53 53 SVGMatrixValue& svgMatrix() { return static_cast<SVGMatrixValue&>(m_matrix); }54 AffineTransform matrix() const{ return m_matrix; }54 const AffineTransform& matrix() const { return m_matrix; } 55 AffineTransform& matrix() { return m_matrix; } 55 56 void updateSVGMatrix(); 56 57 … … 74 75 75 76 private: 76 friend bool operator==(const SVGTransformValue&, const SVGTransformValue&);77 78 77 SVGTransformType m_type { SVG_TRANSFORM_UNKNOWN }; 79 78 float m_angle { 0 }; … … 82 81 }; 83 82 84 inline bool operator==(const SVGTransformValue& a, const SVGTransformValue& b)85 {86 return a.m_type == b.m_type && a.m_angle == b.m_angle && a.m_matrix == b.m_matrix;87 }88 89 inline bool operator!=(const SVGTransformValue& a, const SVGTransformValue& b)90 {91 return !(a == b);92 }93 94 83 } // namespace WebCore -
trunk/Source/WebCore/svg/properties/SVGMatrixTearOff.h
r232613 r243703 27 27 class SVGMatrixTearOff final : public SVGMatrix { 28 28 public: 29 static Ref<SVGMatrixTearOff> create(SVGTransform& parent, SVGMatrixValue& value)29 static Ref<SVGMatrixTearOff> create(SVGTransform& parent, AffineTransform& value) 30 30 { 31 ASSERT_UNUSED(value, &parent.propertyReference(). svgMatrix() == &value);31 ASSERT_UNUSED(value, &parent.propertyReference().matrix() == &value); 32 32 auto result = adoptRef(*new SVGMatrixTearOff(parent)); 33 33 parent.addChild(makeWeakPtr(result.get())); … … 35 35 } 36 36 37 SVGMatrixValue& propertyReference() final { return m_parent->propertyReference().svgMatrix(); } 37 const AffineTransform& propertyReference() const final { return m_parent->propertyReference().matrix(); } 38 AffineTransform& propertyReference() final { return m_parent->propertyReference().matrix(); } 38 39 39 void setValue( SVGMatrixValue& value) final { m_parent->propertyReference().setMatrix(value); }40 void setValue(AffineTransform& value) final { m_parent->propertyReference().setMatrix(value); } 40 41 41 42 void commitChange() final -
trunk/Source/WebCore/svg/properties/SVGPropertyTearOff.h
r242978 r243703 61 61 } 62 62 63 virtual const PropertyType& propertyReference() const { return *m_value; } 63 64 virtual PropertyType& propertyReference() { return *m_value; } 64 65 SVGLegacyAnimatedProperty* animatedProperty() const { return m_animatedProperty.get(); }
Note: See TracChangeset
for help on using the changeset viewer.