Skip to content

[css-grid] Automatic minimum size clamping by grid area should transfer through aspect ratio #767

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

Closed
fantasai opened this issue Nov 26, 2016 · 6 comments
Labels
Closed Accepted by CSSWG Resolution Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-grid-1 Tracked in DoC

Comments

@fantasai
Copy link
Collaborator

I think this is an error in the clamping rule... The spec says in https://drafts.csswg.org/css-grid/#min-size-auto

However, if the grid item spans only grid tracks that have a fixed max track sizing function, its automatic minimum size in that dimension is further clamped to less than or equal to the size necessary to fit its margin box within the resulting grid area (flooring at zero).

I think that if the transferred size (this dimension's size transferred through the aspect ratio to the other dimension) is controlling the size in the other dimension, then that transferred size should also get clamped accordingly.

Possible edits for this would be

However, if the grid item spans only grid tracks that have a fixed max track sizing function, its automatic minimum size in that dimension is further limited by treating the item’s fill-available fit into the sum of those track sizes as an additional maximum limit (floored at zero) for clamping the “specified size” and “content size” in that dimension and accordingly the “transferred size”, if any, in the other dimension, so as to prevent the automatic minimum from forcing overflow of its fixed-size grid area.

Let me know what you think.

@MatsPalmgren
Copy link

Yes, I think this is a good idea for "transferred size". Firefox currently doesn't do this -- we only clamp the intrinsic size, but that can lead to non-intuitive results since it may overflow the clamped axis when stretching an image with preserved ratio.

I don't think clamping should shrink an item below its specified width/height in the same axis though (as you seem to suggest, but maybe I misunderstood?).

I wonder if it would be better to define the grid area clamping in terms of max-width/height instead?
It's currently a bit undefined how clamping interacts with min/max-width/height (and over-constrained situations), even with your suggested additions above.
Something like "clamping acts as an extra max-size on the item in the relevant axis, that is, the used max-width/height is the minimum of the grid area size and the computed value of the relevant max-width/height, if any".
That makes it much better defined, since we re-use all spec text for max-width/height. It's immediately clear that a specified larger width/height trumps the clamping, for example.
(Warning: I haven't really investigated this idea in depth.)

@MatsPalmgren
Copy link

Actually, I was mostly thinking about a transferred size that comes from stretching an item with a preserved ratio when I wrote the above. I'm less sure it's a good idea when the transferred size comes from an actual specified size in the other axis. We might want to treat those differently...

@fantasai
Copy link
Collaborator Author

Keep in mind that we're clamping a minimum size! Not the actual size. :) Defining it in terms of max-width/height wouldn't make any sense. (And the interaction with max-width/height isn't underdefined: max-width/height reduces the automatic minimum if necessary, that's clearly specified in the definition.)

The specified size is a maximum on that minimum -- it's there so that if the specified size is less than the intrinsic size, then we use the specified size as the minimum instead. A specified size doesn't increase the automatic minimum: we take the most conservative minimum as the automatic minimum, so it's min(specified size, content size) if there's a specified size and min(transferred size, content size) if there isn't but there's an aspect ratio, and simply content size if neither specified size nor transferred size exist.

@tabatkins
Copy link
Member

All right, fix checked in

  However, if the <a>grid item</a> spans only <a>grid tracks</a>
  that have a <a lt="fixed sizing function">fixed</a> <a>max track sizing function</a>,
- its <a>automatic minimum size</a> in that dimension
- is further clamped to less than or equal to the size necessary
+ the “specified size” and “content size” in that dimension
+ (and the input to the "transferred size" in the other dimension)
+ are further clamped to less than or equal to the size necessary
  to fit its margin box within the resulting <a>grid area</a> (flooring at zero)
+ so as to prevent the automatic minimum from forcing overflow of its fixed-size grid area

@fantasai
Copy link
Collaborator Author

Agenda+ to get wg resolution

@tabatkins
Copy link
Member

WG resolved to take this edit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Accepted by CSSWG Resolution 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

3 participants