mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
layout: Restrict stretch alignment to flex items with computed auto size (#36288)
We were allowing `align-self: stretch` to stretch flex items whose cross size behaves as `auto`, including cyclic percentages. However, https://github.com/w3c/csswg-drafts/issues/4525 resolved that stretching should only happen when the cross size computes to `auto`. So this patch exposes this information in `ContentBoxSizesAndPBM`, and refactors the flexbox stretching logic. Fixes: #36285 Testing: - `/css/css-flexbox/quirks-auto-block-size-with-percentage-item.html` - `/css/css-flexbox/stretch-requires-computed-auto-size.html` Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
c19c7b2ed8
commit
202cac900d
7 changed files with 94 additions and 67 deletions
|
@ -235,6 +235,7 @@ pub(crate) struct ContentBoxSizesAndPBM {
|
|||
pub content_box_sizes: LogicalVec2<Sizes>,
|
||||
pub pbm: PaddingBorderMargin,
|
||||
pub depends_on_block_constraints: bool,
|
||||
pub preferred_size_computes_to_auto: LogicalVec2<bool>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
@ -1000,6 +1001,8 @@ impl LayoutStyle<'_> {
|
|||
let box_size = style.box_size(writing_mode);
|
||||
let min_size = style.min_box_size(writing_mode);
|
||||
let max_size = style.max_box_size(writing_mode);
|
||||
let preferred_size_computes_to_auto = box_size.map(|size| size.is_initial());
|
||||
|
||||
let depends_on_block_constraints = |size: &Size<LengthPercentage>| {
|
||||
match size {
|
||||
// fit-content is like clamp(min-content, stretch, max-content), but currently
|
||||
|
@ -1014,7 +1017,6 @@ impl LayoutStyle<'_> {
|
|||
_ => false,
|
||||
}
|
||||
};
|
||||
|
||||
let depends_on_block_constraints = depends_on_block_constraints(&box_size.block) ||
|
||||
depends_on_block_constraints(&min_size.block) ||
|
||||
depends_on_block_constraints(&max_size.block) ||
|
||||
|
@ -1045,6 +1047,7 @@ impl LayoutStyle<'_> {
|
|||
},
|
||||
pbm,
|
||||
depends_on_block_constraints,
|
||||
preferred_size_computes_to_auto,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue