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-sizing] Does indefinite stretch behave as automatic size or as initial value? #11006
@bfgeek told me that Blink had to deal with some breakage when they adopted this behavior, but that it's the correct thing to do. But what about stretch?
But here Blink is not implementing this, not sure if due to an oversight.
And then the situation is that browsers are implementing stretch, but nobody follows the spec here. It may be too late for *-content, but I would like to have an agreement for stretch before it ships. So Agenda+.
So I think this was intended just to be applicable to main sizes, (e.g. not min/max-sizes).
IMO this should be consistent with min-height: 100%, e.g. if a percentage is indefinite it behaves as zero for min-height, and Infinity for max-height.
I'm not convinced we should treat it like a percentage. For example, with a min/max-content of 100px, fit-content is basically clamp(100px, stretch, 100px), and in Blink max-height: fit-content behaves as 100px but max-height: clamp(100px, 100%, 100px) behaves as none. And doing this like Blink seems more annoying to implement in Servo.
So I think we should either:
Keep the spec as-is, or
Treat both fit-content and stretch as containing a cyclic percentage.
More specifically, treat fit-content as fit-content(100%) and stretch as 100%, so:
I'm not convinced we should treat it like a percentage. For example, with a min/max-content of 100px, fit-content is basically clamp(100px, stretch, 100px)
This isn't correct - we recently did a change to follow Firefox in this regard. See: #10721
When the stretch is indefinite - min-size: fit-content resolves to min-size: min-content, and max-size: fit-content to max-size: max-content respectively.
And doing this like Blink seems more annoying to implement in Servo.
I'm curious why this is difficult in Servo? This might result in difficulty when attempting to implement calc-size() for example.
I'm pretty convinced that we should just be consistent with 100% here, (again see the max-height:stretch example above, it'd be super weird if we coerce an explicitly extrinsic constraint to be intrinsic).
we recently did a change to follow Firefox in this regard. See: #10721
Not sure if that is the best behavior, I have commented there.
I'm curious why this is difficult in Servo?
I misunderstood what you were doing for fit-content, I thought it was trickier. Resolving keywords in different ways depending on the property and having a potentially indefinite stretch size during layout still adds some complexity. But not a big deal I guess.
it'd be super weird if we coerce an explicitly extrinsic constraint to be intrinsic
Indeed, the FF behavior is just because I haven't implemented stretch behavior in the block axis yet (keep getting distracted by other tasks, but made a little local progress this week, hope to be done soonish).
Sure, but if the spec changes, we need to decide whether min-height: stretch should behave as auto or as 0px or whatever 100% would do (the spec says that 100% should behave as 0px, but browsers don't follow the spec in general).
So I think this was intended just to be applicable to main sizes, (e.g. not min/max-sizes).
IMO this should be consistent with min-height: 100%, e.g. if a percentage is indefinite it behaves as zero for min-height, and Infinity for max-height.
I talked to @tabatkins about this a few weeks ago. He confirmed that the spec editors intended the Blink/Gecko behavior (min-size:stretch resolves to 0 and max-size:stretch resolves to infinity when available size is indefinite) and that it was indeed on the editors to better define the spec around min/max sizes behaving as auto, which should hopefully clear up the confusion here.
Activity
Loirooriol commentedon Oct 5, 2024
For Servo following the spec seems a bit simpler than aligning with Blink, so I guess I will go with that for now.
bfgeek commentedon Oct 8, 2024
So I think this was intended just to be applicable to main sizes, (e.g. not min/max-sizes).
IMO this should be consistent with
min-height: 100%, e.g. if a percentage is indefinite it behaves as zero formin-height, and Infinity formax-height.(e.g. The Blink/Gecko behaviour).
For example it'd be pretty weird if:
got clamped by the intrinsic size (when
stretchis an extrinsic constraint).cc/ @tabatkins
Loirooriol commentedon Oct 9, 2024
I'm not convinced we should treat it like a percentage. For example, with a min/max-content of 100px,
fit-contentis basicallyclamp(100px, stretch, 100px), and in Blinkmax-height: fit-contentbehaves as100pxbutmax-height: clamp(100px, 100%, 100px)behaves asnone. And doing this like Blink seems more annoying to implement in Servo.So I think we should either:
fit-contentandstretchas containing a cyclic percentage.More specifically, treat
fit-contentasfit-content(100%)andstretchas100%, so:bfgeek commentedon Oct 9, 2024
This isn't correct - we recently did a change to follow Firefox in this regard. See: #10721
When the stretch is indefinite -
min-size: fit-contentresolves tomin-size: min-content, andmax-size: fit-contenttomax-size: max-contentrespectively.I'm curious why this is difficult in Servo? This might result in difficulty when attempting to implement calc-size() for example.
I'm pretty convinced that we should just be consistent with 100% here, (again see the
max-height:stretchexample above, it'd be super weird if we coerce an explicitly extrinsic constraint to be intrinsic).Loirooriol commentedon Oct 17, 2024
Not sure if that is the best behavior, I have commented there.
I misunderstood what you were doing for
fit-content, I thought it was trickier. Resolving keywords in different ways depending on the property and having a potentially indefinite stretch size during layout still adds some complexity. But not a big deal I guess.Maybe a bit weird indeed.
Loirooriol commentedon Oct 17, 2024
It's worth noting that there is a difference among major browsers:
min-height: stretchas the initialauto0pxInterestingly, they all treat
min-height: 0%as0px.bfgeek commentedon Oct 17, 2024
I wouldn't read too much into the block direction behaviour with FF (support was lacking last time I checked).
dholbert commentedon Oct 17, 2024
Indeed, the FF behavior is just because I haven't implemented
stretchbehavior in the block axis yet (keep getting distracted by other tasks, but made a little local progress this week, hope to be done soonish).Loirooriol commentedon Oct 18, 2024
Sure, but if the spec changes, we need to decide whether
min-height: stretchshould behave asautoor as0pxor whatever100%would do (the spec says that100%should behave as0px, but browsers don't follow the spec in general).davidsgrogan commentedon Dec 9, 2024
I talked to @tabatkins about this a few weeks ago. He confirmed that the spec editors intended the Blink/Gecko behavior (min-size:stretch resolves to 0 and max-size:stretch resolves to infinity when available size is indefinite) and that it was indeed on the editors to better define the spec around min/max sizes behaving as auto, which should hopefully clear up the confusion here.
21 remaining items
Bug 1950067 [wpt PR 50899] - layout: Ignore indefinite `stretch` on m…
Bug 1950067 [wpt PR 50899] - layout: Ignore indefinite `stretch` on m…
[layout] Fix fit-content on min/max inline-sizes for contributions.
[layout] Fix fit-content on min/max inline-sizes for contributions.
[layout] Fix fit-content on min/max inline-sizes for contributions.
[layout] Fix fit-content on min/max inline-sizes for contributions.
Bug 1954553 [wpt PR 51392] - [layout] Fix fit-content on min/max inli…
Bug 1950067 [wpt PR 50899] - layout: Ignore indefinite `stretch` on m…
Bug 1954553 [wpt PR 51392] - [layout] Fix fit-content on min/max inli…
[css-sizing-3] Clarify indefinite stretch sizing #11006