- From: Joe Pea via GitHub <sysbot+gh@w3.org>
- Date: Fri, 27 Dec 2024 05:33:58 +0000
- To: public-fxtf-archive@w3.org
trusktr has just created a new issue for https://github.com/w3c/fxtf-drafts: == Improve algorithm steps for identity transforms == There's a discrepancy between browsers. This code: ```js new DOMMatrix().rotateAxisAngleSelf(1, 0, 0, 0).toString() ``` Outputs different values across browsers: - Firefox: `matrix(1, 0, 0, 1, 0, 0)` - Chrome, Safari, and Edge: `matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)` Technically all browsers except Firefox are "correct" because they do exactly what the spec says: 1. [Post-multiply](https://drafts.fxtf.org/geometry/#post-multiply) a rotation transformation on the current matrix around the specified vector _x, y, z_ by the specified rotation _angle_ in degrees. The 3D rotation matrix is [described](https://drafts.csswg.org/css-transforms-1/#RotateDefined) in CSS Transforms with _alpha_ = _angle_ in degrees. [[CSS3-TRANSFORMS]](https://drafts.fxtf.org/geometry/#biblio-css3-transforms) 2. If _x_ or _y_ are not 0 or -0, set [is 2D](https://drafts.fxtf.org/geometry/#matrix-is-2d) of the current matrix to `false`. 3. Return the current matrix. However, Firefox's behavior is better: if the rotation is zero, then nothing needs to be done, the `rotateAxisAngleSelf` method can return early to avoid unnecessary work, and in this case `is2D` should remain `true` because basically "nothing happened" due to the rotation being zero. I believe it would be best if the spec did the following, and maybe we can change the spec because browsers are not currently aligned, however it might be easier for a single browser (Firefox) to adopt the less desirable current spec behavior. Here's what I would change the algorithm steps to: 1. If _angle_ is 0 or -0 return the current matrix. 2. [Post-multiply](https://drafts.fxtf.org/geometry/#post-multiply) a rotation transformation on the current matrix around the specified vector _x, y, z_ by the specified rotation _angle_ in degrees. The 3D rotation matrix is [described](https://drafts.csswg.org/css-transforms-1/#RotateDefined) in CSS Transforms with _alpha_ = _angle_ in degrees. [[CSS3-TRANSFORMS]](https://drafts.fxtf.org/geometry/#biblio-css3-transforms) 3. If _x_ or _y_ are not 0 or -0, set [is 2D](https://drafts.fxtf.org/geometry/#matrix-is-2d) of the current matrix to `false`. 4. Return the current matrix. If "nothing happened", then there should be no effects, arbitrarily switching from 2D to 3D due to a zero-angle rotation is unnecessary. Please view or discuss this issue at https://github.com/w3c/fxtf-drafts/issues/579 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 05:33:59 UTC