Skip to content

Commit 72d9e39

Browse files
darrnshntabatkins
authored andcommitted
Add CSSTransformComponent.is2D (#614)
* Add CSSTransformComponent.is2D * Simplify is2D handling.
1 parent 09f859e commit 72d9e39

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

css-typed-om/Overview.bs

+34-16
Original file line numberDiff line numberDiff line change
@@ -2010,27 +2010,18 @@ is a [=list=] of {{CSSTransformComponent}}s.
20102010
when called,
20112011
perform the following steps:
20122012

2013-
1. Let |matrix| be a 4x4 matrix,
2014-
initially set to the identity matrix.
2015-
Let |is2D| be a boolean initially set to `true`.
2013+
1. Let |matrix| be a new {{DOMMatrix}},
2014+
initialized to the identity matrix,
2015+
with its {{DOMMatrix/is2D}} internal slot set to `true`.
20162016

20172017
2. [=list/For each=] |func| in |this|’s [=values to iterate over=]:
20182018

2019-
1. Let |funcMatrix| be |func|’s equivalent 4x4 transform matrix,
2020-
as defined in [[css-transforms-1#mathematical-description]].
2021-
2022-
As the entries of such a matrix are defined relative to the ''px'' unit,
2023-
if any <<length>>s in |func| involved in generating the matrix
2024-
are not [=compatible units=] with ''px'',
2025-
[=throw=] a {{TypeError}}.
2019+
1. Let |funcMatrix| be the {{DOMMatrix}} returned by
2020+
calling {{CSSTransformComponent/toMatrix()}} on |func|.
20262021
2. Set |matrix| to the result of multiplying |matrix|
2027-
and |funcMatrix|.
2028-
3. If |func|’s {{CSSTransformComponent/is2D}} internal slot is `false`,
2029-
set |is2D| to `false`.
2022+
and the matrix represented by |funcMatrix|.
20302023

2031-
3. Return a new {{DOMMatrix}}
2032-
representing |matrix|,
2033-
and with its internal [=matrix/is 2D=] flag set to |is2D|.
2024+
3. Return |matrix|.
20342025
</div>
20352026

20362027
The <dfn attribute for=CSSTransformValue>length</dfn> attribute indicates how many transform components are contained within the {{CSSTransformValue}}.
@@ -2041,6 +2032,7 @@ The <dfn for=CSSTransformValue>indexed getter</dfn> retrieves the transform comp
20412032
interface CSSTransformComponent {
20422033
stringifier;
20432034
attribute boolean is2D;
2035+
DOMMatrix toMatrix();
20442036
};
20452037

20462038
[Constructor(CSSNumericValue x, CSSNumericValue y, optional CSSNumericValue z)]
@@ -2121,6 +2113,32 @@ The <dfn for=CSSTransformValue>indexed getter</dfn> retrieves the transform comp
21212113
but also prevents "accidentally" flipping a 2D transform into becoming 3D.
21222114
</details>
21232115

2116+
<div algorithm="CSSTransformComponent.toMatrix()">
2117+
The <dfn method for=CSSTransformComponent>toMatrix()</dfn> method of a {{CSSTransformComponent}} |this| must,
2118+
when called,
2119+
perform the following steps:
2120+
2121+
1. Let |matrix| be a new {{DOMMatrix}} object,
2122+
initialized to |this|’s equivalent 4x4 transform matrix,
2123+
as defined in [[css-transforms-1#mathematical-description]],
2124+
and with its {{DOMMatrixReadOnly/is2D}} internal slot
2125+
set to the same value as |this|'s {{CSSTransformComponent/is2D}} internal slot.
2126+
2127+
Note: Recall that the {{CSSTransformComponent/is2D}} flag
2128+
affects what transform,
2129+
and thus what equivalent matrix,
2130+
a {{CSSTransformComponent}} represents.
2131+
2132+
As the entries of such a matrix are defined relative to the ''px'' unit,
2133+
if any <<length>>s in |this| involved in generating the matrix
2134+
are not [=compatible units=] with ''px''
2135+
(such as [=relative lengths=] or [=percentages=]),
2136+
[=throw=] a {{TypeError}}.
2137+
2138+
2. Return |matrix|.
2139+
</div>
2140+
2141+
21242142
<div algorithm="CSSTranslate()">
21252143
The <dfn constructor for=CSSTranslate>CSSTranslate(|x|, |y|, |z|)</dfn> constructor must,
21262144
when invoked,

0 commit comments

Comments
 (0)