aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/flow.rs
diff options
context:
space:
mode:
authorWu Yu Wei <wusyong9104@gmail.com>2022-04-19 14:57:03 +0800
committerWu Yu Wei <wusyong9104@gmail.com>2022-04-19 17:43:43 +0800
commitf5a3d282fbc47177285d7635284d9bd1c00dc04a (patch)
treed5b12b75f79418b590c4ec1a6c9fbbbdbb91ff35 /components/layout/flow.rs
parent6a871808e893c3b9f4dffde1abacff7898c2612f (diff)
downloadservo-f5a3d282fbc47177285d7635284d9bd1c00dc04a.tar.gz
servo-f5a3d282fbc47177285d7635284d9bd1c00dc04a.zip
Actually check if root is absolute positioned
Diffstat (limited to 'components/layout/flow.rs')
-rw-r--r--components/layout/flow.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/components/layout/flow.rs b/components/layout/flow.rs
index b8a16933ae6..074f0ad273a 100644
--- a/components/layout/flow.rs
+++ b/components/layout/flow.rs
@@ -557,6 +557,11 @@ pub trait MutableOwnedFlowUtils {
/// Set this flow as the Containing Block for all the absolute descendants.
fn set_absolute_descendants(&mut self, abs_descendants: AbsoluteDescendants);
+ /// Push absolute descendants to this flow.
+ ///
+ /// Set this flow as the Containing Block for the provided absolute descendants.
+ fn push_absolute_descendants(&mut self, abs_descendants: AbsoluteDescendants);
+
/// Sets the flow as the containing block for all absolute descendants that have been marked
/// as having reached their containing block. This is needed in order to handle cases like:
///
@@ -1364,6 +1369,26 @@ impl MutableOwnedFlowUtils for FlowRef {
}
}
+ /// Push absolute descendants for this flow.
+ ///
+ /// Set yourself as the Containing Block for the provided absolute descendants.
+ ///
+ /// This is called when retreiving layout root if it's not absolute positioned. We can't just
+ /// call `set_absolute_descendants` because it might contain other abs_descendants already.
+ /// We push descendants instead of replace it since it won't cause circular reference.
+ fn push_absolute_descendants(&mut self, mut abs_descendants: AbsoluteDescendants) {
+ let this = self.clone();
+ let base = FlowRef::deref_mut(self).mut_base();
+
+ for descendant_link in abs_descendants.descendant_links.iter_mut() {
+ debug_assert!(!descendant_link.has_reached_containing_block);
+ let descendant_base = FlowRef::deref_mut(&mut descendant_link.flow).mut_base();
+ descendant_base.absolute_cb.set(this.clone());
+ }
+
+ base.abs_descendants.push_descendants(abs_descendants);
+ }
+
/// Sets the flow as the containing block for all absolute descendants that have been marked
/// as having reached their containing block. This is needed in order to handle cases like:
///