layout: Respect alignment when sizing replaced abspos (#35085)

If an absolutely position element which is replaced has `justify-self`
or `align-self` set to `stretch`, and no inset is `auto` on that axis,
then an automatic size should behave as `stretch`, not as `fit-content`.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-01-20 05:25:00 -08:00 committed by GitHub
parent 2965b2fda7
commit f6c166533e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 92 additions and 69 deletions

View file

@ -1972,18 +1972,21 @@ impl FlexItem<'_> {
containing_block,
item_style,
self.preferred_aspect_ratio,
&Sizes::new(
block_size
.to_definite()
.map_or(Size::Initial, Size::Numeric),
Size::Numeric(min_size.block),
max_size.block.map_or(Size::Initial, Size::Numeric),
),
&Sizes::new(
Size::Numeric(inline_size),
Size::Numeric(min_size.inline),
max_size.inline.map_or(Size::Initial, Size::Numeric),
),
LogicalVec2 {
block: &Sizes::new(
block_size
.to_definite()
.map_or(Size::Initial, Size::Numeric),
Size::Numeric(min_size.block),
max_size.block.map_or(Size::Initial, Size::Numeric),
),
inline: &Sizes::new(
Size::Numeric(inline_size),
Size::Numeric(min_size.inline),
max_size.inline.map_or(Size::Initial, Size::Numeric),
),
},
Size::FitContent.into(),
flex_axis.vec2_to_flow_relative(self.pbm_auto_is_zero),
);
let hypothetical_cross_size = flex_axis.vec2_to_flex_relative(size).cross;
@ -2792,22 +2795,25 @@ impl FlexItemBox {
flex_context.containing_block,
style,
preferred_aspect_ratio,
&Sizes::new(
content_box_size
.block
.non_auto()
.map_or(Size::Initial, Size::Numeric),
Size::Numeric(min_size.block),
max_size.block.map_or(Size::Initial, Size::Numeric),
),
&Sizes::new(
content_box_size
.inline
.non_auto()
.map_or(Size::Initial, Size::Numeric),
Size::Numeric(min_size.inline),
max_size.inline.map_or(Size::Initial, Size::Numeric),
),
LogicalVec2 {
block: &Sizes::new(
content_box_size
.block
.non_auto()
.map_or(Size::Initial, Size::Numeric),
Size::Numeric(min_size.block),
max_size.block.map_or(Size::Initial, Size::Numeric),
),
inline: &Sizes::new(
content_box_size
.inline
.non_auto()
.map_or(Size::Initial, Size::Numeric),
Size::Numeric(min_size.inline),
max_size.inline.map_or(Size::Initial, Size::Numeric),
),
},
Size::FitContent.into(),
padding_border_margin.padding_border_sums +
padding_border_margin.margin.auto_is(Au::zero).sum(),
)