Don't transfer indefinite height: stretch to inline axis (#34557)

Consider this testcase:
```html
<canvas style="aspect-ratio: 1; height: stretch; background: cyan"
        width="200" height="100"></canvas>
```

To compute the intrinsic inline sizes we were treating `height: stretch`
as the natural height (100px) and then transferring that to the inline
axis through the preferred aspect ratio. So the element was 100px wide.

However, an indefinite `stretch` should be treated as an automatic size,
which wouldn't be transferred to the inline axis.

The fix actually makes the code slightly simpler.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2024-12-10 12:12:28 +01:00 committed by GitHub
parent 2b8a8f7498
commit e10e989abb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 15 deletions

View file

@ -532,18 +532,15 @@ impl ReplacedContents {
// Therefore, we tentatively treat intrinsic block sizing properties as their initial value.
let inline_content_size = LazyCell::new(|| {
let get_block_size = || {
let block_stretch_size = block_stretch_size.unwrap_or_else(get_block_fallback_size);
SizeConstraint::new(
box_size
.block
.maybe_resolve_extrinsic(Some(block_stretch_size)),
box_size.block.maybe_resolve_extrinsic(block_stretch_size),
min_box_size
.block
.maybe_resolve_extrinsic(Some(block_stretch_size))
.maybe_resolve_extrinsic(block_stretch_size)
.unwrap_or_default(),
max_box_size
.block
.maybe_resolve_extrinsic(Some(block_stretch_size)),
.maybe_resolve_extrinsic(block_stretch_size),
)
};
self.content_size(