Skip to content

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

Closed

Description

@Loirooriol

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?

Activity

  1. 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
  2. fantasai commented on Feb 7, 2019

    @fantasai
    Collaborator

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

  3. Loirooriol commented on Feb 7, 2019

    @Loirooriol
    ContributorAuthor

    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.

  4. fantasai commented on Feb 8, 2019

    @fantasai
    Collaborator

    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?

  5. Loirooriol commented on Feb 8, 2019

    @Loirooriol
    ContributorAuthor

    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.

  6. fantasai commented on Feb 20, 2019

    @fantasai
    Collaborator

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

  7. Loirooriol commented on Feb 20, 2019

    @Loirooriol
    ContributorAuthor

    Yes, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions