Handle aspect ratios in ReplacedContent::inline_content_sizes (#33240)

We were only handling the aspect ratio of a replaced element when
computing its min/max-content contribution, but not when computing
the min/max-content size. Now both cases will take it into account.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2024-08-29 17:38:59 +02:00 committed by GitHub
parent 3f93de7f54
commit 0643aa4708
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 39 additions and 59 deletions

View file

@ -5,7 +5,6 @@
use app_units::Au;
use serde::Serialize;
use servo_arc::Arc;
use style::logical_geometry::Direction;
use style::properties::ComputedValues;
use style::selector_parser::PseudoElement;
use style::values::specified::text::TextDecorationLine;
@ -180,14 +179,17 @@ impl IndependentFormattingContext {
&mut self,
layout_context: &LayoutContext,
containing_block_for_children: &IndefiniteContainingBlock,
containing_block: &IndefiniteContainingBlock,
) -> ContentSizes {
match self {
Self::NonReplaced(inner) => {
inner.inline_content_sizes(layout_context, containing_block_for_children)
},
Self::Replaced(inner) => inner
.contents
.inline_content_sizes(layout_context, containing_block_for_children),
Self::Replaced(inner) => inner.contents.inline_content_sizes(
layout_context,
containing_block_for_children,
inner.preferred_aspect_ratio(containing_block),
),
}
}
@ -211,20 +213,11 @@ impl IndependentFormattingContext {
containing_block,
auto_minimum,
|containing_block_for_children| {
match (
containing_block_for_children.size.block,
replaced.contents.inline_content_sizes(
layout_context,
containing_block_for_children,
replaced.preferred_aspect_ratio(containing_block),
) {
(AuOrAuto::LengthPercentage(block_size), Some(ratio)) => {
return ratio
.compute_dependent_size(Direction::Inline, block_size)
.into();
},
_ => {},
}
replaced
.contents
.inline_content_sizes(layout_context, containing_block_for_children)
)
},
),
}