Re: [csswg-drafts] [cssom-view] Layout dimension that divides+rounds+sums to value different to original dividend

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 `offsetHeight` in the vertical dimension where row heights are divisions of the height of the container.

I created more test cases for the 10px÷3 scenario;

- [Column widths](
- [Row heights](

I believe what Chrome does to determine which element to add or remove the additional pixel to/from is;

- round the left edge
- round the right edge
- make the width be the difference

(Safari and Chrome apply this to actual layout, shown by each column being different widths in the tests.  Chrome also applies it to `offsetWidth` and `offsetHeight`.  Safari does not, making the most incorrect browser for this unspecified behaviour; It reports the 4px row as 5px high in the row heights test case!)

Perhaps the solution is that `offsetHeight` and `offsetWidth` should be specified to be calculated in this way.

This doesn't require Firefox and Edge change their actual layout by requiring all elements have width and height dimensions that are integers.  And `offsetWidth` and `offsetHeight` would still be inconsistent with the actual layout (in Firefox and Edge only), because they still _must_ be integers.  This is no more or less broken than their current behaviour.  But at least offset dimensions would add to the sum of the container in _all_ browsers.  Also, Safari would then have to report what it is actually doing, and have the same behaviour as Chrome.

Website creators would then only need to deal with two different behaviours.

### Workaround

I've documented a workaround at

GitHub Notification of comment by BevanR
Please view or discuss this issue at using your GitHub account

Received on Thursday, 13 April 2017 10:11:57 UTC