Fix various issues with replaced elements in flex layout (#33263)

In particular, this takes into account that flex items may be stretched,
and if they have an aspect ratio, we ma6y need to convert the stretched
size through the ratio.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Oriol Brufau 2024-08-31 01:39:18 +02:00 committed by GitHub
parent 4ae2610c24
commit 3acc9edd82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 334 additions and 481 deletions

View file

@ -198,12 +198,14 @@ impl IndependentFormattingContext {
layout_context: &LayoutContext,
containing_block: &IndefiniteContainingBlock,
auto_minimum: &LogicalVec2<Au>,
auto_block_size_stretches_to_containing_block: bool,
) -> ContentSizes {
match self {
Self::NonReplaced(non_replaced) => sizing::outer_inline(
&non_replaced.style.clone(),
containing_block,
auto_minimum,
auto_block_size_stretches_to_containing_block,
|containing_block_for_children| {
non_replaced.inline_content_sizes(layout_context, containing_block_for_children)
},
@ -212,6 +214,7 @@ impl IndependentFormattingContext {
&replaced.style,
containing_block,
auto_minimum,
auto_block_size_stretches_to_containing_block,
|containing_block_for_children| {
replaced.contents.inline_content_sizes(
layout_context,
@ -222,6 +225,16 @@ impl IndependentFormattingContext {
),
}
}
pub(crate) fn preferred_aspect_ratio(
&self,
containing_block: &IndefiniteContainingBlock,
) -> Option<AspectRatio> {
match self {
Self::NonReplaced(_) => None,
Self::Replaced(replaced) => replaced.preferred_aspect_ratio(containing_block),
}
}
}
impl NonReplacedFormattingContext {