Re: [csswg-drafts] [css-grid][css-contain] Clarify that `contain:size` affects track sizing (#4931)

> >    When you calculate the size of the box, you treat it as having no content, and therefore do not reserve room for any implicit track.
>
> @frivoal You don't? So Chromium is wrong?

I think so:
* spec based reasoning: spec says to size the element as if it were empty. implicit tracks with a non-zero fixed min track sizing function would have an impact on the size, and only exist if the element is not empty. Therefore, don't take them into account when calculating the size. (but then when later doing the layout pass, sure, do consider the grid items and do create the relevant tracks).
* goal based reasoning: if we take the number of elements into account in order to figure out how many implicit tracks we have, and these implicit tracks have a non-zero fixed min track sizing function, then, by applying display:none to grid items, we can change the size of the grid. This would mean that the element is not actually contained, and optimizations based on containment would become incorrect.

So, answers to your numbered questions are:

> When sizing a grid container with size containment under a min/max-content constraint,
> 
> 1. Should we run the placement algorithm (creating implicit tracks if needed)?
>    Florian says we shouldn't? Chromium does, Firefox does not.

No, that would defeat the point of using size containment.

> 2. Should we run the track sizing algorithm?
>    The spec says so. Chromium does, Firefox just sets the size of the grid container to 0.

Yes. We could switch to no without defeating the point of using size containment, but that would result in a less useful layout.

> 3. If 1 and 2 are affirmative, should tracks take intrinsic contributions of the items into account?
>    No, that would defeat the point of using size containment.

Agreed.

> When laying out the grid container with size containment into that size,
> 
> 4. Should we run the placement algorithm (creating implicit tracks if needed)?
>    Yes, we need to know where to place the items in order to display them.

Agreed

> 5. Should we run the track sizing algorithm?
>    Yes, we need to know the sizes of the grid areas in order to size the grid items.

Agreed. We could switch to no without defeating the point of using size containment, but that would result in a less useful layout.


> 6. If 4 and 5 are affirmative, should tracks take intrinsic contributions of the items into account?
>    Yes with option B, not with option A. Chromium and Firefox do it.

Yes. We could switch to no without defeating the point of using size containment, but that would result in a less useful layout. Also, if authors have a layout which would be resilient to that and want the extra optimization opportunities, they can apply size containment to the grid items.


> 7. If 6 is negative, should the automatic minimum size still apply?
>    Maybe not?

I don't think 6 should be negative, so ¯\\\_(ツ)\_/¯

-- 
GitHub Notification of comment by frivoal
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4931#issuecomment-615058884 using your GitHub account

Received on Friday, 17 April 2020 05:59:26 UTC