Closed Bug 1245242 Opened 9 years ago Closed 9 years ago

WebKitCSSMatrix.rotateAxisAngle not compatible with WebKit's

Categories

(Core :: DOM: CSS Object Model, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla47
Tracking Status
firefox47 --- fixed

People

(Reporter: miketaylr, Assigned: wchen)

References

Details

(Whiteboard: dom-triaged)

Attachments

(1 file)

We don't produce the same output as WebKit/Blink for the following: m = new WebKitCSSMatrix(); m2 = m.rotateAxisAngle(0.707, 0.707, 0.707, 45); (from https://github.com/WebKit/webkit/blob/master/LayoutTests/transforms/cssmatrix-3d-interface.xhtml#L405) A few options: 1) File the bug on the Geometry spec, and fix this when we update our DOMMatrix(ReadOnly) implementation (will file a bug and link it) -- if the editors decide to change it there. 2) Fix this now, and file a bug on the Geometry spec FWIW, there seems to be very little web content relying on this. I found a few demos that look slightly different, but not broken in terms of functionality, e.g., http://smagch.github.io/demo/css3-transform-centering-demo.html (compare the 3d effect in Chrome on first load). And there's only a few hundred results in GitHub's search results (not scientific, but Here's the algorithm that WebKit uses: https://github.com/WebKit/webkit/blob/c753ad6d11a3df2436de4e7d41e1d111221283aa/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp#L797-L882 Here's a JS port: https://github.com/beastaugh/firmin/blob/2b468fb0cd5ed5a273d1fe73184a7e4224b1da40/src/matrix.js#L463
I'm curious what you think of the options above, wchen.
Flags: needinfo?(wchen)
Oops, left this link out https://github.com/WebKit/webkit/blob/master/Source/WebCore/css/WebKitCSSMatrix.cpp#L160-L176. This contains the if x, y, z are 0 then z = 1 bit before calling rotate3d.
I think if we need to update DOMMatrix and DOMMatrixReadOnly at some point in the future anyways, we should pick #1. I'm interested to see if we get any bug reports about these differences in the wild as well.
Whiteboard: dom-noted
Or, if we made rotateAxisAngle(x, y, z, angle) the result of returning a new WebKitCSSMatrix that does something this: WebKitCSSMatrix('rotate3d(' + x + ',' + y + ',' + z + ',' + angle + 'deg)') we get the results we want.
The issue here is that DOMMatrix and Gecko's WebKitCSSMatrix does not normalize the vector to a unit vector for the rotateAxisAngle matrix. Safari, Chrome and our implementation of the transform property do the normalization. The spec [1] should explicitly say to normalize the vector to a unit vector. I will work on a patch to add this for DOMMatrix (and by extension WebKitCSSMatrix). [1] https://www.w3.org/TR/css-transforms-1/#funcdef-rotate3d
Assignee: nobody → wchen
Flags: needinfo?(wchen)
I'll file a spec issue, thanks!
Down in https://www.w3.org/TR/css-transforms-1/#interpolation-of-transform-functions, it says "The transform functions matrix(), matrix3d() and perspective() get converted into 4x4 matrices first and interpolated as defined in section Interpolation of Matrices afterwards. For interpolations with the primitive rotate3d(), the direction vectors of the transform functions get normalized first. If the normalized vectors are equal, the rotation angle gets interpolated numerically." But I filed https://www.w3.org/Bugs/Public/show_bug.cgi?id=29417 to be more explicit.
I factored out an axis angle rotation matrix method that uses a normalized vector and updated DOMMatrix and ProcessRotate3D in nsStyleTransformMatrix to call the new method.
Attachment #8715567 - Flags: review?(roc)
Awesome, you rock wchen (confirmed on an inbound build this makes us compatible with existing implementations).
Whiteboard: dom-noted → dom-triaged
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: