Bug 126844

Summary: Subpixel Layout: getComputedStyle rounds off fractional pixel values
Product: WebKit Reporter: David DeSandro <desandrocodes>
Component: Layout and RenderingAssignee: zalan <zalan>
Status: RESOLVED WORKSFORME    
Severity: Normal CC: jonlee, mathias, m.goleb+bugzilla, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Macintosh Intel   
OS: Unspecified   
URL: http://codepen.io/desandro/pen/CEfJF
Bug Depends on:    
Bug Blocks: 126283    

Description David DeSandro 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
Comment 1 zalan 2014-01-19 18:27:47 PST
<rdar://problem/15855798>
Comment 2 zalan 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.