New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 641379 link

Starred by 3 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

CSS floating-point values sometimes rounded to fewer than 6 decimals

Project Member Reported by chrishtr@chromium.org, Aug 26 2016

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.
 
Status: Started (was: Assigned)
Working on a simple fix w/my intern now.
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
Owner: ----
Status: Untriaged (was: Started)
Seems too hard to so simply and safely.
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.

Comment 5 by timloh@chromium.org, Aug 29 2016

Cc: rob.b...@samsung.com
cc-ing Rob, who made some changes around here in the past (I think to align better with other browsers?)

Comment 6 by samli@chromium.org, Aug 29 2016

Labels: -Pri-3 Pri-2
Status: Available (was: Untriaged)

Comment 7 by samli@chromium.org, Aug 29 2016

Labels: Hotlist-Polish
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>


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.
Labels: Update-Quarterly

Comment 10 by meade@chromium.org, Oct 30 2017

Labels: Code-Serialization ApproachableBug
Labels: -Update-Quarterly

Comment 12 by nainar@google.com, Feb 5 2018

 Issue 808798  has been merged into this issue.

Sign in to add a comment