mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
layout: Support stretch
cross size for automatic min size in flexbox (#35652)
The computation of the automatic minimum 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:
parent
9d5171f3c5
commit
6aae4df909
4 changed files with 93 additions and 5 deletions
|
@ -2530,14 +2530,16 @@ impl FlexItemBox {
|
||||||
Direction::Block
|
Direction::Block
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let cross_stretch_size = containing_block_size
|
||||||
|
.cross
|
||||||
|
.map(|v| v - pbm_auto_is_zero.cross);
|
||||||
let cross_size = SizeConstraint::new(
|
let cross_size = SizeConstraint::new(
|
||||||
if content_box_size.cross.is_initial() && auto_cross_size_stretches_to_container_size {
|
if content_box_size.cross.is_initial() && auto_cross_size_stretches_to_container_size {
|
||||||
containing_block_size
|
cross_stretch_size
|
||||||
.cross
|
|
||||||
.map(|v| v - pbm_auto_is_zero.cross)
|
|
||||||
} else {
|
} else {
|
||||||
// TODO(#32853): handle size keywords.
|
content_box_size
|
||||||
content_box_size.cross.to_numeric()
|
.cross
|
||||||
|
.maybe_resolve_extrinsic(cross_stretch_size)
|
||||||
},
|
},
|
||||||
min_size.cross.auto_is(Au::zero),
|
min_size.cross.auto_is(Au::zero),
|
||||||
max_size.cross,
|
max_size.cross,
|
||||||
|
|
26
tests/wpt/meta/MANIFEST.json
vendored
26
tests/wpt/meta/MANIFEST.json
vendored
|
@ -246687,6 +246687,32 @@
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"flexbox-auto-minimum-001.html": [
|
||||||
|
"626b18deae189b3c97c106968758164405786941",
|
||||||
|
[
|
||||||
|
null,
|
||||||
|
[
|
||||||
|
[
|
||||||
|
"/css/reference/ref-filled-green-200px-square.html",
|
||||||
|
"=="
|
||||||
|
]
|
||||||
|
],
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"flexbox-auto-minimum-002.html": [
|
||||||
|
"d5e590346ee36a7cb613e6fa89c1c999c2cccfb5",
|
||||||
|
[
|
||||||
|
null,
|
||||||
|
[
|
||||||
|
[
|
||||||
|
"/css/reference/ref-filled-green-200px-square.html",
|
||||||
|
"=="
|
||||||
|
]
|
||||||
|
],
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
],
|
||||||
"min-width-1.html": [
|
"min-width-1.html": [
|
||||||
"a1a39073e88d4626be7c469611e3593415849e7a",
|
"a1a39073e88d4626be7c469611e3593415849e7a",
|
||||||
[
|
[
|
||||||
|
|
30
tests/wpt/tests/css/css-sizing/stretch/flexbox-auto-minimum-001.html
vendored
Normal file
30
tests/wpt/tests/css/css-sizing/stretch/flexbox-auto-minimum-001.html
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Automatic minimum 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/#min-size-auto">
|
||||||
|
<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 automatic minimum size of a flex item.">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
div {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 200px;
|
||||||
|
width: 200px;
|
||||||
|
background: red;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
width: stretch;
|
||||||
|
align-self: start;
|
||||||
|
flex-basis: 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>
|
30
tests/wpt/tests/css/css-sizing/stretch/flexbox-auto-minimum-002.html
vendored
Normal file
30
tests/wpt/tests/css/css-sizing/stretch/flexbox-auto-minimum-002.html
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Automatic minimum 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/#min-size-auto">
|
||||||
|
<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 automatic minimum size of a flex item.">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
div {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
height: 200px;
|
||||||
|
width: 200px;
|
||||||
|
background: red;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
height: stretch;
|
||||||
|
align-self: start;
|
||||||
|
flex-basis: 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>
|
Loading…
Add table
Add a link
Reference in a new issue