RESOLVED WORKSFORME 126844
Subpixel Layout: getComputedStyle rounds off fractional pixel values
https://bugs.webkit.org/show_bug.cgi?id=126844
Summary Subpixel Layout: getComputedStyle rounds off fractional pixel values
David DeSandro
Reported 2014-01-12 08:14:09 PST
See example http://codepen.io/desandro/pen/CEfJF The value of getComputedStyle( elem ).width is returned as 199px for an element that has CSS `width: 66.666%`, and it's parent element has `width: 300px`. Other browsers keep the fractional pixel value, i.e. 199.98px. I expected the value to either have the fractional pixel, or round up to the nearest integer, instead of rounding off any fractional pixel value. I imagine this behavior might be by design, as it 199px is the rendered width of the element, and it prevents rounding errors to overshoot the true value. That said, I thought it was worth documenting. I have found that using `calc()` values for `width` produces closer-to-expected values. So for that example, changing width to `calc( 100% * 2 /3 )` returns `200px`. See http://codepen.io/desandro/pen/CKwfd
Attachments
zalan
Comment 1 2014-01-19 18:27:47 PST
zalan
Comment 2 2014-06-10 19:56:06 PDT
getComputedStyle( box ).width now returns 199.984375px as expected. This has been fixed by one of the patches while transitioning to subpixel rendering.
Note You need to log in before you can comment on or make changes to this bug.