diff options
author | bors-servo <infra@servo.org> | 2023-05-03 12:20:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-03 12:20:30 +0200 |
commit | 77a184a0e7379a63a0d9d8bf442d8dd5c3b5e307 (patch) | |
tree | 63977547a5589b891b7ef0852fa6d238ec082e85 /components/layout_2020/fragments.rs | |
parent | a8f7c458117efdcdac64f0865885b372896f50d1 (diff) | |
parent | 0c13fcb9f27a51c787a48cca6df91850d7a9fc74 (diff) | |
download | servo-77a184a0e7379a63a0d9d8bf442d8dd5c3b5e307.tar.gz servo-77a184a0e7379a63a0d9d8bf442d8dd5c3b5e307.zip |
Auto merge of #29660 - mrobinson:revamp-stacking-context-tree, r=delan
Rework CB management during stacking context tree construction
Manage containing blocks and WebRender `SpaceAndClip` during stacking context tree construction using the `ContainingBlockInfo` data structure. This will allow us to reuse this data structure whenever we traverse the fragment tree. In addition, `StackingContextBuilder` is no longer necessary at all. This change also fixes some bugs where fixed position fragments were not placed in the correct spatial node. Unfortunately, these fixes are difficult to test because of #29659.
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] There are tests for these changes.
Diffstat (limited to 'components/layout_2020/fragments.rs')
-rw-r--r-- | components/layout_2020/fragments.rs | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/components/layout_2020/fragments.rs b/components/layout_2020/fragments.rs index b54fa90a52b..687bdbe083e 100644 --- a/components/layout_2020/fragments.rs +++ b/components/layout_2020/fragments.rs @@ -19,7 +19,6 @@ use serde::ser::{Serialize, Serializer}; use servo_arc::Arc as ServoArc; use std::sync::Arc; use style::computed_values::overflow_x::T as ComputedOverflow; -use style::computed_values::position::T as ComputedPosition; use style::dom::OpaqueNode; use style::logical_geometry::WritingMode; use style::properties::ComputedValues; @@ -68,19 +67,20 @@ impl Tag { pub(crate) enum Fragment { Box(BoxFragment), Anonymous(AnonymousFragment), - AbsoluteOrFixedPositioned(AbsoluteOrFixedPositionedFragment), + /// Absolute and fixed position fragments are hoisted up so that they + /// are children of the BoxFragment that establishes their containing + /// blocks, so that they can be laid out properly. When this happens + /// an `AbsoluteOrFixedPositioned` fragment is left at the original tree + /// position. This allows these hoisted fragments to be painted with + /// regard to their original tree order during stacking context tree / + /// display list construction. + AbsoluteOrFixedPositioned(ArcRefCell<HoistedSharedFragment>), Text(TextFragment), Image(ImageFragment), IFrame(IFrameFragment), } #[derive(Serialize)] -pub(crate) struct AbsoluteOrFixedPositionedFragment { - pub position: ComputedPosition, - pub hoisted_fragment: ArcRefCell<HoistedSharedFragment>, -} - -#[derive(Serialize)] pub(crate) struct BoxFragment { pub tag: Tag, pub debug_id: DebugId, @@ -214,7 +214,9 @@ impl Fragment { pub fn print(&self, tree: &mut PrintTree) { match self { Fragment::Box(fragment) => fragment.print(tree), - Fragment::AbsoluteOrFixedPositioned(fragment) => fragment.print(tree), + Fragment::AbsoluteOrFixedPositioned(_) => { + tree.add_item("AbsoluteOrFixedPositioned".to_string()); + }, Fragment::Anonymous(fragment) => fragment.print(tree), Fragment::Text(fragment) => fragment.print(tree), Fragment::Image(fragment) => fragment.print(tree), @@ -280,12 +282,6 @@ impl Fragment { } } -impl AbsoluteOrFixedPositionedFragment { - pub fn print(&self, tree: &mut PrintTree) { - tree.add_item(format!("AbsoluteOrFixedPositionedFragment")); - } -} - impl AnonymousFragment { pub fn no_op(mode: WritingMode) -> Self { Self { |