Open Bug 726630 Opened 13 years ago Updated 3 years ago

Small perspective()s are output inaccurately in getComputedStyle()

Categories

(Core :: CSS Parsing and Computation, defect)

x86
Linux
defect

Tracking

()

People

(Reporter: ayg, Unassigned)

Details

Test-case: data:text/html,<!doctype html> <script> document.documentElement.style.MozTransform = "perspective(0.12px)"; document.documentElement.textContent = getComputedStyle(document.documentElement).MozTransform; </script> Outputs "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -8.57143, 0, 0, 0, 1)". IE10 Developer Preview gives -8.33333, and Chrome 18 dev gives -8.333333519597852. The correct value is -1/0.12 = -8 1/3, so Gecko is off by quite a lot -- 0.25 or so. I'm guessing the perspective value is first translated into a length accurate only to 1/60th of a pixel, and only then is the reciprocal taken. Even better, if you specify a perspective of 0.001px, the matrix is "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, NaN, NaN, NaN, -Infinity, 0, 0, 0, 1)"!
> I'm guessing the perspective value is first translated into a length accurate only to > 1/60th of a pixel, and only then is the reciprocal taken. Almost certainly. 1/60 is 0.016666, so the closest multiple to 0.12 is 7/60, and 60/7 = 8.571428
This looks like it's baked pretty deeply into nsRuleNode.cpp. Unless there's some existing way to convert CSS lengths into floats instead of nscoords, it looks like it would take a significant amount of surgery to get this to work. Bug 719173 is related.
Severity: minor → S4
You need to log in before you can comment on or make changes to this bug.