From 82886237353a69ba378c6800d3cd69178067a6bd Mon Sep 17 00:00:00 2001 From: Darren Shen Date: Wed, 31 Jan 2018 10:09:53 +1100 Subject: [PATCH 1/2] Add CSSTransformComponent.is2D --- css-typed-om/Overview.bs | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/css-typed-om/Overview.bs b/css-typed-om/Overview.bs index bb2daadd..72a77ba1 100644 --- a/css-typed-om/Overview.bs +++ b/css-typed-om/Overview.bs @@ -1997,16 +1997,11 @@ is a [=list=] of {{CSSTransformComponent}}s. 2. [=list/For each=] |func| in |this|’s [=values to iterate over=]: - 1. Let |funcMatrix| be |func|’s equivalent 4x4 transform matrix, - as defined in [[css-transforms-1#mathematical-description]]. - - As the entries of such a matrix are defined relative to the ''px'' unit, - if any <>s in |func| involved in generating the matrix - are not [=compatible units=] with ''px'', - [=throw=] a {{TypeError}}. + 1. Let |funcMatrix| be the {{DOMMatrix}} returned by + calling {{CSSTransformComponent/toMatrix()}} on |func|. 2. Set |matrix| to the result of multiplying |matrix| - and |funcMatrix|. - 3. If |func|’s {{CSSTransformComponent/is2D}} internal slot is `false`, + and the matrix represented by |funcMatrix|. + 3. If |funcMatrix|’s {{DOMMatrix/is2D}} internal slot is `false`, set |is2D| to `false`. 3. Return a new {{DOMMatrix}} @@ -2019,6 +2014,7 @@ is a [=list=] of {{CSSTransformComponent}}s. interface CSSTransformComponent { stringifier; attribute boolean is2D; + DOMMatrix toMatrix(); }; [Constructor(CSSNumericValue x, CSSNumericValue y, optional CSSNumericValue z)] @@ -2099,6 +2095,30 @@ is a [=list=] of {{CSSTransformComponent}}s. but also prevents "accidentally" flipping a 2D transform into becoming 3D. +
+ The toMatrix() method of a {{CSSTransformComponent}} |this| must, + when called, + perform the following steps: + + 1. Let |is2D| be a boolean initially set to `true`. + + 2. Let |matrix| be |this|’s equivalent 4x4 transform matrix, + as defined in [[css-transforms-1#mathematical-description]]. + + As the entries of such a matrix are defined relative to the ''px'' unit, + if any <>s in |this| involved in generating the matrix + are not [=compatible units=] with ''px'', + [=throw=] a {{TypeError}}. + + 3. If |this|’s {{CSSTransformComponent/is2D}} internal slot is `false`, + set |is2D| to `false`. + + 3. Return a new {{DOMMatrix}} + representing |matrix|, + and with its internal [=matrix/is 2D=] flag set to |is2D|. +
+ +
The CSSTranslate(|x|, |y|, |z|) constructor must, when invoked, From ed5dc0672f20d2f03f5cb5722049dbedb8865c4f Mon Sep 17 00:00:00 2001 From: Tab Atkins Jr Date: Tue, 30 Jan 2018 16:31:17 -0800 Subject: [PATCH 2/2] Simplify is2D handling. --- css-typed-om/Overview.bs | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/css-typed-om/Overview.bs b/css-typed-om/Overview.bs index 72a77ba1..f32655bb 100644 --- a/css-typed-om/Overview.bs +++ b/css-typed-om/Overview.bs @@ -1991,9 +1991,9 @@ is a [=list=] of {{CSSTransformComponent}}s. when called, perform the following steps: - 1. Let |matrix| be a 4x4 matrix, - initially set to the identity matrix. - Let |is2D| be a boolean initially set to `true`. + 1. Let |matrix| be a new {{DOMMatrix}}, + initialized to the identity matrix, + with its {{DOMMatrix/is2D}} internal slot set to `true`. 2. [=list/For each=] |func| in |this|’s [=values to iterate over=]: @@ -2001,12 +2001,8 @@ is a [=list=] of {{CSSTransformComponent}}s. calling {{CSSTransformComponent/toMatrix()}} on |func|. 2. Set |matrix| to the result of multiplying |matrix| and the matrix represented by |funcMatrix|. - 3. If |funcMatrix|’s {{DOMMatrix/is2D}} internal slot is `false`, - set |is2D| to `false`. - 3. Return a new {{DOMMatrix}} - representing |matrix|, - and with its internal [=matrix/is 2D=] flag set to |is2D|. + 3. Return |matrix|.
@@ -2100,22 +2096,24 @@ is a [=list=] of {{CSSTransformComponent}}s. when called, perform the following steps: - 1. Let |is2D| be a boolean initially set to `true`. - - 2. Let |matrix| be |this|’s equivalent 4x4 transform matrix, - as defined in [[css-transforms-1#mathematical-description]]. + 1. Let |matrix| be a new {{DOMMatrix}} object, + initialized to |this|’s equivalent 4x4 transform matrix, + as defined in [[css-transforms-1#mathematical-description]], + and with its {{DOMMatrixReadOnly/is2D}} internal slot + set to the same value as |this|'s {{CSSTransformComponent/is2D}} internal slot. + + Note: Recall that the {{CSSTransformComponent/is2D}} flag + affects what transform, + and thus what equivalent matrix, + a {{CSSTransformComponent}} represents. As the entries of such a matrix are defined relative to the ''px'' unit, if any <>s in |this| involved in generating the matrix - are not [=compatible units=] with ''px'', + are not [=compatible units=] with ''px'' + (such as [=relative lengths=] or [=percentages=]), [=throw=] a {{TypeError}}. - 3. If |this|’s {{CSSTransformComponent/is2D}} internal slot is `false`, - set |is2D| to `false`. - - 3. Return a new {{DOMMatrix}} - representing |matrix|, - and with its internal [=matrix/is 2D=] flag set to |is2D|. + 2. Return |matrix|.