You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[css-grid] Sizing algorithm for span >= 2 should be a generalization of span 1 #3616
I don't understand why there is a track sizing algorithm using items with a span of 1 (and intrinsic minimum and non-flexible maximum), and another one for items with a span >= 2 (not spanning tracks with flexible maximums).
I think both cases should use the same algorithm, just with the extra space distribution being more trivial to perform for items with a span of 1. However, they aren't exactly the same:
With span >= 2, tracks with intrinsic minimums end up at least as big as the minimum contribution. For span 1, this is only ensured for auto minimums.
With span >= 2, an auto minimum under a sizing min/max-content constraint behaves as min/max-content. With span 1 it's not exactly like this, because the value is later clamped between the minimum contribution and the max track sizing function (or fit-content argument).
changed the title [-][css-grid] Sizing algorithm for span 2 should be a generalization of span 1[/-][+][css-grid] Sizing algorithm for span >= 2 should be a generalization of span 1[/+]on Feb 6, 2019
Wrt the first point, the following inequality holds: minimum contribution ≤ min-content contribution ≤ max-content contribution. This allowed us to have a simpler structure for span=1. (It wasn't possible for span > 1 because of the way spanning items are handled... We could have written a super generalized algorithm, but this would have been harder for readers to follow. It's easier to think about the span=1 case using the simplified algorithm, and then work up to spanning items, where there is some extra complexity.)
OK I was strongly suspecting this, but it's not obvious, because the definition of the minimum contribution is complex, and requires a deep understanding of css-sizing. Maybe add a note?
We could have written a super generalized algorithm, but this would have been harder for readers to follow.
Then could you also add another note saying that applying the algorithm for spanning items to non-spanning ones would produce the same result, it would just be less simple?
Then could you also add another note saying that applying the algorithm for spanning items to non-spanning ones would produce the same result, it would just be less simple?
At what point in the section do you think this is helpful to point out?
Well for example in https://drafts.csswg.org/css-grid/#algo-single-span-items after "consider the items in it with a span of 1" it could say that it's just a simplification, but with the same result, of the algorithm for spanning items.
Or maybe in https://drafts.csswg.org/css-grid/#algo-spanning-items after "Repeat incrementally for items with greater spans until all items have been considered" it could say that performing an initial iteration for items with a span of 1 would have the same effect as running the non-spanning algorithm.
Activity
[-][css-grid] Sizing algorithm for span 2 should be a generalization of span 1[/-][+][css-grid] Sizing algorithm for span >= 2 should be a generalization of span 1[/+]fantasai commentedon Feb 7, 2019
Wrt the first point, the following inequality holds: minimum contribution ≤ min-content contribution ≤ max-content contribution. This allowed us to have a simpler structure for span=1. (It wasn't possible for span > 1 because of the way spanning items are handled... We could have written a super generalized algorithm, but this would have been harder for readers to follow. It's easier to think about the span=1 case using the simplified algorithm, and then work up to spanning items, where there is some extra complexity.)
Wrt the second point. see #2303 (comment) :)
Loirooriol commentedon Feb 7, 2019
OK I was strongly suspecting this, but it's not obvious, because the definition of the minimum contribution is complex, and requires a deep understanding of css-sizing. Maybe add a note?
Then could you also add another note saying that applying the algorithm for spanning items to non-spanning ones would produce the same result, it would just be less simple?
That looks good, thanks.
fantasai commentedon Feb 8, 2019
At what point in the section do you think this is helpful to point out?
[css-grid-1] Note that auto-min <= min-content <= max-content. #3616
Loirooriol commentedon Feb 8, 2019
Well for example in https://drafts.csswg.org/css-grid/#algo-single-span-items after "consider the items in it with a span of 1" it could say that it's just a simplification, but with the same result, of the algorithm for spanning items.
Or maybe in https://drafts.csswg.org/css-grid/#algo-spanning-items after "Repeat incrementally for items with greater spans until all items have been considered" it could say that performing an initial iteration for items with a span of 1 would have the same effect as running the non-spanning algorithm.
[css-grid-1] Note that span=1 item instructions are equivalent to, ju…
fantasai commentedon Feb 20, 2019
@Loirooriol Done. Close out the issue if you are satisfied? :)
Loirooriol commentedon Feb 20, 2019
Yes, thanks!