Bug 126844
Summary: | Subpixel Layout: getComputedStyle rounds off fractional pixel values | ||
---|---|---|---|
Product: | WebKit | Reporter: | David DeSandro <desandrocodes> |
Component: | Layout and Rendering | Assignee: | 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: | Mac (Intel) | ||
OS: | Unspecified | ||
URL: | http://codepen.io/desandro/pen/CEfJF | ||
Bug Depends on: | |||
Bug Blocks: | 126283 |
David DeSandro
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
zalan
<rdar://problem/15855798>
zalan
getComputedStyle( box ).width now returns 199.984375px as expected. This has been fixed by one of the patches while transitioning to subpixel rendering.