Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (293004 => 293005)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2022-04-19 02:45:51 UTC (rev 293005)
@@ -1,3 +1,16 @@
+2022-04-18 Alex Christensen <[email protected]>
+
+ Implement CSSTransformValue.is2D
+ https://bugs.webkit.org/show_bug.cgi?id=239462
+
+ Reviewed by Simon Fraser.
+
+ * web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssMatrixComponent.tentative-expected.txt:
+ * web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssRotate.tentative-expected.txt:
+ * web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssScale.tentative-expected.txt:
+ * web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssTransformValue.tentative-expected.txt:
+ * web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssPerspective.tentative-expected.txt:
+
2022-04-18 Matt Woodrow <[email protected]>
Implement support for aligning baselines through subgrids
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssMatrixComponent.tentative-expected.txt (293004 => 293005)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssMatrixComponent.tentative-expected.txt 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssMatrixComponent.tentative-expected.txt 2022-04-19 02:45:51 UTC (rev 293005)
@@ -1,10 +1,10 @@
-FAIL CSSMatrixComponent can be constructed from a 2D matrix with is2D true assert_true: expected true got false
+PASS CSSMatrixComponent can be constructed from a 2D matrix with is2D true
PASS CSSMatrixComponent can be constructed from a 2D matrix with is2D false
FAIL CSSMatrixComponent can be constructed from a 2D matrix without a CSSMatrixComponentOptions assert_equals: expected true but got false
FAIL CSSMatrixComponent can be constructed from a 2D matrix with an invalid CSSMatrixComponentOptions assert_equals: expected true but got false
PASS CSSMatrixComponent.matrix can be updated to a 2D matrix
-FAIL CSSMatrixComponent can be constructed from a 3D matrix with is2D true assert_true: expected true got false
+PASS CSSMatrixComponent can be constructed from a 3D matrix with is2D true
PASS CSSMatrixComponent can be constructed from a 3D matrix with is2D false
PASS CSSMatrixComponent can be constructed from a 3D matrix without a CSSMatrixComponentOptions
PASS CSSMatrixComponent can be constructed from a 3D matrix with an invalid CSSMatrixComponentOptions
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssPerspective.tentative-expected.txt (293004 => 293005)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssPerspective.tentative-expected.txt 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssPerspective.tentative-expected.txt 2022-04-19 02:45:51 UTC (rev 293005)
@@ -3,19 +3,19 @@
PASS Constructing a CSSPerspective with a double throws a TypeError
PASS Constructing a CSSPerspective with a unitless zero throws a TypeError
PASS Constructing a CSSPerspective with a string length throws a TypeError
-FAIL Constructing a CSSPerspective with a number CSSUnitValue throws a TypeError assert_throws_js: function "() => new CSSPerspective(length)" did not throw
-FAIL Constructing a CSSPerspective with a time dimension CSSUnitValue throws a TypeError assert_throws_js: function "() => new CSSPerspective(length)" did not throw
-FAIL Constructing a CSSPerspective with a CSSMathValue of angle type throws a TypeError assert_throws_js: function "() => new CSSPerspective(length)" did not throw
+PASS Constructing a CSSPerspective with a number CSSUnitValue throws a TypeError
+PASS Constructing a CSSPerspective with a time dimension CSSUnitValue throws a TypeError
+PASS Constructing a CSSPerspective with a CSSMathValue of angle type throws a TypeError
PASS Updating CSSPerspective.length with a keyword throws a TypeError
PASS Updating CSSPerspective.length with a double throws a TypeError
PASS Updating CSSPerspective.length with a unitless zero throws a TypeError
PASS Updating CSSPerspective.length with a string length throws a TypeError
-FAIL Updating CSSPerspective.length with a number CSSUnitValue throws a TypeError assert_throws_js: function "() => perspective.length = length" did not throw
-FAIL Updating CSSPerspective.length with a time dimension CSSUnitValue throws a TypeError assert_throws_js: function "() => perspective.length = length" did not throw
-FAIL Updating CSSPerspective.length with a CSSMathValue of angle type throws a TypeError assert_throws_js: function "() => perspective.length = length" did not throw
+PASS Updating CSSPerspective.length with a number CSSUnitValue throws a TypeError
+PASS Updating CSSPerspective.length with a time dimension CSSUnitValue throws a TypeError
+PASS Updating CSSPerspective.length with a CSSMathValue of angle type throws a TypeError
PASS CSSPerspective can be constructed from a length CSSUnitValue
PASS CSSPerspective.length can be updated to a length CSSUnitValue
PASS CSSPerspective can be constructed from a CSSMathValue of length type
PASS CSSPerspective.length can be updated to a CSSMathValue of length type
-FAIL Modifying CSSPerspective.is2D is a no-op assert_false: expected false got true
+PASS Modifying CSSPerspective.is2D is a no-op
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssRotate.tentative-expected.txt (293004 => 293005)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssRotate.tentative-expected.txt 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssRotate.tentative-expected.txt 2022-04-19 02:45:51 UTC (rev 293005)
@@ -1,28 +1,28 @@
-FAIL Constructing a CSSRotate with a CSSUnitValue with type other than angle for the angle throws a TypeError assert_throws_js: function "() => new CSSRotate(angle)" did not throw
-FAIL Constructing a CSSRotate with a CSSMathValue that doesn't match <angle> for the angle throws a TypeError assert_throws_js: function "() => new CSSRotate(angle)" did not throw
-FAIL Constructing a CSSRotate with a CSSUnitValue with type other than number for the coordinates throws a TypeError assert_throws_js: function "() => new CSSRotate(coord, 0, 0, CSS.deg(0))" did not throw
-FAIL Constructing a CSSRotate with a CSSMathValue that doesn't match <number> for the coordinates throws a TypeError assert_throws_js: function "() => new CSSRotate(coord, 0, 0, CSS.deg(0))" did not throw
-FAIL Updating CSSRotate.x to a CSSUnitValue with type other than number throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL Updating CSSRotate.x to a CSSMathValue that doesn't match <number> throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL Updating CSSRotate.y to a CSSUnitValue with type other than number throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL Updating CSSRotate.y to a CSSMathValue that doesn't match <number> throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL Updating CSSRotate.z to a CSSUnitValue with type other than number throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL Updating CSSRotate.z to a CSSMathValue that doesn't match <number> throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL Updating CSSRotate.angle to a CSSUnitValue with type other than angle throws a TypeError assert_throws_js: function "() => result.angle = angle" did not throw
-FAIL Updating CSSRotate.angle to a CSSMathValue that doesn't match <angle> throws a TypeError assert_throws_js: function "() => result.angle = angle" did not throw
-FAIL CSSRotate can be constructed from a single angle assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL CSSRotate can be constructed from numberish coordinates assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL CSSRotate can be constructed from CSSMathValues assert_equals: expected "CSSMathProduct" but got "CSSMathSum"
-FAIL CSSRotate.x can be updated to a double assert_equals: expected "CSSUnitValue" but got "Number"
+PASS Constructing a CSSRotate with a CSSUnitValue with type other than angle for the angle throws a TypeError
+PASS Constructing a CSSRotate with a CSSMathValue that doesn't match <angle> for the angle throws a TypeError
+PASS Constructing a CSSRotate with a CSSUnitValue with type other than number for the coordinates throws a TypeError
+PASS Constructing a CSSRotate with a CSSMathValue that doesn't match <number> for the coordinates throws a TypeError
+PASS Updating CSSRotate.x to a CSSUnitValue with type other than number throws a TypeError
+PASS Updating CSSRotate.x to a CSSMathValue that doesn't match <number> throws a TypeError
+PASS Updating CSSRotate.y to a CSSUnitValue with type other than number throws a TypeError
+PASS Updating CSSRotate.y to a CSSMathValue that doesn't match <number> throws a TypeError
+PASS Updating CSSRotate.z to a CSSUnitValue with type other than number throws a TypeError
+PASS Updating CSSRotate.z to a CSSMathValue that doesn't match <number> throws a TypeError
+PASS Updating CSSRotate.angle to a CSSUnitValue with type other than angle throws a TypeError
+PASS Updating CSSRotate.angle to a CSSMathValue that doesn't match <angle> throws a TypeError
+PASS CSSRotate can be constructed from a single angle
+PASS CSSRotate can be constructed from numberish coordinates
+FAIL CSSRotate can be constructed from CSSMathValues Type error
+PASS CSSRotate.x can be updated to a double
PASS CSSRotate.x can be updated to a number CSSUnitValue
PASS CSSRotate.x can be updated to a CSSMathValue matching <number>
-FAIL CSSRotate.y can be updated to a double assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL CSSRotate.y can be updated to a number CSSUnitValue assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL CSSRotate.y can be updated to a CSSMathValue matching <number> assert_equals: expected "CSSMathSum" but got "Number"
-FAIL CSSRotate.z can be updated to a double assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL CSSRotate.z can be updated to a number CSSUnitValue assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL CSSRotate.z can be updated to a CSSMathValue matching <number> assert_equals: expected "CSSMathSum" but got "Number"
+PASS CSSRotate.y can be updated to a double
+PASS CSSRotate.y can be updated to a number CSSUnitValue
+PASS CSSRotate.y can be updated to a CSSMathValue matching <number>
+PASS CSSRotate.z can be updated to a double
+PASS CSSRotate.z can be updated to a number CSSUnitValue
+PASS CSSRotate.z can be updated to a CSSMathValue matching <number>
PASS CSSRotate.angle can be updated to a degree CSSUnitValue
PASS CSSRotate.angle can be updated to a CSSMathValue matching <angle>
PASS Modifying CSSRotate.is2D can be updated to true or false
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssScale.tentative-expected.txt (293004 => 293005)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssScale.tentative-expected.txt 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssScale.tentative-expected.txt 2022-04-19 02:45:51 UTC (rev 293005)
@@ -1,26 +1,26 @@
-FAIL Constructing a CSSScale with an angle CSSUnitValue for the coordinates throws a TypeError assert_throws_js: function "() => new CSSScale(coord, 0)" did not throw
-FAIL Constructing a CSSScale with a CSSMathValue that doesn't match <number> for the coordinates throws a TypeError assert_throws_js: function "() => new CSSScale(coord, 0)" did not throw
+PASS Constructing a CSSScale with an angle CSSUnitValue for the coordinates throws a TypeError
+PASS Constructing a CSSScale with a CSSMathValue that doesn't match <number> for the coordinates throws a TypeError
FAIL Constructing a CSSScale with an invalid division by px/px for the coordinates throws a TypeError assert_throws_js: function "() => new CSSScale(coord, 0)" did not throw
-FAIL Updating CSSScale.x to an angle CSSUnitValue throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL Updating CSSScale.x to a CSSMathValue that doesn't match <number> throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL Updating CSSScale.x to an invalid division by px/px throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL Updating CSSScale.y to an angle CSSUnitValue throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL Updating CSSScale.y to a CSSMathValue that doesn't match <number> throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL Updating CSSScale.y to an invalid division by px/px throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL Updating CSSScale.z to an angle CSSUnitValue throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL Updating CSSScale.z to a CSSMathValue that doesn't match <number> throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL Updating CSSScale.z to an invalid division by px/px throws a TypeError assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL CSSScale can be constructed from two number coordinates assert_equals: expected "CSSUnitValue" but got "Number"
-FAIL CSSScale can be constructed from three number coordinates assert_equals: expected "CSSUnitValue" but got "Number"
+PASS Updating CSSScale.x to an angle CSSUnitValue throws a TypeError
+PASS Updating CSSScale.x to a CSSMathValue that doesn't match <number> throws a TypeError
+PASS Updating CSSScale.x to an invalid division by px/px throws a TypeError
+PASS Updating CSSScale.y to an angle CSSUnitValue throws a TypeError
+PASS Updating CSSScale.y to a CSSMathValue that doesn't match <number> throws a TypeError
+PASS Updating CSSScale.y to an invalid division by px/px throws a TypeError
+PASS Updating CSSScale.z to an angle CSSUnitValue throws a TypeError
+PASS Updating CSSScale.z to a CSSMathValue that doesn't match <number> throws a TypeError
+PASS Updating CSSScale.z to an invalid division by px/px throws a TypeError
+PASS CSSScale can be constructed from two number coordinates
+PASS CSSScale can be constructed from three number coordinates
PASS CSSScale can be constructed from CSSMathValue coordinates
-FAIL CSSScale.x can be updated to a number assert_equals: expected "CSSUnitValue" but got "Number"
+PASS CSSScale.x can be updated to a number
PASS CSSScale.x can be updated to a numberish
PASS CSSScale.x can be updated to a CSSMathValue
-FAIL CSSScale.y can be updated to a number assert_equals: expected "CSSUnitValue" but got "Number"
+PASS CSSScale.y can be updated to a number
PASS CSSScale.y can be updated to a numberish
PASS CSSScale.y can be updated to a CSSMathValue
-FAIL CSSScale.z can be updated to a number assert_equals: expected "CSSUnitValue" but got "Number"
+PASS CSSScale.z can be updated to a number
PASS CSSScale.z can be updated to a numberish
PASS CSSScale.z can be updated to a CSSMathValue
PASS Modifying CSSScale.is2D can be updated to true or false
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssSkew.tentative-expected.txt (293004 => 293005)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssSkew.tentative-expected.txt 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssSkew.tentative-expected.txt 2022-04-19 02:45:51 UTC (rev 293005)
@@ -3,9 +3,9 @@
PASS Constructing a CSSSkew with a double throws a TypeError
PASS Constructing a CSSSkew with a unitless zero throws a TypeError
PASS Constructing a CSSSkew with a string angle throws a TypeError
-FAIL Constructing a CSSSkew with a number CSSUnitValue throws a TypeError assert_throws_js: function "() => new CSSSkew(value, CSS.deg(0))" did not throw
-FAIL Constructing a CSSSkew with a time dimension CSSUnitValue throws a TypeError assert_throws_js: function "() => new CSSSkew(value, CSS.deg(0))" did not throw
-FAIL Constructing a CSSSkew with a CSSMathValue of length type throws a TypeError assert_throws_js: function "() => new CSSSkew(value, CSS.deg(0))" did not throw
+PASS Constructing a CSSSkew with a number CSSUnitValue throws a TypeError
+PASS Constructing a CSSSkew with a time dimension CSSUnitValue throws a TypeError
+PASS Constructing a CSSSkew with a CSSMathValue of length type throws a TypeError
PASS Updating CSSSkew.ax with a keyword throws a TypeError
PASS Updating CSSSkew.ax with a double throws a TypeError
PASS Updating CSSSkew.ax with a unitless zero throws a TypeError
@@ -20,10 +20,10 @@
FAIL Updating CSSSkew.ay with a number CSSUnitValue throws a TypeError assert_throws_js: function "() => skew[attr] = value" did not throw
FAIL Updating CSSSkew.ay with a time dimension CSSUnitValue throws a TypeError assert_throws_js: function "() => skew[attr] = value" did not throw
FAIL Updating CSSSkew.ay with a CSSMathValue of length type throws a TypeError assert_throws_js: function "() => skew[attr] = value" did not throw
-FAIL CSSSkew can be constructed from an angle CSSUnitValue and an angle CSSUnitValue assert_true: expected true got false
-FAIL CSSSkew can be constructed from an angle CSSUnitValue and a CSSMathValue of angle type assert_true: expected true got false
-FAIL CSSSkew can be constructed from a CSSMathValue of angle type and an angle CSSUnitValue assert_true: expected true got false
-FAIL CSSSkew can be constructed from a CSSMathValue of angle type and a CSSMathValue of angle type assert_true: expected true got false
+PASS CSSSkew can be constructed from an angle CSSUnitValue and an angle CSSUnitValue
+PASS CSSSkew can be constructed from an angle CSSUnitValue and a CSSMathValue of angle type
+PASS CSSSkew can be constructed from a CSSMathValue of angle type and an angle CSSUnitValue
+PASS CSSSkew can be constructed from a CSSMathValue of angle type and a CSSMathValue of angle type
PASS CSSSkew.ax can be updated to an angle CSSUnitValue
PASS CSSSkew.ax can be updated to a CSSMathValue of angle type
PASS CSSSkew.ay can be updated to an angle CSSUnitValue
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssSkewX.tentative-expected.txt (293004 => 293005)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssSkewX.tentative-expected.txt 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssSkewX.tentative-expected.txt 2022-04-19 02:45:51 UTC (rev 293005)
@@ -3,9 +3,9 @@
PASS Constructing a CSSSkewX with a double throws a TypeError
PASS Constructing a CSSSkewX with a unitless zero throws a TypeError
PASS Constructing a CSSSkewX with a string angle throws a TypeError
-FAIL Constructing a CSSSkewX with a number CSSUnitValue throws a TypeError assert_throws_js: function "() => new CSSSkewX(value)" did not throw
-FAIL Constructing a CSSSkewX with a time dimension CSSUnitValue throws a TypeError assert_throws_js: function "() => new CSSSkewX(value)" did not throw
-FAIL Constructing a CSSSkewX with a CSSMathValue of length type throws a TypeError assert_throws_js: function "() => new CSSSkewX(value)" did not throw
+PASS Constructing a CSSSkewX with a number CSSUnitValue throws a TypeError
+PASS Constructing a CSSSkewX with a time dimension CSSUnitValue throws a TypeError
+PASS Constructing a CSSSkewX with a CSSMathValue of length type throws a TypeError
PASS Updating CSSSkewX.ax with a keyword throws a TypeError
PASS Updating CSSSkewX.ax with a double throws a TypeError
PASS Updating CSSSkewX.ax with a unitless zero throws a TypeError
@@ -13,8 +13,8 @@
FAIL Updating CSSSkewX.ax with a number CSSUnitValue throws a TypeError assert_throws_js: function "() => skewX.ax = value" did not throw
FAIL Updating CSSSkewX.ax with a time dimension CSSUnitValue throws a TypeError assert_throws_js: function "() => skewX.ax = value" did not throw
FAIL Updating CSSSkewX.ax with a CSSMathValue of length type throws a TypeError assert_throws_js: function "() => skewX.ax = value" did not throw
-FAIL CSSSkewX can be constructed from an angle CSSUnitValue assert_true: expected true got false
-FAIL CSSSkewX can be constructed from a CSSMathValue of angle type assert_true: expected true got false
+PASS CSSSkewX can be constructed from an angle CSSUnitValue
+PASS CSSSkewX can be constructed from a CSSMathValue of angle type
PASS CSSSkew.ax can be updated to an angle CSSUnitValue
PASS CSSSkew.ax can be updated to a CSSMathValue of angle type
FAIL Modifying skewX.is2D is a no-op assert_true: expected true got false
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssSkewY.tentative-expected.txt (293004 => 293005)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssSkewY.tentative-expected.txt 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssSkewY.tentative-expected.txt 2022-04-19 02:45:51 UTC (rev 293005)
@@ -3,9 +3,9 @@
PASS Constructing a CSSSkewY with a double throws a TypeError
PASS Constructing a CSSSkewY with a unitless zero throws a TypeError
PASS Constructing a CSSSkewY with a string angle throws a TypeError
-FAIL Constructing a CSSSkewY with a number CSSUnitValue throws a TypeError assert_throws_js: function "() => new CSSSkewY(value)" did not throw
-FAIL Constructing a CSSSkewY with a time dimension CSSUnitValue throws a TypeError assert_throws_js: function "() => new CSSSkewY(value)" did not throw
-FAIL Constructing a CSSSkewY with a CSSMathValue of length type throws a TypeError assert_throws_js: function "() => new CSSSkewY(value)" did not throw
+PASS Constructing a CSSSkewY with a number CSSUnitValue throws a TypeError
+PASS Constructing a CSSSkewY with a time dimension CSSUnitValue throws a TypeError
+PASS Constructing a CSSSkewY with a CSSMathValue of length type throws a TypeError
PASS Updating CSSSkewY.ay with a keyword throws a TypeError
PASS Updating CSSSkewY.ay with a double throws a TypeError
PASS Updating CSSSkewY.ay with a unitless zero throws a TypeError
@@ -13,8 +13,8 @@
FAIL Updating CSSSkewY.ay with a number CSSUnitValue throws a TypeError assert_throws_js: function "() => skewY.ay = value" did not throw
FAIL Updating CSSSkewY.ay with a time dimension CSSUnitValue throws a TypeError assert_throws_js: function "() => skewY.ay = value" did not throw
FAIL Updating CSSSkewY.ay with a CSSMathValue of length type throws a TypeError assert_throws_js: function "() => skewY.ay = value" did not throw
-FAIL CSSSkewY can be constructed from an angle CSSUnitValue assert_true: expected true got false
-FAIL CSSSkewY can be constructed from a CSSMathValue of angle type assert_true: expected true got false
+PASS CSSSkewY can be constructed from an angle CSSUnitValue
+PASS CSSSkewY can be constructed from a CSSMathValue of angle type
PASS CSSSkewY.ay can be updated to an angle CSSUnitValue
PASS CSSSkewY.ay can be updated to a CSSMathValue of angle type
FAIL Modifying skewY.is2D is a no-op assert_true: expected true got false
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssTransformValue.tentative-expected.txt (293004 => 293005)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssTransformValue.tentative-expected.txt 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssTransformValue.tentative-expected.txt 2022-04-19 02:45:51 UTC (rev 293005)
@@ -1,10 +1,10 @@
-FAIL Constructing a CSSTransformValue with no components throws TypeError assert_throws_js: function "() => new CSSTransformValue([])" did not throw
+PASS Constructing a CSSTransformValue with no components throws TypeError
PASS CSSTransformValue can be constructed with multiple transforms
PASS CSSTransformValue.set correctly sets the CSSTransformComponent at the given index
-FAIL Setting a component in CSSTransformValue correctly appends the CSSTransformComponent if index specified is greater than length Index 3 exceeds the range of CSSTransformValue.
+PASS Setting a component in CSSTransformValue correctly appends the CSSTransformComponent if index specified is greater than length
PASS CSSTransformValue.is2D is false when given mix of 2D and 3D transforms
-FAIL CSSTransformValue.is2D is true when given only 2D transforms assert_equals: expected true but got false
-FAIL CSSTransformValue.is2D is readonly assert_equals: expected true but got false
+PASS CSSTransformValue.is2D is true when given only 2D transforms
+PASS CSSTransformValue.is2D is readonly
PASS Can iterate through CSSTransformValue components
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssTranslate.tentative-expected.txt (293004 => 293005)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssTranslate.tentative-expected.txt 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssTranslate.tentative-expected.txt 2022-04-19 02:45:51 UTC (rev 293005)
@@ -1,6 +1,6 @@
-FAIL Constructing a CSSTranslate with a CSSUnitValue with type other than length or percent for the coordinates throws a TypeError assert_throws_js: function "() => new CSSTranslate(coord, CSS.px(0), CSS.px(0))" did not throw
-FAIL Constructing a CSSTranslate with a CSSMathValue that doesn't match <length-percentage> for the coordinates throws a TypeError assert_throws_js: function "() => new CSSTranslate(coord, CSS.px(0), CSS.px(0))" did not throw
+PASS Constructing a CSSTranslate with a CSSUnitValue with type other than length or percent for the coordinates throws a TypeError
+PASS Constructing a CSSTranslate with a CSSMathValue that doesn't match <length-percentage> for the coordinates throws a TypeError
FAIL Constructing a CSSTranslate with a percent for the Z coordinate throws a TypeError assert_throws_js: function "() => new CSSTranslate(CSS.px(0), CSS.px(0), CSS.percent(0))" did not throw
PASS Updating CSSTranslate.x to a CSSUnitValue with type other than length or percent throws a TypeError
PASS Updating CSSTranslate.x to a CSSMathValue that doesn't match <length-percentage> throws a TypeError
@@ -9,9 +9,9 @@
PASS Updating CSSTranslate.z to a CSSUnitValue with type other than length or percent throws a TypeError
PASS Updating CSSTranslate.z to a CSSMathValue that doesn't match <length-percentage> throws a TypeError
FAIL Updating CSSTranslate.z to a percent throws a TypeError assert_throws_js: function "() => result.z = CSS.percent(0)" did not throw
-FAIL CSSTranslate can be constructed from two length or percent coordinates assert_equals: expected object "0px" but got null
+PASS CSSTranslate can be constructed from two length or percent coordinates
PASS CSSTranslate can be constructed from three length or percent coordinates
-FAIL CSSTranslate can be constructed from CSSMathValues assert_equals: expected object "0px" but got null
+PASS CSSTranslate can be constructed from CSSMathValues
PASS CSSTranslate.x can be updated to a length
PASS CSSTranslate.x can be updated to a percent
PASS CSSTranslate.x can be updated to a CSSMathValue
Modified: trunk/Source/WebCore/ChangeLog (293004 => 293005)
--- trunk/Source/WebCore/ChangeLog 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/ChangeLog 2022-04-19 02:45:51 UTC (rev 293005)
@@ -1,3 +1,68 @@
+2022-04-18 Alex Christensen <[email protected]>
+
+ Implement CSSTransformValue.is2D
+ https://bugs.webkit.org/show_bug.cgi?id=239462
+
+ Reviewed by Simon Fraser.
+
+ This is an off-by-default feature.
+ Covered by WPT tests.
+
+ * bindings/js/JSCSSTransformComponentCustom.cpp:
+ (WebCore::toJSNewlyCreated):
+ * css/typedom/CSSNumericValue.cpp:
+ (WebCore::CSSNumericValue::rectifyNumberish):
+ * css/typedom/CSSNumericValue.h:
+ * css/typedom/numeric/CSSNumericType.h:
+ (WebCore::CSSNumericType::valueForType const):
+ (WebCore::CSSNumericType::nonZeroEntryCount const):
+ (WebCore::CSSNumericType::matches const):
+ (WebCore::CSSNumericType::matchesNumber const):
+ * css/typedom/transform/CSSMatrixComponent.cpp:
+ (WebCore::CSSMatrixComponent::create):
+ (WebCore::CSSMatrixComponent::CSSMatrixComponent):
+ * css/typedom/transform/CSSMatrixComponent.h:
+ (WebCore::CSSMatrixComponent::create): Deleted.
+ * css/typedom/transform/CSSMatrixComponent.idl:
+ * css/typedom/transform/CSSRotate.cpp:
+ (WebCore::CSSRotate::create):
+ (WebCore::CSSRotate::CSSRotate):
+ (WebCore::CSSRotate::setX):
+ (WebCore::CSSRotate::setY):
+ (WebCore::CSSRotate::setZ):
+ (WebCore::CSSRotate::setAngle):
+ * css/typedom/transform/CSSRotate.h:
+ (WebCore::CSSRotate::x):
+ (WebCore::CSSRotate::y):
+ (WebCore::CSSRotate::z):
+ (WebCore::CSSRotate::setX): Deleted.
+ (WebCore::CSSRotate::setY): Deleted.
+ (WebCore::CSSRotate::setZ): Deleted.
+ (WebCore::CSSRotate::setAngle): Deleted.
+ * css/typedom/transform/CSSScale.cpp:
+ (WebCore::CSSScale::create):
+ (WebCore::CSSScale::CSSScale):
+ * css/typedom/transform/CSSScale.h:
+ (WebCore::CSSScale::x const):
+ (WebCore::CSSScale::y const):
+ (WebCore::CSSScale::z const):
+ (WebCore::CSSScale::x): Deleted.
+ (WebCore::CSSScale::y): Deleted.
+ (WebCore::CSSScale::z): Deleted.
+ * css/typedom/transform/CSSTransformComponent.cpp:
+ (WebCore::CSSTransformComponent::toString const):
+ (WebCore::CSSTransformComponent::toMatrix): Deleted.
+ * css/typedom/transform/CSSTransformComponent.h:
+ (WebCore::CSSTransformComponent::CSSTransformComponent):
+ (WebCore::CSSTransformComponent::getType const): Deleted.
+ * css/typedom/transform/CSSTransformValue.cpp:
+ (WebCore::CSSTransformValue::create):
+ (WebCore::CSSTransformValue::setItem):
+ (WebCore::CSSTransformValue::is2D const):
+ (WebCore::CSSTransformValue::setIs2D): Deleted.
+ * css/typedom/transform/CSSTransformValue.h:
+ * css/typedom/transform/CSSTranslate.h:
+
2022-04-18 Chris Dumez <[email protected]>
Use convertToASCIILowercase() less and more SortedArrayMap / SortedArraySet
Modified: trunk/Source/WebCore/bindings/js/JSCSSTransformComponentCustom.cpp (293004 => 293005)
--- trunk/Source/WebCore/bindings/js/JSCSSTransformComponentCustom.cpp 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/bindings/js/JSCSSTransformComponentCustom.cpp 2022-04-19 02:45:51 UTC (rev 293005)
@@ -44,8 +44,6 @@
JSValue toJSNewlyCreated(JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<CSSTransformComponent>&& value)
{
switch (value->getType()) {
- case CSSTransformType::Transform:
- return createWrapper<CSSTransformComponent>(globalObject, WTFMove(value));
case CSSTransformType::MatrixComponent:
return createWrapper<CSSMatrixComponent>(globalObject, WTFMove(value));
case CSSTransformType::Perspective:
Modified: trunk/Source/WebCore/css/typedom/CSSKeywordValue.cpp (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/CSSKeywordValue.cpp 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/CSSKeywordValue.cpp 2022-04-19 02:45:51 UTC (rev 293005)
@@ -39,6 +39,17 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(CSSKeywordValue);
+Ref<CSSKeywordValue> CSSKeywordValue::rectifyKeywordish(CSSKeywordish&& keywordish)
+{
+ // https://drafts.css-houdini.org/css-typed-om/#rectify-a-keywordish-value
+ return WTF::switchOn(WTFMove(keywordish), [] (String string) {
+ return adoptRef(*new CSSKeywordValue(string));
+ }, [] (RefPtr<CSSKeywordValue> value) {
+ RELEASE_ASSERT(value);
+ return value.releaseNonNull();
+ });
+}
+
ExceptionOr<Ref<CSSKeywordValue>> CSSKeywordValue::create(const String& value)
{
if (value.isEmpty())
Modified: trunk/Source/WebCore/css/typedom/CSSKeywordValue.h (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/CSSKeywordValue.h 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/CSSKeywordValue.h 2022-04-19 02:45:51 UTC (rev 293005)
@@ -34,6 +34,8 @@
namespace WebCore {
template<typename> class ExceptionOr;
+class CSSKeywordValue;
+using CSSKeywordish = std::variant<String, RefPtr<CSSKeywordValue>>;
class CSSKeywordValue final : public CSSStyleValue {
WTF_MAKE_ISO_ALLOCATED(CSSKeywordValue);
@@ -44,6 +46,9 @@
ExceptionOr<void> setValue(const String&);
CSSStyleValueType getType() const final { return CSSStyleValueType::CSSKeywordValue; }
+
+ static Ref<CSSKeywordValue> rectifyKeywordish(CSSKeywordish&&);
+
private:
explicit CSSKeywordValue(const String& value)
: m_value(value) { }
Modified: trunk/Source/WebCore/css/typedom/numeric/CSSNumericType.h (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/numeric/CSSNumericType.h 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/numeric/CSSNumericType.h 2022-04-19 02:45:51 UTC (rev 293005)
@@ -77,6 +77,11 @@
RELEASE_ASSERT_NOT_REACHED();
}
+ const std::optional<long>& valueForType(CSSNumericBaseType type) const
+ {
+ return const_cast<CSSNumericType*>(this)->valueForType(type);
+ }
+
void applyPercentHint(CSSNumericBaseType hint)
{
// https://drafts.css-houdini.org/css-typed-om/#apply-the-percent-hint
@@ -88,6 +93,41 @@
percentHint = hint;
}
+ size_t nonZeroEntryCount() const
+ {
+ size_t count { 0 };
+ count += length && *length;
+ count += angle && *angle;
+ count += time && *time;
+ count += frequency && *frequency;
+ count += resolution && *resolution;
+ count += flex && *flex;
+ count += percent && *percent;
+ return count;
+ }
+
+ template<CSSNumericBaseType type>
+ bool matches() const
+ {
+ // https://drafts.css-houdini.org/css-typed-om/#cssnumericvalue-match
+ return (type == CSSNumericBaseType::Percent || !percentHint)
+ && nonZeroEntryCount() == 1
+ && valueForType(type)
+ && *valueForType(type);
+ }
+
+ bool matchesNumber() const
+ {
+ // https://drafts.css-houdini.org/css-typed-om/#cssnumericvalue-match
+ return !nonZeroEntryCount() && !percentHint;
+ }
+
+ template<CSSNumericBaseType type>
+ bool matchesTypeOrPercentage() const
+ {
+ return matches<type>() || matches<CSSNumericBaseType::Percent>();
+ }
+
String debugString() const
{
return makeString("{",
Modified: trunk/Source/WebCore/css/typedom/transform/CSSMatrixComponent.cpp (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSMatrixComponent.cpp 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSMatrixComponent.cpp 2022-04-19 02:45:51 UTC (rev 293005)
@@ -41,14 +41,14 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(CSSMatrixComponent);
-Ref<CSSTransformComponent> CSSMatrixComponent::create(Ref<DOMMatrixReadOnly>&& matrix, CSSMatrixComponentOptions&& options)
+Ref<CSSTransformComponent> CSSMatrixComponent::create(Ref<DOMMatrixReadOnly>&& matrix, std::optional<CSSMatrixComponentOptions>&& options)
{
return adoptRef(*new CSSMatrixComponent(WTFMove(matrix), WTFMove(options)));
}
-CSSMatrixComponent::CSSMatrixComponent(Ref<DOMMatrixReadOnly>&& matrix, CSSMatrixComponentOptions&& options)
- : m_matrix(matrix->cloneAsDOMMatrix())
- , m_options(WTFMove(options))
+CSSMatrixComponent::CSSMatrixComponent(Ref<DOMMatrixReadOnly>&& matrix, std::optional<CSSMatrixComponentOptions>&& options)
+ : CSSTransformComponent((options ? options->is2D : matrix->is2D()) ? Is2D::Yes : Is2D::No)
+ , m_matrix(matrix->cloneAsDOMMatrix())
{
}
Modified: trunk/Source/WebCore/css/typedom/transform/CSSMatrixComponent.h (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSMatrixComponent.h 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSMatrixComponent.h 2022-04-19 02:45:51 UTC (rev 293005)
@@ -39,7 +39,7 @@
class CSSMatrixComponent : public CSSTransformComponent {
WTF_MAKE_ISO_ALLOCATED(CSSMatrixComponent);
public:
- static Ref<CSSTransformComponent> create(Ref<DOMMatrixReadOnly>&& matrix, CSSMatrixComponentOptions&& options = CSSMatrixComponentOptions { });
+ static Ref<CSSTransformComponent> create(Ref<DOMMatrixReadOnly>&&, std::optional<CSSMatrixComponentOptions>&&);
DOMMatrix& matrix();
void setMatrix(Ref<DOMMatrix>&&);
@@ -49,9 +49,8 @@
CSSTransformType getType() const final { return CSSTransformType::MatrixComponent; }
private:
- CSSMatrixComponent(Ref<DOMMatrixReadOnly>&&, CSSMatrixComponentOptions&&);
+ CSSMatrixComponent(Ref<DOMMatrixReadOnly>&&, std::optional<CSSMatrixComponentOptions>&&);
Ref<DOMMatrix> m_matrix;
- CSSMatrixComponentOptions m_options;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/css/typedom/transform/CSSMatrixComponent.idl (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSMatrixComponent.idl 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSMatrixComponent.idl 2022-04-19 02:45:51 UTC (rev 293005)
@@ -29,6 +29,9 @@
Conditional=CSS_TYPED_OM,
Exposed=(Window,Worker,PaintWorklet),
] interface CSSMatrixComponent : CSSTransformComponent {
+ // FIXME: when the second parameter is missing or not a dictionary,
+ // CSSMatrixComponent::create is not called with std::nullopt in the generated bindings code.
+ // Doing so would fix the remaining failures in the cssMatrixComponent.tentative test.
constructor(DOMMatrixReadOnly matrix, optional CSSMatrixComponentOptions options);
attribute DOMMatrix matrix;
Modified: trunk/Source/WebCore/css/typedom/transform/CSSPerspective.cpp (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSPerspective.cpp 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSPerspective.cpp 2022-04-19 02:45:51 UTC (rev 293005)
@@ -32,6 +32,7 @@
#if ENABLE(CSS_TYPED_OM)
+#include "CSSKeywordValue.h"
#include "DOMMatrix.h"
#include "ExceptionOr.h"
#include <wtf/IsoMallocInlines.h>
@@ -40,16 +41,53 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(CSSPerspective);
-Ref<CSSPerspective> CSSPerspective::create(Ref<CSSNumericValue>&& length)
+static ExceptionOr<CSSPerspectiveValue> checkLength(CSSPerspectiveValue length)
{
- return adoptRef(*new CSSPerspective(WTFMove(length)));
+ // https://drafts.css-houdini.org/css-typed-om/#dom-cssperspective-cssperspective
+ auto checkKeywordValue = [] (RefPtr<CSSKeywordValue> value) -> ExceptionOr<CSSPerspectiveValue> {
+ RELEASE_ASSERT(value);
+ if (!equalIgnoringASCIICase(value->value(), "none"))
+ return Exception { TypeError };
+ return { WTFMove(value) };
+ };
+ return WTF::switchOn(WTFMove(length),
+ [] (RefPtr<CSSNumericValue> value) -> ExceptionOr<CSSPerspectiveValue> {
+ if (value && !value->type().matches<CSSNumericBaseType::Length>())
+ return Exception { TypeError };
+ return { WTFMove(value) };
+ }, [&] (String value) {
+ return checkKeywordValue(CSSKeywordValue::rectifyKeywordish(WTFMove(value)));
+ }, checkKeywordValue);
}
-CSSPerspective::CSSPerspective(Ref<CSSNumericValue>&& length)
- : m_length(WTFMove(length))
+ExceptionOr<Ref<CSSPerspective>> CSSPerspective::create(CSSPerspectiveValue length)
{
+ auto checkedLength = checkLength(WTFMove(length));
+ if (checkedLength.hasException())
+ return checkedLength.releaseException();
+ return adoptRef(*new CSSPerspective(checkedLength.releaseReturnValue()));
}
+CSSPerspective::CSSPerspective(CSSPerspectiveValue length)
+ : CSSTransformComponent(Is2D::No)
+ , m_length(WTFMove(length))
+{
+}
+
+ExceptionOr<void> CSSPerspective::setLength(CSSPerspectiveValue length)
+{
+ auto checkedLength = checkLength(WTFMove(length));
+ if (checkedLength.hasException())
+ return checkedLength.releaseException();
+ m_length = checkedLength.releaseReturnValue();
+ return { };
+}
+
+void CSSPerspective::setIs2D(bool)
+{
+ // https://drafts.css-houdini.org/css-typed-om/#dom-cssperspective-is2d says to do nothing here.
+}
+
// FIXME: Fix all the following virtual functions
String CSSPerspective::toString() const
Modified: trunk/Source/WebCore/css/typedom/transform/CSSPerspective.h (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSPerspective.h 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSPerspective.h 2022-04-19 02:45:51 UTC (rev 293005)
@@ -33,14 +33,16 @@
namespace WebCore {
template<typename> class ExceptionOr;
+class CSSKeywordValue;
+using CSSPerspectiveValue = std::variant<RefPtr<CSSNumericValue>, String, RefPtr<CSSKeywordValue>>;
class CSSPerspective : public CSSTransformComponent {
WTF_MAKE_ISO_ALLOCATED(CSSPerspective);
public:
- static Ref<CSSPerspective> create(Ref<CSSNumericValue>&& length);
+ static ExceptionOr<Ref<CSSPerspective>> create(CSSPerspectiveValue);
- CSSNumericValue& length() { return m_length.get(); }
- void setLength(Ref<CSSNumericValue>&& length) { m_length = WTFMove(length); }
+ const CSSPerspectiveValue& length() const { return m_length; }
+ ExceptionOr<void> setLength(CSSPerspectiveValue);
String toString() const final;
ExceptionOr<Ref<DOMMatrix>> toMatrix() final;
@@ -48,9 +50,11 @@
CSSTransformType getType() const final { return CSSTransformType::Perspective; }
private:
- CSSPerspective(Ref<CSSNumericValue>&& length);
-
- Ref<CSSNumericValue> m_length;
+ CSSPerspective(CSSPerspectiveValue);
+
+ void setIs2D(bool);
+
+ CSSPerspectiveValue m_length;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/css/typedom/transform/CSSPerspective.idl (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSPerspective.idl 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSPerspective.idl 2022-04-19 02:45:51 UTC (rev 293005)
@@ -23,6 +23,9 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+typedef (DOMString or CSSKeywordValue) CSSKeywordish;
+typedef (CSSNumericValue or CSSKeywordish) CSSPerspectiveValue;
+
// https://drafts.css-houdini.org/css-typed-om/#cssperspective
[
EnabledBySetting=CSSTypedOMEnabled,
@@ -29,7 +32,7 @@
Conditional=CSS_TYPED_OM,
Exposed=(Window,Worker,PaintWorklet)
] interface CSSPerspective : CSSTransformComponent {
- constructor(CSSNumericValue length);
+ constructor(CSSPerspectiveValue length);
- attribute CSSNumericValue length;
+ attribute CSSPerspectiveValue length;
};
Modified: trunk/Source/WebCore/css/typedom/transform/CSSRotate.cpp (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSRotate.cpp 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSRotate.cpp 2022-04-19 02:45:51 UTC (rev 293005)
@@ -32,6 +32,8 @@
#if ENABLE(CSS_TYPED_OM)
+#include "CSSUnitValue.h"
+#include "CSSUnits.h"
#include "DOMMatrix.h"
#include "ExceptionOr.h"
#include <wtf/IsoMallocInlines.h>
@@ -40,18 +42,37 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(CSSRotate);
-Ref<CSSRotate> CSSRotate::create(CSSNumberish&& x, CSSNumberish&& y, CSSNumberish&& z, Ref<CSSNumericValue>&& angle)
+ExceptionOr<Ref<CSSRotate>> CSSRotate::create(CSSNumberish x, CSSNumberish y, CSSNumberish z, Ref<CSSNumericValue> angle)
{
- return adoptRef(*new CSSRotate(WTFMove(x), WTFMove(y), WTFMove(z), WTFMove(angle)));
+ if (!angle->type().matches<CSSNumericBaseType::Angle>())
+ return Exception { TypeError };
+
+ auto rectifiedX = CSSNumericValue::rectifyNumberish(WTFMove(x));
+ auto rectifiedY = CSSNumericValue::rectifyNumberish(WTFMove(y));
+ auto rectifiedZ = CSSNumericValue::rectifyNumberish(WTFMove(z));
+
+ if (!rectifiedX->type().matchesNumber()
+ || !rectifiedY->type().matchesNumber()
+ || !rectifiedZ->type().matchesNumber())
+ return Exception { TypeError };
+
+ return adoptRef(*new CSSRotate(Is2D::No, WTFMove(rectifiedX), WTFMove(rectifiedY), WTFMove(rectifiedZ), WTFMove(angle)));
}
-Ref<CSSRotate> CSSRotate::create(Ref<CSSNumericValue>&& angle)
+ExceptionOr<Ref<CSSRotate>> CSSRotate::create(Ref<CSSNumericValue> angle)
{
- return adoptRef(*new CSSRotate(0.0, 0.0, 0.0, WTFMove(angle)));
+ if (!angle->type().matches<CSSNumericBaseType::Angle>())
+ return Exception { TypeError };
+ return adoptRef(*new CSSRotate(Is2D::Yes,
+ CSSUnitValue::create(0.0, CSSUnitType::CSS_NUMBER),
+ CSSUnitValue::create(0.0, CSSUnitType::CSS_NUMBER),
+ CSSUnitValue::create(1.0, CSSUnitType::CSS_NUMBER),
+ WTFMove(angle)));
}
-CSSRotate::CSSRotate(CSSNumberish&& x, CSSNumberish&& y, CSSNumberish&& z, Ref<CSSNumericValue>&& angle)
- : m_x(WTFMove(x))
+CSSRotate::CSSRotate(CSSTransformComponent::Is2D is2D, Ref<CSSNumericValue> x, Ref<CSSNumericValue> y, Ref<CSSNumericValue> z, Ref<CSSNumericValue> angle)
+ : CSSTransformComponent(is2D)
+ , m_x(WTFMove(x))
, m_y(WTFMove(y))
, m_z(WTFMove(z))
, m_angle(WTFMove(angle))
@@ -58,6 +79,41 @@
{
}
+ExceptionOr<void> CSSRotate::setX(CSSNumberish x)
+{
+ auto rectified = CSSNumericValue::rectifyNumberish(WTFMove(x));
+ if (!rectified->type().matchesNumber())
+ return Exception { TypeError };
+ m_x = WTFMove(rectified);
+ return { };
+}
+
+ExceptionOr<void> CSSRotate::setY(CSSNumberish y)
+{
+ auto rectified = CSSNumericValue::rectifyNumberish(WTFMove(y));
+ if (!rectified->type().matchesNumber())
+ return Exception { TypeError };
+ m_y = WTFMove(rectified);
+ return { };
+}
+
+ExceptionOr<void> CSSRotate::setZ(CSSNumberish z)
+{
+ auto rectified = CSSNumericValue::rectifyNumberish(WTFMove(z));
+ if (!rectified->type().matchesNumber())
+ return Exception { TypeError };
+ m_z = WTFMove(rectified);
+ return { };
+}
+
+ExceptionOr<void> CSSRotate::setAngle(Ref<CSSNumericValue> angle)
+{
+ if (!angle->type().matches<CSSNumericBaseType::Angle>())
+ return Exception { TypeError };
+ m_angle = WTFMove(angle);
+ return { };
+}
+
// FIXME: Fix all the following virtual functions
String CSSRotate::toString() const
Modified: trunk/Source/WebCore/css/typedom/transform/CSSRotate.h (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSRotate.h 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSRotate.h 2022-04-19 02:45:51 UTC (rev 293005)
@@ -37,19 +37,19 @@
class CSSRotate : public CSSTransformComponent {
WTF_MAKE_ISO_ALLOCATED(CSSRotate);
public:
- static Ref<CSSRotate> create(CSSNumberish&&, CSSNumberish&&, CSSNumberish&&, Ref<CSSNumericValue>&&);
- static Ref<CSSRotate> create(Ref<CSSNumericValue>&&);
+ static ExceptionOr<Ref<CSSRotate>> create(CSSNumberish, CSSNumberish, CSSNumberish, Ref<CSSNumericValue>);
+ static ExceptionOr<Ref<CSSRotate>> create(Ref<CSSNumericValue>);
- const CSSNumberish& x() { return m_x; }
- const CSSNumberish& y() { return m_x; }
- const CSSNumberish& z() { return m_x; }
+ CSSNumberish x() { return { m_x.ptr() }; }
+ CSSNumberish y() { return { m_y.ptr() }; }
+ CSSNumberish z() { return { m_z.ptr() }; }
const CSSNumericValue& angle() { return m_angle.get(); }
-
- void setX(CSSNumberish&& x) { m_x = WTFMove(x); }
- void setY(CSSNumberish&& y) { m_y = WTFMove(y); }
- void setZ(CSSNumberish&& z) { m_z = WTFMove(z); }
- void setAngle(Ref<CSSNumericValue>&& angle) { m_angle = WTFMove(angle); }
-
+
+ ExceptionOr<void> setX(CSSNumberish);
+ ExceptionOr<void> setY(CSSNumberish);
+ ExceptionOr<void> setZ(CSSNumberish);
+ ExceptionOr<void> setAngle(Ref<CSSNumericValue>);
+
String toString() const final;
ExceptionOr<Ref<DOMMatrix>> toMatrix() final;
@@ -56,11 +56,11 @@
CSSTransformType getType() const final { return CSSTransformType::Rotate; }
private:
- CSSRotate(CSSNumberish&&, CSSNumberish&&, CSSNumberish&&, Ref<CSSNumericValue>&&);
+ CSSRotate(CSSTransformComponent::Is2D, Ref<CSSNumericValue>, Ref<CSSNumericValue>, Ref<CSSNumericValue>, Ref<CSSNumericValue>);
- CSSNumberish m_x;
- CSSNumberish m_y;
- CSSNumberish m_z;
+ Ref<CSSNumericValue> m_x;
+ Ref<CSSNumericValue> m_y;
+ Ref<CSSNumericValue> m_z;
Ref<CSSNumericValue> m_angle;
};
Modified: trunk/Source/WebCore/css/typedom/transform/CSSScale.cpp (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSScale.cpp 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSScale.cpp 2022-04-19 02:45:51 UTC (rev 293005)
@@ -32,6 +32,8 @@
#if ENABLE(CSS_TYPED_OM)
+#include "CSSUnitValue.h"
+#include "CSSUnits.h"
#include "DOMMatrix.h"
#include "ExceptionOr.h"
#include <wtf/IsoMallocInlines.h>
@@ -40,18 +42,44 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(CSSScale);
-Ref<CSSScale> CSSScale::create(CSSNumberish&& x, CSSNumberish&& y, std::optional<CSSNumberish>&& z)
+ExceptionOr<Ref<CSSScale>> CSSScale::create(CSSNumberish x, CSSNumberish y, std::optional<CSSNumberish> z)
{
- return adoptRef(*new CSSScale(WTFMove(x), WTFMove(y), WTFMove(z)));
+ auto rectifiedX = CSSNumericValue::rectifyNumberish(WTFMove(x));
+ auto rectifiedY = CSSNumericValue::rectifyNumberish(WTFMove(y));
+ auto rectifiedZ = z ? CSSNumericValue::rectifyNumberish(WTFMove(*z)) : Ref<CSSNumericValue> { CSSUnitValue::create(1.0, CSSUnitType::CSS_NUMBER) };
+
+ // https://drafts.css-houdini.org/css-typed-om/#dom-cssscale-cssscale
+ if (!rectifiedX->type().matchesNumber()
+ || !rectifiedY->type().matchesNumber()
+ || (!rectifiedZ->type().matchesNumber()))
+ return Exception { TypeError };
+
+ return adoptRef(*new CSSScale(z ? Is2D::No : Is2D::Yes, WTFMove(rectifiedX), WTFMove(rectifiedY), WTFMove(rectifiedZ)));
}
-CSSScale::CSSScale(CSSNumberish&& x, CSSNumberish&& y, std::optional<CSSNumberish>&& z)
- : m_x(WTFMove(x))
+CSSScale::CSSScale(CSSTransformComponent::Is2D is2D, Ref<CSSNumericValue> x, Ref<CSSNumericValue> y, Ref<CSSNumericValue> z)
+ : CSSTransformComponent(is2D)
+ , m_x(WTFMove(x))
, m_y(WTFMove(y))
, m_z(WTFMove(z))
{
}
+void CSSScale::setX(CSSNumberish x)
+{
+ m_x = CSSNumericValue::rectifyNumberish(WTFMove(x));
+}
+
+void CSSScale::setY(CSSNumberish y)
+{
+ m_y = CSSNumericValue::rectifyNumberish(WTFMove(y));
+}
+
+void CSSScale::setZ(CSSNumberish z)
+{
+ m_z = CSSNumericValue::rectifyNumberish(WTFMove(z));
+}
+
// FIXME: Fix all the following virtual functions
String CSSScale::toString() const
Modified: trunk/Source/WebCore/css/typedom/transform/CSSScale.h (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSScale.h 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSScale.h 2022-04-19 02:45:51 UTC (rev 293005)
@@ -37,27 +37,27 @@
class CSSScale : public CSSTransformComponent {
WTF_MAKE_ISO_ALLOCATED(CSSScale);
public:
- static Ref<CSSScale> create(CSSNumberish&& x, CSSNumberish&& y, std::optional<CSSNumberish>&& z);
+ static ExceptionOr<Ref<CSSScale>> create(CSSNumberish x, CSSNumberish y, std::optional<CSSNumberish> z);
String toString() const final;
ExceptionOr<Ref<DOMMatrix>> toMatrix() final;
-
- CSSNumberish x() { return m_x; }
- CSSNumberish y() { return m_y; }
- CSSNumberish z() { return m_z ? *m_z : 0.0; }
- void setX(CSSNumberish&& x) { m_x = WTFMove(x); }
- void setY(CSSNumberish&& y) { m_y = WTFMove(y); }
- void setZ(CSSNumberish&& z) { m_z = WTFMove(z); }
+ CSSNumberish x() const { return m_x.ptr(); }
+ CSSNumberish y() const { return m_y.ptr(); }
+ CSSNumberish z() const { return m_z.ptr(); }
+ void setX(CSSNumberish);
+ void setY(CSSNumberish);
+ void setZ(CSSNumberish);
+
CSSTransformType getType() const final { return CSSTransformType::Scale; }
private:
- CSSScale(CSSNumberish&& x, CSSNumberish&& y, std::optional<CSSNumberish>&& z);
-
- CSSNumberish m_x;
- CSSNumberish m_y;
- std::optional<CSSNumberish> m_z;
+ CSSScale(CSSTransformComponent::Is2D, Ref<CSSNumericValue>, Ref<CSSNumericValue>, Ref<CSSNumericValue>);
+
+ Ref<CSSNumericValue> m_x;
+ Ref<CSSNumericValue> m_y;
+ Ref<CSSNumericValue> m_z;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/css/typedom/transform/CSSSkew.cpp (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSSkew.cpp 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSSkew.cpp 2022-04-19 02:45:51 UTC (rev 293005)
@@ -40,13 +40,17 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(CSSSkew);
-Ref<CSSSkew> CSSSkew::create(Ref<CSSNumericValue>&& ax, Ref<CSSNumericValue>&& ay)
+ExceptionOr<Ref<CSSSkew>> CSSSkew::create(Ref<CSSNumericValue> ax, Ref<CSSNumericValue> ay)
{
+ if (!ax->type().matches<CSSNumericBaseType::Angle>()
+ || !ay->type().matches<CSSNumericBaseType::Angle>())
+ return Exception { TypeError };
return adoptRef(*new CSSSkew(WTFMove(ax), WTFMove(ay)));
}
-CSSSkew::CSSSkew(Ref<CSSNumericValue>&& ax, Ref<CSSNumericValue>&& ay)
- : m_ax(WTFMove(ax))
+CSSSkew::CSSSkew(Ref<CSSNumericValue> ax, Ref<CSSNumericValue> ay)
+ : CSSTransformComponent(Is2D::Yes)
+ , m_ax(WTFMove(ax))
, m_ay(WTFMove(ay))
{
}
Modified: trunk/Source/WebCore/css/typedom/transform/CSSSkew.h (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSSkew.h 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSSkew.h 2022-04-19 02:45:51 UTC (rev 293005)
@@ -37,13 +37,13 @@
class CSSSkew : public CSSTransformComponent {
WTF_MAKE_ISO_ALLOCATED(CSSSkew);
public:
- static Ref<CSSSkew> create(Ref<CSSNumericValue>&&, Ref<CSSNumericValue>&&);
+ static ExceptionOr<Ref<CSSSkew>> create(Ref<CSSNumericValue>, Ref<CSSNumericValue>);
- CSSNumericValue& ax() { return m_ax.get(); }
- CSSNumericValue& ay() { return m_ay.get(); }
+ const CSSNumericValue& ax() const { return m_ax.get(); }
+ const CSSNumericValue& ay() const { return m_ay.get(); }
- void setAx(Ref<CSSNumericValue>&& ax) { m_ax = WTFMove(ax); }
- void setAy(Ref<CSSNumericValue>&& ay) { m_ay = WTFMove(ay); }
+ void setAx(Ref<CSSNumericValue> ax) { m_ax = WTFMove(ax); }
+ void setAy(Ref<CSSNumericValue> ay) { m_ay = WTFMove(ay); }
String toString() const final;
ExceptionOr<Ref<DOMMatrix>> toMatrix() final;
@@ -51,7 +51,7 @@
CSSTransformType getType() const final { return CSSTransformType::Skew; }
private:
- CSSSkew(Ref<CSSNumericValue>&& ax, Ref<CSSNumericValue>&& ay);
+ CSSSkew(Ref<CSSNumericValue> ax, Ref<CSSNumericValue> ay);
Ref<CSSNumericValue> m_ax;
Ref<CSSNumericValue> m_ay;
Modified: trunk/Source/WebCore/css/typedom/transform/CSSSkewX.cpp (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSSkewX.cpp 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSSkewX.cpp 2022-04-19 02:45:51 UTC (rev 293005)
@@ -40,13 +40,16 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(CSSSkewX);
-Ref<CSSSkewX> CSSSkewX::create(Ref<CSSNumericValue>&& ax)
+ExceptionOr<Ref<CSSSkewX>> CSSSkewX::create(Ref<CSSNumericValue> ax)
{
+ if (!ax->type().matches<CSSNumericBaseType::Angle>())
+ return Exception { TypeError };
return adoptRef(*new CSSSkewX(WTFMove(ax)));
}
-CSSSkewX::CSSSkewX(Ref<CSSNumericValue>&& ax)
- : m_ax(WTFMove(ax))
+CSSSkewX::CSSSkewX(Ref<CSSNumericValue> ax)
+ : CSSTransformComponent(Is2D::Yes)
+ , m_ax(WTFMove(ax))
{
}
Modified: trunk/Source/WebCore/css/typedom/transform/CSSSkewX.h (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSSkewX.h 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSSkewX.h 2022-04-19 02:45:51 UTC (rev 293005)
@@ -37,10 +37,10 @@
class CSSSkewX : public CSSTransformComponent {
WTF_MAKE_ISO_ALLOCATED(CSSSkewX);
public:
- static Ref<CSSSkewX> create(Ref<CSSNumericValue>&& ax);
+ static ExceptionOr<Ref<CSSSkewX>> create(Ref<CSSNumericValue>);
- CSSNumericValue& ax() { return m_ax.get(); }
- void setAx(Ref<CSSNumericValue>&& ax) { m_ax = WTFMove(ax); }
+ const CSSNumericValue& ax() const { return m_ax.get(); }
+ void setAx(Ref<CSSNumericValue> ax) { m_ax = WTFMove(ax); }
String toString() const final;
ExceptionOr<Ref<DOMMatrix>> toMatrix() final;
@@ -48,7 +48,7 @@
CSSTransformType getType() const final { return CSSTransformType::SkewX; }
private:
- CSSSkewX(Ref<CSSNumericValue>&& ax);
+ CSSSkewX(Ref<CSSNumericValue> ax);
Ref<CSSNumericValue> m_ax;
};
Modified: trunk/Source/WebCore/css/typedom/transform/CSSSkewY.cpp (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSSkewY.cpp 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSSkewY.cpp 2022-04-19 02:45:51 UTC (rev 293005)
@@ -40,13 +40,16 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(CSSSkewY);
-Ref<CSSSkewY> CSSSkewY::create(Ref<CSSNumericValue>&& ay)
+ExceptionOr<Ref<CSSSkewY>> CSSSkewY::create(Ref<CSSNumericValue> ay)
{
+ if (!ay->type().matches<CSSNumericBaseType::Angle>())
+ return Exception { TypeError };
return adoptRef(*new CSSSkewY(WTFMove(ay)));
}
-CSSSkewY::CSSSkewY(Ref<CSSNumericValue>&& ay)
- : m_ay(WTFMove(ay))
+CSSSkewY::CSSSkewY(Ref<CSSNumericValue> ay)
+ : CSSTransformComponent(Is2D::Yes)
+ , m_ay(WTFMove(ay))
{
}
Modified: trunk/Source/WebCore/css/typedom/transform/CSSSkewY.h (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSSkewY.h 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSSkewY.h 2022-04-19 02:45:51 UTC (rev 293005)
@@ -37,10 +37,10 @@
class CSSSkewY : public CSSTransformComponent {
WTF_MAKE_ISO_ALLOCATED(CSSSkewY);
public:
- static Ref<CSSSkewY> create(Ref<CSSNumericValue>&&);
+ static ExceptionOr<Ref<CSSSkewY>> create(Ref<CSSNumericValue>);
- CSSNumericValue& ay() { return m_ay.get(); }
- void setAy(Ref<CSSNumericValue>&& ay) { m_ay = WTFMove(ay); }
+ const CSSNumericValue& ay() const { return m_ay.get(); }
+ void setAy(Ref<CSSNumericValue> ay) { m_ay = WTFMove(ay); }
String toString() const final;
ExceptionOr<Ref<DOMMatrix>> toMatrix() final;
@@ -48,7 +48,7 @@
CSSTransformType getType() const final { return CSSTransformType::SkewY; }
private:
- CSSSkewY(Ref<CSSNumericValue>&& ay);
+ CSSSkewY(Ref<CSSNumericValue> ay);
Ref<CSSNumericValue> m_ay;
};
Modified: trunk/Source/WebCore/css/typedom/transform/CSSTransformComponent.cpp (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSTransformComponent.cpp 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSTransformComponent.cpp 2022-04-19 02:45:51 UTC (rev 293005)
@@ -38,20 +38,12 @@
namespace WebCore {
-WTF_MAKE_ISO_ALLOCATED_IMPL(CSSTransformComponent);
-
-// FIXME: Fix all the following virtual functions
-
String CSSTransformComponent::toString() const
{
+ // FIXME: implement.
return emptyString();
}
-ExceptionOr<Ref<DOMMatrix>> CSSTransformComponent::toMatrix()
-{
- return DOMMatrix::fromMatrix(DOMMatrixInit { });
-}
-
} // namespace WebCore
#endif
Modified: trunk/Source/WebCore/css/typedom/transform/CSSTransformComponent.h (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSTransformComponent.h 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSTransformComponent.h 2022-04-19 02:45:51 UTC (rev 293005)
@@ -34,7 +34,6 @@
namespace WebCore {
enum class CSSTransformType : uint8_t {
- Transform,
MatrixComponent,
Perspective,
Rotate,
@@ -49,17 +48,20 @@
template<typename> class ExceptionOr;
class CSSTransformComponent : public RefCounted<CSSTransformComponent> {
- WTF_MAKE_ISO_ALLOCATED(CSSTransformComponent);
+protected:
+ enum class Is2D : bool { No, Yes };
+ CSSTransformComponent(Is2D is2D)
+ : m_is2D(is2D) { }
public:
virtual String toString() const;
- bool is2D() const { return m_is2D; }
- void setIs2D(bool is2D) { m_is2D = is2D; }
- virtual ExceptionOr<Ref<DOMMatrix>> toMatrix();
+ bool is2D() const { return m_is2D == Is2D::Yes; }
+ virtual void setIs2D(bool is2D) { m_is2D = is2D ? Is2D::Yes : Is2D::No; }
+ virtual ExceptionOr<Ref<DOMMatrix>> toMatrix() = 0;
virtual ~CSSTransformComponent() = default;
- virtual CSSTransformType getType() const { return CSSTransformType::Transform; }
+ virtual CSSTransformType getType() const = 0;
private:
- bool m_is2D { false };
+ Is2D m_is2D;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/css/typedom/transform/CSSTransformValue.cpp (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSTransformValue.cpp 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSTransformValue.cpp 2022-04-19 02:45:51 UTC (rev 293005)
@@ -35,6 +35,7 @@
#include "CSSTransformComponent.h"
#include "DOMMatrix.h"
#include "ExceptionOr.h"
+#include <wtf/Algorithms.h>
#include <wtf/IsoMallocInlines.h>
#include <wtf/text/WTFString.h>
@@ -42,8 +43,11 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(CSSTransformValue);
-Ref<CSSTransformValue> CSSTransformValue::create(Vector<RefPtr<CSSTransformComponent>>&& transforms)
+ExceptionOr<Ref<CSSTransformValue>> CSSTransformValue::create(Vector<RefPtr<CSSTransformComponent>>&& transforms)
{
+ // https://drafts.css-houdini.org/css-typed-om/#dom-csstransformvalue-csstransformvalue
+ if (transforms.isEmpty())
+ return Exception { TypeError };
return adoptRef(*new CSSTransformValue(WTFMove(transforms)));
}
@@ -57,24 +61,25 @@
ExceptionOr<RefPtr<CSSTransformComponent>> CSSTransformValue::setItem(size_t index, Ref<CSSTransformComponent>&& value)
{
- if (index >= m_components.size())
+ if (index > m_components.size())
return Exception { RangeError, makeString("Index ", index, " exceeds the range of CSSTransformValue.") };
-
- m_components[index] = WTFMove(value);
+ if (index == m_components.size())
+ m_components.append(WTFMove(value));
+ else
+ m_components[index] = WTFMove(value);
+
return RefPtr<CSSTransformComponent> { m_components[index] };
}
bool CSSTransformValue::is2D() const
{
- return m_is2D;
+ // https://drafts.css-houdini.org/css-typed-om/#dom-csstransformvalue-is2d
+ return WTF::allOf(m_components, [] (auto& component) {
+ return component && component->is2D();
+ });
}
-void CSSTransformValue::setIs2D(bool is2D)
-{
- m_is2D = is2D;
-}
-
ExceptionOr<Ref<DOMMatrix>> CSSTransformValue::toMatrix()
{
// FIXME: add correct behavior here.
Modified: trunk/Source/WebCore/css/typedom/transform/CSSTransformValue.h (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSTransformValue.h 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSTransformValue.h 2022-04-19 02:45:51 UTC (rev 293005)
@@ -40,7 +40,7 @@
class CSSTransformValue final : public CSSStyleValue {
WTF_MAKE_ISO_ALLOCATED(CSSTransformValue);
public:
- static Ref<CSSTransformValue> create(Vector<RefPtr<CSSTransformComponent>>&& transforms);
+ static ExceptionOr<Ref<CSSTransformValue>> create(Vector<RefPtr<CSSTransformComponent>>&&);
size_t length() const { return m_components.size(); }
ExceptionOr<RefPtr<CSSTransformComponent>> item(size_t);
@@ -47,7 +47,6 @@
ExceptionOr<RefPtr<CSSTransformComponent>> setItem(size_t, Ref<CSSTransformComponent>&&);
bool is2D() const;
- void setIs2D(bool);
ExceptionOr<Ref<DOMMatrix>> toMatrix();
@@ -55,7 +54,6 @@
private:
CSSTransformValue(Vector<RefPtr<CSSTransformComponent>>&&);
- bool m_is2D { false };
Vector<RefPtr<CSSTransformComponent>> m_components;
};
Modified: trunk/Source/WebCore/css/typedom/transform/CSSTranslate.cpp (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSTranslate.cpp 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSTranslate.cpp 2022-04-19 02:45:51 UTC (rev 293005)
@@ -33,6 +33,8 @@
#if ENABLE(CSS_TYPED_OM)
#include "CSSNumericValue.h"
+#include "CSSUnitValue.h"
+#include "CSSUnits.h"
#include "DOMMatrix.h"
#include "ExceptionOr.h"
#include <wtf/IsoMallocInlines.h>
@@ -41,13 +43,23 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(CSSTranslate);
-Ref<CSSTranslate> CSSTranslate::create(Ref<CSSNumericValue>&& x, Ref<CSSNumericValue>&& y, RefPtr<CSSNumericValue>&& z)
+ExceptionOr<Ref<CSSTranslate>> CSSTranslate::create(Ref<CSSNumericValue> x, Ref<CSSNumericValue> y, RefPtr<CSSNumericValue> z)
{
- return adoptRef(*new CSSTranslate(WTFMove(x), WTFMove(y), WTFMove(z)));
+ auto is2D = z ? CSSTransformComponent::Is2D::No : CSSTransformComponent::Is2D::Yes;
+ if (!z)
+ z = CSSUnitValue::create(0.0, CSSUnitType::CSS_PX);
+
+ if (!x->type().matchesTypeOrPercentage<CSSNumericBaseType::Length>()
+ || !y->type().matchesTypeOrPercentage<CSSNumericBaseType::Length>()
+ || !z->type().matchesTypeOrPercentage<CSSNumericBaseType::Length>())
+ return Exception { TypeError };
+
+ return adoptRef(*new CSSTranslate(is2D, WTFMove(x), WTFMove(y), z.releaseNonNull()));
}
-CSSTranslate::CSSTranslate(Ref<CSSNumericValue>&& x, Ref<CSSNumericValue>&& y, RefPtr<CSSNumericValue>&& z)
- : m_x(WTFMove(x))
+CSSTranslate::CSSTranslate(CSSTransformComponent::Is2D is2D, Ref<CSSNumericValue> x, Ref<CSSNumericValue> y, Ref<CSSNumericValue> z)
+ : CSSTransformComponent(is2D)
+ , m_x(WTFMove(x))
, m_y(WTFMove(y))
, m_z(WTFMove(z))
{
Modified: trunk/Source/WebCore/css/typedom/transform/CSSTranslate.h (293004 => 293005)
--- trunk/Source/WebCore/css/typedom/transform/CSSTranslate.h 2022-04-19 00:54:23 UTC (rev 293004)
+++ trunk/Source/WebCore/css/typedom/transform/CSSTranslate.h 2022-04-19 02:45:51 UTC (rev 293005)
@@ -37,25 +37,27 @@
class CSSTranslate : public CSSTransformComponent {
WTF_MAKE_ISO_ALLOCATED(CSSTranslate);
public:
- static Ref<CSSTranslate> create(Ref<CSSNumericValue>&&, Ref<CSSNumericValue>&&, RefPtr<CSSNumericValue>&&);
+ static ExceptionOr<Ref<CSSTranslate>> create(Ref<CSSNumericValue> x, Ref<CSSNumericValue> y, RefPtr<CSSNumericValue> z);
- Ref<CSSNumericValue> x() { return m_x; }
- Ref<CSSNumericValue> y() { return m_y; }
- RefPtr<CSSNumericValue> z() { return m_z; }
+ const CSSNumericValue& x() const { return m_x.get(); }
+ const CSSNumericValue& y() const { return m_y.get(); }
+ const CSSNumericValue& z() const { return m_z.get(); }
- void setX(Ref<CSSNumericValue>&& x) { m_x = WTFMove(x); }
- void setY(Ref<CSSNumericValue>&& y) { m_y = WTFMove(y); }
- void setZ(Ref<CSSNumericValue>&& z) { m_z = WTFMove(z); }
+ void setX(Ref<CSSNumericValue> x) { m_x = WTFMove(x); }
+ void setY(Ref<CSSNumericValue> y) { m_y = WTFMove(y); }
+ void setZ(Ref<CSSNumericValue> z) { m_z = WTFMove(z); }
String toString() const final;
ExceptionOr<Ref<DOMMatrix>> toMatrix() final;
private:
- CSSTranslate(Ref<CSSNumericValue>&&, Ref<CSSNumericValue>&&, RefPtr<CSSNumericValue>&&);
-
+ CSSTranslate(CSSTransformComponent::Is2D, Ref<CSSNumericValue>, Ref<CSSNumericValue>, Ref<CSSNumericValue>);
+
+ CSSTransformType getType() const final { return CSSTransformType::Translate; }
+
Ref<CSSNumericValue> m_x;
Ref<CSSNumericValue> m_y;
- RefPtr<CSSNumericValue> m_z;
+ Ref<CSSNumericValue> m_z;
};
} // namespace WebCore