Open fantasai opened 5 years ago
If I understand this correctly, I believe it should resolve to the Grid container size / “available grid space”. As an Author, I would have no idea why it resolved to 300px.
The CSS Working Group just discussed aspect-ratio-only boxes should be able to size to grid container
.
@dholbert
I need to page back in the grid layout algorithm before I can comment usefully here. CC @MatsPalmgren in case he can get to thinking through this before I do.
@fantasai
The available space to a grid item when finding its max-content contribution is undefined. :(
The available space isn't a parameter when finding out the min/max-content size
at all. It seems like a flawed assumption that it should be. I really don't want to introduce "available space" as a parameter to those functions.
I disagree with this edit that made it so: https://github.com/w3c/csswg-drafts/commit/c42c80f64a0fe6b1ea05678a16862eb0880b4b76
Is there a spec issue/resolution for that change?
This issue could benefit from a better description of the problem it's trying to solve. It sounds like what you really want is ratio-preserving stretching, so that for example:
<div style="display:grid; grid-template-rows:200px">
<img src="https://hg.mozilla.org/mozilla-central/raw-file/tip/layout/reftests/w3c-css/submitted/images3/support/colors-16x8-noSize.svg">
</div>
would result in an 400x200 sized image?
Issue #523 has a useful discussion of this problem. (Note that the example above works as expected in Firefox 51 (and older), but then we changed it as a result of that issue...)
That problem can be solved with align-self:stretch-with-ratio
or height:contain
or something. I don't think we need to mess with intrinsic sizes to solve this.
@MatsPalmgren The calculation of the size for images with an aspect ratio and no intrinsic size is noted in https://www.w3.org/TR/CSS2/visudet.html#inline-replaced-width so we just followed that rule when drafting css-sizing-3.
This issue could benefit from a better description of the problem it's trying to solve.
I think the summary is pretty clear: we've got a case where the result is undefined, so we have to define the behavior.
Comment for future Tab and fantasai: There's some interop here, but not fully, and we have a mix of the behaviors described here, with more interop on what's described in this issue than not. We need to write up the relevant test cases and figure out spec text to describe this behavior.
If we put an image which has only an aspect ratio into an auto-row/auto-column grid cell in a fixed-size grid...
(We don't run into this problem for non-replaced elements, because their min/max-content contributions don't refer to the available space in the inline dimension, and for orthogonal flows we do define the available space.)
The available logical width we provide to an item with an aspect ratio and no size should either be the “available grid space” (the size of the grid container if definite), or it should be infinity. (Infinity in this case will resolve to an image width of 300px/ICB size depending on issue #4218.) In the case where the grid container's size is definite, do we want to use it instead?