Skip to content

[css-contain][css-grid] contain:size for grid containers is underspecified #3892

@MatsPalmgren

Description

@MatsPalmgren

Size containment needs more details to be implementable for Grid containers. Specifically, is grid item placement considered part of "sizing"?
The grid spec has Placement as a separate step before Grid Sizing, 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.

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions