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

@ -536,12 +536,25 @@ impl HoistedAbsolutelyPositionedBox {
inline: inline_axis_solver.inset_sum(),
block: block_axis_solver.inset_sum(),
};
let automatic_size = |alignment: AlignFlags, offsets: &AbsoluteBoxOffsets| {
if alignment.value() == AlignFlags::STRETCH && !offsets.either_auto() {
Size::Stretch
} else {
Size::FitContent
}
};
let used_size = replaced.used_size_as_if_inline_element_from_content_box_sizes(
containing_block,
&style,
context.preferred_aspect_ratio(&pbm.padding_border_sums),
&block_axis_solver.computed_sizes,
&inline_axis_solver.computed_sizes,
LogicalVec2 {
inline: &inline_axis_solver.computed_sizes,
block: &block_axis_solver.computed_sizes,
},
LogicalVec2 {
inline: automatic_size(inline_alignment, &inline_axis_solver.box_offsets),
block: automatic_size(block_alignment, &block_axis_solver.box_offsets),
},
pbm.padding_border_sums + pbm.margin.auto_is(Au::zero).sum() + inset_sums,
);
inline_axis_solver.override_size(used_size.inline);