- From: Joe Pea via GitHub <sysbot+gh@w3.org>
- Date: Fri, 27 Dec 2024 23:49:58 +0000
- To: public-fxtf-archive@w3.org
trusktr has just created a new issue for https://github.com/w3c/fxtf-drafts: == [geometry-1] There is no way to reset `DOMMatrix` `is2D` back to `true` when returning to identity. == For example, run this in any browser console: ```js function toIdentity(mat) { mat.m11 = 1 mat.m12 = 0 mat.m13 = 0 mat.m14 = 0 mat.m21 = 0 mat.m22 = 1 mat.m23 = 0 mat.m24 = 0 mat.m31 = 0 mat.m32 = 0 mat.m33 = 1 mat.m34 = 0 mat.m41 = 0 mat.m42 = 0 mat.m43 = 0 mat.m44 = 1 } const mat = new DOMMatrix() console.assert(mat.is2D) // passes mat.rotateSelf(10, 20, 30) console.assert(!mat.is2D) // passes toIdentity(mat) console.assert(mat.is2D) // fail! ``` The last assertion fails: ``` Assertion failed: expect is2D to be true ``` This makes it tricky to use a single `DOMMatrix` instance as an optimized cached value when avoiding mutation (instead of always creating new instances for calculations). For example, when we set the matrix back to identity, `is2D` should go back to `true`, that way any optimizations that rely on `if (mat.is2D)` can kick in again. If we can add more methods to `DOMMatrix`, for example as we've begun to ideate in - #194 one of them could be `mat.toIdentity()` which can set the internal `is2D` value to `true`. The hand-rolled `toIdentity` function above cannot set the private `is2D` state back to `true` from the outside. Besides adding `DOMMatrix.toIdentity`, another possibility is to expand the `set` steps for `m11` to `m44` such that if they receive `0` or `1`, they should check if `isIdentity` is `true`, and if so set `is2D` back to `true`. However this might be more expensive than relying on new `isIdentity` method which will unconditionally set `is2D` back to `true`. Please view or discuss this issue at https://github.com/w3c/fxtf-drafts/issues/584 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 27 December 2024 23:49:59 UTC