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

> 3. Change "_Then, its contents must then be laid out into the containing box's resolved size._" to "_Then, its contents is laid out into the containing box's resolved size normally, i.e. `contain:size` has no effect in this phase._"

Sure. That's a reasonable clarification.

> Perhaps also add a parenthetical clarification: "(including any pseudo-elements)" at the end.

This too seems like a useful clarification.

>  1. change "When calculating the size of the containing box, including when computing its intrinsic size, it must be treated as having no contents." to "When calculating the intrinsic size of the containing box, it must be treated as having no contents.".

That would not work:

If the size-contained grid is inside of a absolutely positioned element, or inside of a float which is itself inside a zero-width div, then when we try to figure out the size of the abspos or of the div, we look at the **intrinsic size** of its content (the size-positioned grid): the max-content size in the case of the abspos, the min-content size in the case of the float in a zero-width container. This is correctly captured by your phrasing (and also I believe by the one currently in the spec).

However, the effect is not limited to this, and your suggested edit drops the other part:

If a size-contained grid is an ordinary block-level child of an ordinary div, the grid must still be sized as if it were empty, then laid out in that size. For a grid with no gap, fixed-sized track, etc, than would mean a width equal to that of its block container, and a height of 0. This is not calculating the **intrinsic size** of the grid. It is calculating its **size**.

> My understanding is that size containment is only supposed to prevent the intrinsic size of an element from depending on the size of the contents. But in this case, the existence of implicit tracks wouldn't depend on the layout of the children, only on their computed style.
>
> So I'm not opposed to avoid creating implicit tracks with size containment, but I'm not convinced that's necessary.

When you change the style of the children of the grid to display:none, or to turn them into abspos, or to use grid-row or grid-column to explicitly place them into implicit tracks, you can affect the number of tracks implicit tracks, and if they have a non-zero fixed min track sizing function, this in turn affects the size of the grid even if you ignore them when sizing the tracks. But since the goal of size containment is that whatever happens inside the element has no effect on the size of the element, this cannot be allowed.

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

Received on Thursday, 23 April 2020 05:15:58 UTC