Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-grid] Sizing algorithm for span >= 2 should be a generalization of span 1 #3616

Closed
Loirooriol opened this issue Feb 5, 2019 · 6 comments
Labels
Closed Accepted as Editorial Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-grid-1 Tracked in DoC

Comments

@Loirooriol
Copy link
Contributor

Loirooriol commented Feb 5, 2019

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).

Why the differences?

@Loirooriol Loirooriol 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 Feb 6, 2019
@fantasai fantasai added this to the css-grid-1 CR 2017-12-14+ milestone Feb 7, 2019
@fantasai
Copy link
Collaborator

fantasai commented 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
Copy link
Contributor Author

minimum contribution ≤ min-content contribution

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?

Wrt the second point. see #2303 (comment) :)

That looks good, thanks.

@fantasai
Copy link
Collaborator

fantasai commented Feb 8, 2019

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?

@Loirooriol
Copy link
Contributor Author

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.

@fantasai fantasai added the Target Revision: Current Remove when done. label Feb 20, 2019
fantasai added a commit that referenced this issue Feb 20, 2019
…st a simplification of, the span=n instructions. #3616
@fantasai
Copy link
Collaborator

@Loirooriol Done. Close out the issue if you are satisfied? :)

@Loirooriol
Copy link
Contributor Author

Yes, thanks!

@fantasai fantasai added Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. and removed Commenter Response Pending Target Revision: Current Remove when done. labels Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Accepted as Editorial Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-grid-1 Tracked in DoC
Projects
None yet
Development

No branches or pull requests

2 participants