layout: Support stretch cross size for flex base size (#35663)

The computation of the flex base size may involve transferring a
definite cross size into the main axis through the aspect ratio.
We were only considering numeric sizes as definite, but `stretch` can
also be definite.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-02-26 19:03:38 +01:00 committed by GitHub
parent 8d8f0f49cf
commit 03e953e22c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 93 additions and 5 deletions

View file

@ -246713,6 +246713,32 @@
{}
]
],
"flexbox-flex-base-size-001.html": [
"a7a1aef192d8e95a93ecffb9bbe9834eb7ecbca7",
[
null,
[
[
"/css/reference/ref-filled-green-200px-square.html",
"=="
]
],
{}
]
],
"flexbox-flex-base-size-002.html": [
"66a1874f933add4ce0e9d0bd5939d46812934ee0",
[
null,
[
[
"/css/reference/ref-filled-green-200px-square.html",
"=="
]
],
{}
]
],
"min-width-1.html": [
"a1a39073e88d4626be7c469611e3593415849e7a",
[

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Flex base size of flex item with stretch cross size</title>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#stretch-fit-sizing">
<link rel="help" href="https://drafts.csswg.org/css-flexbox-1/#flex-base-size">
<link rel="match" href="../../reference/ref-filled-green-200px-square.html">
<meta assert="A definite `stretch` cross size can be transferred through the
aspect ratio when computing the flex base size of a flex item.">
<style>
div {
display: flex;
flex-direction: column;
height: 200px;
width: 200px;
background: red;
}
canvas {
width: stretch;
align-self: start;
min-height: 0;
background: green;
}
</style>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div class="flex">
<canvas width="100" height="100"></canvas>
</div>

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Flex base size of flex item with stretch cross size</title>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#stretch-fit-sizing">
<link rel="help" href="https://drafts.csswg.org/css-flexbox-1/#flex-base-size">
<link rel="match" href="../../reference/ref-filled-green-200px-square.html">
<meta assert="A definite `stretch` cross size can be transferred through the
aspect ratio when computing the flex base size of a flex item.">
<style>
div {
display: flex;
flex-direction: row;
height: 200px;
width: 200px;
background: red;
}
canvas {
height: stretch;
align-self: start;
min-width: 0;
background: green;
}
</style>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div class="flex">
<canvas width="100" height="100"></canvas>
</div>