CSS floating-point values sometimes rounded to fewer than 6 decimals |
||||||||
Issue description
Example:
<!doctype HTML>
<div id=target style="width:123.456789px"></div>
<script>
onload = function() {
console.log(getComputedStyle(target).width);
}
</script>
prints 12.456px, rather than 12.456789px.
The spec requires up to 6: https://drafts.csswg.org/cssom/#serializing-css-values. In addition, LayoutUnit stores at a resolution of 1/64 px, which is exactly representable only with 6 digits.
,
Aug 26 2016
Sigh. printf does not support showing up to 6 decimals, but trimming trailing zeros. Some ideas are listed here: http://stackoverflow.com/questions/277772/avoid-trailing-zeroes-in-printf
,
Aug 26 2016
Seems too hard to so simply and safely.
,
Aug 26 2016
This bug's importance is that there is currently a loss of precision when reading the computed style of an element which has fractional CSS values.
,
Aug 29 2016
cc-ing Rob, who made some changes around here in the past (I think to align better with other browsers?)
,
Aug 29 2016
,
Aug 29 2016
Similar issue in firefox.
Data URL: data:text/html,<div id=target style="width:123.456789px"></div> <script> onload = function() { console.log(getComputedStyle(target).width); } </script>
,
Aug 29 2016
I am not sure the stated values in the example are correct, my current build gives me: 123.453px I guess the first value differs from the stated value (12.456px) because of the 1 / 64 precision. Though maybe there is a runtime flag I need to enable? BTW Firefox gives: 123.45px which also seems like a loss of precision.
,
Feb 13 2017
,
Oct 30 2017
,
Dec 6 2017
,
Feb 5 2018
Issue 808798 has been merged into this issue. |
||||||||
►
Sign in to add a comment |
||||||||
Comment 1 by chrishtr@chromium.org
, Aug 26 2016