-
Notifications
You must be signed in to change notification settings - Fork 715
[cssom-view] Layout dimension that divides+rounds+sums to value different to original dividend #1211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for looking into this and writing tests! This is indeed the right place. Although the rendering can snap to device pixels, this can still be different from CSS pixels. In particular if there are two device pixels per CSS pixels (in one dimension), then both columns can be exactly 49.5px (without aliasing). Also with page zoom can affect this I believe. Still, you demonstrated that there is lack of interop between Chrome and everyone else, so it would be good to come to an agreement which behavior is better and align on that. If we say that all widths should add up to the same sum as the total width, how could that be implemented? For Firefox and Edge that allow the edge to cross a pixel, it seems they would need to do extra work to figure out which way to round So I'm tempted to suggest that these should round in isolation (like Safari/Firefox/Edge), and we can add new non-integer APIs if any are missing. @rune-opera thoughts? |
The same issue exists with other more arbitrary divisions too. E.g. 10px÷3 or 70px split into 3 columns of 3, 4 and 5 units in a 12-column grid (using e.g. flexbox). Of course it also applies to I created more test cases for the 10px÷3 scenario; I believe what Chrome does to determine which element to add or remove the additional pixel to/from is;
(Safari and Chrome apply this to actual layout, shown by each column being different widths in the tests. Chrome also applies it to Perhaps the solution is that This doesn't require Firefox and Edge change their actual layout by requiring all elements have width and height dimensions that are integers. And Website creators would then only need to deal with two different behaviours. WorkaroundI've documented a workaround at https://github.com/BevanR/5-and-5-is-9/ |
Rounding the edges is interesting. An interesting case is if the width is 0.5px, it depends on where the edges are in the "CSS pixel grid" if |
...at least not always, it appears it depends on page zoom level. |
Uh oh!
There was an error while loading. Please reload this page.
Is there any specification for HTML layout dimensions that divide, round and sum to a value greater than the original dividend?
For example
Major web browsers handle this differently;
element.offsetWidth
† Allows element boundaries to be mid-pixel, causing that pixel to be aliased based on the two elements that it straddles.
Test cases
The specification for
offsetWidth
only says that offsetWidth must be an integer. Is this specified elsewhere? Should it be?Is this the correct place to discuss?
The text was updated successfully, but these errors were encountered: