WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
REOPENED
40414
Fetching inline style gives different matrix for rotate(90deg) than getComputedStyle
https://bugs.webkit.org/show_bug.cgi?id=40414
Summary
Fetching inline style gives different matrix for rotate(90deg) than getComput...
Dirk Schulze
Reported
2010-06-10 03:26:23 PDT
Created
attachment 58354
[details]
Test case CSS Transforms rotate(90deg) make's responing matrix uninvertvible. See alert on attached text. Matrix is 0,1,-1,0,0,0
Attachments
Test case
(417 bytes, text/html)
2010-06-10 03:26 PDT
,
Dirk Schulze
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Simon Fraser (smfr)
Comment 1
2010-06-10 07:04:15 PDT
I don't see a test for the matrix being uninvertible.
Dirk Schulze
Comment 2
2010-06-10 07:17:48 PDT
(In reply to
comment #1
)
> I don't see a test for the matrix being uninvertible.
I get (0,1,-1,0,0,0). That means a = d = 0. Do you get somthing different?
Dirk Schulze
Comment 3
2010-06-10 07:45:02 PDT
But I get correct values with getComputedStyle.
Dirk Schulze
Comment 4
2010-06-10 07:58:37 PDT
The calculation was correct, sorry. A rotation of 90deg means that 'a' gets cos(90/180*pi) and cos(pi/2) is 0.
Simon Fraser (smfr)
Comment 5
2010-06-10 09:25:10 PDT
I don't know why getComputedStyle would return a different value in this case. Reopening this bug to figure out why fetching inline style gives a different answer.
Dirk Schulze
Comment 6
2010-06-10 09:37:33 PDT
(In reply to
comment #5
)
> I don't know why getComputedStyle would return a different value in this case. Reopening this bug to figure out why fetching inline style gives a different answer.
The difference is not quite big matrix(1,77321e-16, 1, -1, 1,77321e-16, 0, 0) to matrix(0,000000, 1,000000, -1,000000, 0,000000, 0,000000, 0,000000). With different code paths: getComputedStyle: var parent = document.getElementById('parent'); var matrix = window.getComputedStyle(parent).webkitTransform; alert(matrix); inline style: var firstMatrix = new WebKitCSSMatrix(document.getElementById('parent').style.webkitTransform); alert(firstMatrix);
Chris Marrin
Comment 7
2010-06-11 08:28:36 PDT
Those two matrices are, for all intents and purposes, identical. The only difference is rounding. The source of the rounding error may be one of the several places we use single precision floating point numbers in TransformationMatrix::rotate3d(). All the use of single precision in this file is a holdover from when the matrix itself was single precision. None of the uses of single precision here seem dangerous. I think they will all up-convert before being used. And the numbers are all 1.0f or 2.0f, which I believe are exactly represented in single precision. But there may be places where single precision math is being performed. It could also be just general precision loss. We need to convert to radians, which is inherently lossy. But this seems like greater loss than that. Finally, there could be places outside the TransformationMatrix code where the values could be getting shortened. But that seems unlikely for 90 degrees, since we store rotation values in degrees directly in the style declaration. So there's no conversion there. At any rate, all the use of single precision in TransformationMatrix should be removed.
Ahmad Saleem
Comment 8
2022-07-23 05:48:55 PDT
Based on attached test cases - I get following values across browsers: Safari 15.6 - transform: matrix(6.123233995736766e-17, 1, -1, 6.123233995736766e-17, 0, 0) Chrome Canary 106 - transform: matrix(6.123233995736766e-17, 1, -1, 6.123233995736766e-17, 0, 0) Firefox Nightly 104 - transform: matrix(2.220446049250313e-16, 1, -1, 2.220446049250313e-16, 0, 0) Safari and Firefox match each other but differ from Firefox Nightly slightly. Just wanted to share updated results as of today. Thanks!
Brent Fulgham
Comment 9
2022-07-23 16:11:58 PDT
Seems like this warrants some investigation. Thank you for testing!
Radar WebKit Bug Importer
Comment 10
2022-07-23 16:12:08 PDT
<
rdar://problem/97496245
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug