aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/flow/inline/mod.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-09-06 06:42:45 -0700
committerGitHub <noreply@github.com>2024-09-06 13:42:45 +0000
commitc24c7d8e4d52604dba755251f7222efcb07d738d (patch)
treeb98a5323a43c146c7bb76c78c8fb3dfbcc9e0bb0 /components/layout_2020/flow/inline/mod.rs
parentebed9218f2907767ba3c9dd9f27f30a6a6e9f225 (diff)
downloadservo-c24c7d8e4d52604dba755251f7222efcb07d738d.tar.gz
servo-c24c7d8e4d52604dba755251f7222efcb07d738d.zip
layout: Lay out absolutes in atomic containing blocks (#33336)
When inline atomics establish containing blocks for absolute descendants, layout should happen with those atomics as the containing block. This ensures that the absolute descendents have the correct containing block and Fragment parent. This wasn't happening before and this change fixes that. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Diffstat (limited to 'components/layout_2020/flow/inline/mod.rs')
-rw-r--r--components/layout_2020/flow/inline/mod.rs26
1 files changed, 17 insertions, 9 deletions
diff --git a/components/layout_2020/flow/inline/mod.rs b/components/layout_2020/flow/inline/mod.rs
index edf1ba81e18..3eddfb3bbbe 100644
--- a/components/layout_2020/flow/inline/mod.rs
+++ b/components/layout_2020/flow/inline/mod.rs
@@ -1984,15 +1984,12 @@ impl IndependentFormattingContext {
"Mixed horizontal and vertical writing modes are not supported yet"
);
- // This always collects for the nearest positioned ancestor even if the parent positioning
- // context doesn't. The thing is we haven't kept track up to this point and there isn't
- // any harm in keeping the hoisted boxes separate.
- child_positioning_context = Some(PositioningContext::new_for_subtree(
- true, /* collects_for_nearest_positioned_ancestor */
- ));
+ let mut positioning_context =
+ PositioningContext::new_for_style(&non_replaced.style)
+ .unwrap_or_else(|| PositioningContext::new_for_subtree(true));
let independent_layout = non_replaced.layout(
layout.layout_context,
- child_positioning_context.as_mut().unwrap(),
+ &mut positioning_context,
&containing_block_for_children,
layout.containing_block,
);
@@ -2022,7 +2019,7 @@ impl IndependentFormattingContext {
.to_physical_size(container_writing_mode),
);
- BoxFragment::new(
+ let mut fragment = BoxFragment::new(
non_replaced.base_fragment_info,
non_replaced.style.clone(),
independent_layout.fragments,
@@ -2033,7 +2030,18 @@ impl IndependentFormattingContext {
None,
CollapsedBlockMargins::zero(),
)
- .with_baselines(independent_layout.baselines)
+ .with_baselines(independent_layout.baselines);
+
+ if fragment
+ .style
+ .establishes_containing_block_for_absolute_descendants(fragment.base.flags)
+ {
+ positioning_context
+ .layout_collected_children(layout.layout_context, &mut fragment);
+ }
+ child_positioning_context = Some(positioning_context);
+
+ fragment
},
};