aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/flow
diff options
context:
space:
mode:
authorOriol Brufau <obrufau@igalia.com>2024-11-29 12:40:52 +0100
committerGitHub <noreply@github.com>2024-11-29 11:40:52 +0000
commit19a7e95a6a4cc4e6aa187f2fe2302c4707401e34 (patch)
treeb288e002160b1dd9c07ecf29eba22df9cf8e59e5 /components/layout_2020/flow
parent16da1c2721d471277c3981795d8d6000e8876cea (diff)
downloadservo-19a7e95a6a4cc4e6aa187f2fe2302c4707401e34.tar.gz
servo-19a7e95a6a4cc4e6aa187f2fe2302c4707401e34.zip
Refactor computation of preferred aspect ratios (#34416)
* Refactor computation of preferred aspect ratios Computing min/max-content sizes required a ContainingBlock in order to resolve the padding and border when determining the preferred aspect ratio. However, all callers already knew the padding and border, so they can compute the ratio themselves, and pass it directly instead of the ContainingBlock. Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Put preferred aspect ratio into ConstraintSpace Signed-off-by: Oriol Brufau <obrufau@igalia.com> --------- Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Diffstat (limited to 'components/layout_2020/flow')
-rw-r--r--components/layout_2020/flow/inline/mod.rs2
-rw-r--r--components/layout_2020/flow/mod.rs18
2 files changed, 14 insertions, 6 deletions
diff --git a/components/layout_2020/flow/inline/mod.rs b/components/layout_2020/flow/inline/mod.rs
index f268a8dbc7f..7e2a537cb29 100644
--- a/components/layout_2020/flow/inline/mod.rs
+++ b/components/layout_2020/flow/inline/mod.rs
@@ -1965,7 +1965,7 @@ impl IndependentFormattingContext {
// Lay out absolutely positioned children if this new atomic establishes a containing block
// for absolutes.
- let positioning_context = if matches!(self, IndependentFormattingContext::Replaced(_)) {
+ let positioning_context = if self.is_replaced() {
None
} else {
if fragment
diff --git a/components/layout_2020/flow/mod.rs b/components/layout_2020/flow/mod.rs
index ed2347360cb..f897c223d56 100644
--- a/components/layout_2020/flow/mod.rs
+++ b/components/layout_2020/flow/mod.rs
@@ -235,10 +235,13 @@ impl OutsideMarker {
sequential_layout_state: Option<&mut SequentialLayoutState>,
collapsible_with_parent_start_margin: Option<CollapsibleWithParentStartMargin>,
) -> Fragment {
- let content_sizes = self.block_container.inline_content_sizes(
- layout_context,
- &ConstraintSpace::new_for_style(&self.marker_style),
+ let constraint_space = ConstraintSpace::new_for_style_and_ratio(
+ &self.marker_style,
+ None, /* TODO: support preferred aspect ratios on non-replaced boxes */
);
+ let content_sizes = self
+ .block_container
+ .inline_content_sizes(layout_context, &constraint_space);
let containing_block_for_children = ContainingBlock {
inline_size: content_sizes.sizes.max_content,
block_size: AuOrAuto::auto(),
@@ -394,7 +397,8 @@ fn calculate_inline_content_size_for_block_level_boxes(
style,
containing_block,
&LogicalVec2::zero(),
- false, /* auto_block_size_stretches_to_containing_block */
+ false, /* auto_block_size_stretches_to_containing_block */
+ |_| None, /* TODO: support preferred aspect ratios on non-replaced boxes */
|constraint_space| {
contents.inline_content_sizes(layout_context, constraint_space)
},
@@ -2054,7 +2058,11 @@ impl IndependentFormattingContext {
SizeConstraint::new(preferred_block_size, min_block_size, max_block_size);
let content_size = LazyCell::new(|| {
- let constraint_space = ConstraintSpace::new(tentative_block_size, writing_mode);
+ let constraint_space = ConstraintSpace::new(
+ tentative_block_size,
+ writing_mode,
+ non_replaced.preferred_aspect_ratio(),
+ );
non_replaced
.inline_content_sizes(layout_context, &constraint_space)
.sizes