diff options
author | Martin Robinson <mrobinson@igalia.com> | 2025-04-18 11:40:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-18 09:40:29 +0000 |
commit | 2ee8427665099987f715296d4d55b6388a480c08 (patch) | |
tree | a1c3595c8f6837abfcd01c729c2d8edcead26327 /components/layout_2020/layout_box_base.rs | |
parent | fc201927ae5bdf26f842f9d4e6e52c2255adcde2 (diff) | |
download | servo-2ee8427665099987f715296d4d55b6388a480c08.tar.gz servo-2ee8427665099987f715296d4d55b6388a480c08.zip |
layout: Store `Fragment` results in `LayoutBoxBase` and start using them for queries (#36583)
Start storing a link to laid-out `Fragment`s in `LayoutBoxBase`, so that
these are accessible for queries and eventually for incremental layout.
Some box tree data structures lacked a `LayoutBoxBase`, such as table
tracks and table track groups[^1].
In addition, start using these `Fragment`s for queries instead of
walking the entire `Fragment` tree. Currently, this isn't possible for
most queries as `Fragment`s do not cache their absolute offsets (which
are often necessary). This change uses the new box tree `Fragment`s for
most resolved style queries.
[^1]: Note that only rows and row groups store `Fragment`s as columsn
and
colgroups do not produce any.
Testing: This is covered by existing tests.
Fixes: This is part of #36525.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Diffstat (limited to 'components/layout_2020/layout_box_base.rs')
-rw-r--r-- | components/layout_2020/layout_box_base.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/components/layout_2020/layout_box_base.rs b/components/layout_2020/layout_box_base.rs index 8a88a5855dc..54f7575391c 100644 --- a/components/layout_2020/layout_box_base.rs +++ b/components/layout_2020/layout_box_base.rs @@ -29,6 +29,7 @@ pub(crate) struct LayoutBoxBase { pub cached_inline_content_size: AtomicRefCell<Option<Box<(SizeConstraint, InlineContentSizesResult)>>>, pub cached_layout_result: AtomicRefCell<Option<Box<CacheableLayoutResultAndInputs>>>, + pub fragments: AtomicRefCell<Vec<Fragment>>, } impl LayoutBoxBase { @@ -38,6 +39,7 @@ impl LayoutBoxBase { style, cached_inline_content_size: AtomicRefCell::default(), cached_layout_result: AtomicRefCell::default(), + fragments: AtomicRefCell::default(), } } @@ -69,6 +71,22 @@ impl LayoutBoxBase { pub(crate) fn invalidate_cached_fragment(&self) { let _ = self.cached_layout_result.borrow_mut().take(); } + + pub(crate) fn fragments(&self) -> Vec<Fragment> { + self.fragments.borrow().clone() + } + + pub(crate) fn add_fragment(&self, fragment: Fragment) { + self.fragments.borrow_mut().push(fragment); + } + + pub(crate) fn set_fragment(&self, fragment: Fragment) { + *self.fragments.borrow_mut() = vec![fragment]; + } + + pub(crate) fn clear_fragments(&self) { + self.fragments.borrow_mut().clear(); + } } impl Debug for LayoutBoxBase { |