aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_thread/lib.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_thread/lib.rs
parent6a871808e893c3b9f4dffde1abacff7898c2612f (diff)
downloadservo-f5a3d282fbc47177285d7635284d9bd1c00dc04a.tar.gz
servo-f5a3d282fbc47177285d7635284d9bd1c00dc04a.zip
Actually check if root is absolute positioned
Diffstat (limited to 'components/layout_thread/lib.rs')
-rw-r--r--components/layout_thread/lib.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index 79d84526b48..ac1a7fe21ef 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -44,7 +44,7 @@ use layout::context::RegisteredPainter;
use layout::context::RegisteredPainters;
use layout::display_list::items::WebRenderImageInfo;
use layout::display_list::{IndexableText, ToLayout};
-use layout::flow::{Flow, GetBaseFlow, ImmutableFlowUtils, MutableOwnedFlowUtils};
+use layout::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils, MutableOwnedFlowUtils};
use layout::flow_ref::FlowRef;
use layout::incremental::{RelayoutMode, SpecialRestyleDamage};
use layout::layout_debug;
@@ -950,11 +950,20 @@ impl LayoutThread {
let mut flow = match result {
ConstructionResult::Flow(mut flow, abs_descendants) => {
// Note: Assuming that the root has display 'static' (as per
- // CSS Section 9.3.1). Otherwise, if it were absolutely
- // positioned, it would return a reference to itself in
- // `abs_descendants` and would lead to a circular reference.
- // Set Root as CB for any remaining absolute descendants.
- flow.set_absolute_descendants(abs_descendants);
+ // CSS Section 9.3.1). If it was absolutely positioned,
+ // it would return a reference to itself in `abs_descendants`
+ // and would lead to a circular reference. Otherwise, we
+ // set Root as CB and push remaining absolute descendants.
+ if flow
+ .base()
+ .flags
+ .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED)
+ {
+ flow.set_absolute_descendants(abs_descendants);
+ } else {
+ flow.push_absolute_descendants(abs_descendants);
+ }
+
flow
},
_ => return None,