[csswg-drafts] [css-contain][css-grid] contain:size for grid containers is underspecified (#3892)

MatsPalmgren has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-contain][css-grid] contain:size for grid containers is underspecified ==
[Size containment](https://drafts.csswg.org/css-contain/#containment-size) needs more details to be implementable for Grid containers.  Specifically, is grid item placement considered part of "sizing"?
The grid spec has [Placement](https://drafts.csswg.org/css-grid/#placement) as a separate step before [Grid Sizing](https://drafts.csswg.org/css-grid/#layout-algorithm), which seems to imply that placement should be done as usual.
The spec mentions that properties like `grid` should be taken into account, but the used value for the underlying properties (`grid-template-columns/rows`) are affected by placement, for example by placing items into the implicit grid, or `repeat(auto-fit)`, here's a [testcase](https://bug1488878.bmoattachments.org/attachment.cgi?id=9062783).

The two alternatives for implementing `contain:size` I can think of are:

    1. place items into the grid as usual
    2. run Track Sizing algo but pretend we have no items
    3. calculate the container's size from the track sizes as usual

or:

    1. without placing any items first, run Track Sizing algo and pretend we have no items
    2. calculate a size from those tracks, then discard those tracks
    3. place items into the grid as usual
    4. run Track Sizing algo but pretend we have no items
    5. use the size from step 2 as the container's size

The first alternative would be slightly more efficient, and also easier to implement. The second  alternative likely leads to overflow when the placement creates tracks as in the given testcase.



Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3892 using your GitHub account

Received on Sunday, 5 May 2019 12:16:15 UTC