Bug 147136 - offsetWidth for fractionally positioned elements returns different values depending on left position
Summary: offsetWidth for fractionally positioned elements returns different values dep...
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.10
: P2 Normal
Assignee: Nobody
URL: http://jsfiddle.net/sbel/sykrLf2u/6/
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-20 19:12 PDT by Chad von Nau
Modified: 2015-08-05 08:38 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chad von Nau 2015-07-20 19:12:09 PDT
Demo here:
http://jsfiddle.net/sbel/sykrLf2u/6/

Steps to reproduce the problem:
1. Create an absolutely positioned element at left: 0.
2. Get offsetWidth of element.
2. Move element to left: .1px
3. Get offsetWidth of element.

What is the expected behavior?
The offsetWidths should match.

What went wrong?
When the element is positioned at .1px, it's offsetWidth is 1px larger.

Notes:
The demo comes from this SO post about the issue: http://stackoverflow.com/q/26124678

This bug is also present in Chrome, but not Firefox or IE.

This bug will likely resolve itself if offsetWidth gains support for subpixel values. The Chrome team seems to be working on this, not sure if you guys are as well.
Comment 1 Chad von Nau 2015-07-20 19:16:49 PDT
Also reported to Chromium: https://code.google.com/p/chromium/issues/detail?id=512307
Comment 2 Simon Fraser (smfr) 2015-07-21 13:13:55 PDT
Having offsetWidth return non-integral values (bug 132895) was a web-breaking change (bug 134651).
Comment 3 Chad von Nau 2015-08-05 02:18:29 PDT
The chromium team has marked their version of this issue as a Won't Fix:

    https://code.google.com/p/chromium/issues/detail?id=512307#c5
    eae@chromium.org:
    This is intentional as we snap elements to the pixel grid. The offset*
    properties return the snapped values and as such are dependent on the
    rendered size, and by extension, position.

I don't like offsetWidth changing based on position, but their logic seems sound to me. Maybe it's best to bury the issue here as well.
Comment 4 Simon Fraser (smfr) 2015-08-05 08:38:10 PDT
Yes, agreed.