diff options
author | Martin Robinson <mrobinson@igalia.com> | 2025-05-12 11:38:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-12 09:38:50 +0000 |
commit | a0dd2c1bebbc238d2fe36b1134acfbc842c1f084 (patch) | |
tree | 367a47983a81113a4c4988ff8a11cca6de6f007d /components/layout/table/mod.rs | |
parent | db83601b62b81965176e1e8272d5b434afeb0da6 (diff) | |
download | servo-a0dd2c1bebbc238d2fe36b1134acfbc842c1f084.tar.gz servo-a0dd2c1bebbc238d2fe36b1134acfbc842c1f084.zip |
layout: Share styles to inline box children via `SharedInlineStyles` (#36896)
`TextRun`s use their parent style to render. Previously, these styles
were cloned and stored directly in the box tree `TextRun` and resulting
`TextFragment`s. This presents a problem for incremental layout.
Wrapping the style in another layer of shared ownership and mutability
will allow updating all `TextFragment`s during repaint-only incremental
layout by simply updating the box tree styles of the original text
parents.
This adds a new set of borrows when accessing text styles, but also
makes it so that during box tree block construction
`InlineFormattingContext`s are created lazily and now
`InlineFormattingContextBuilder::finish` consumes the builder, making
the API make a bit more sense. This should also improve performance of
box tree block construction slightly.
Testing: This should not change observable behavior and thus is covered
by existing WPT tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Diffstat (limited to 'components/layout/table/mod.rs')
-rw-r--r-- | components/layout/table/mod.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/components/layout/table/mod.rs b/components/layout/table/mod.rs index 8e2783e2919..08fc89d927e 100644 --- a/components/layout/table/mod.rs +++ b/components/layout/table/mod.rs @@ -82,10 +82,11 @@ use style::properties::style_structs::Font; use style_traits::dom::OpaqueNode; use super::flow::BlockFormattingContext; +use crate::SharedStyle; use crate::cell::ArcRefCell; use crate::flow::BlockContainer; use crate::formatting_contexts::IndependentFormattingContext; -use crate::fragment_tree::{BaseFragmentInfo, Fragment, SharedBackgroundStyle}; +use crate::fragment_tree::{BaseFragmentInfo, Fragment}; use crate::geom::PhysicalVec; use crate::layout_box_base::LayoutBoxBase; use crate::style_ext::BorderStyleColor; @@ -98,12 +99,10 @@ pub struct Table { /// The style of this table. These are the properties that apply to the "wrapper" ie the element /// that contains both the grid and the captions. Not all properties are actually used on the /// wrapper though, such as background and borders, which apply to the grid. - #[conditional_malloc_size_of] style: Arc<ComputedValues>, /// The style of this table's grid. This is an anonymous style based on the table's style, but /// eliminating all the properties handled by the "wrapper." - #[conditional_malloc_size_of] grid_style: Arc<ComputedValues>, /// The [`BaseFragmentInfo`] for this table's grid. This is necessary so that when the @@ -292,7 +291,7 @@ pub struct TableTrack { /// A shared container for this track's style, used to share the style for the purposes /// of drawing backgrounds in individual cells. This allows updating the style in a /// single place and having it affect all cell `Fragment`s. - shared_background_style: SharedBackgroundStyle, + shared_background_style: SharedStyle, } #[derive(Debug, MallocSizeOf, PartialEq)] @@ -317,7 +316,7 @@ pub struct TableTrackGroup { /// A shared container for this track's style, used to share the style for the purposes /// of drawing backgrounds in individual cells. This allows updating the style in a /// single place and having it affect all cell `Fragment`s. - shared_background_style: SharedBackgroundStyle, + shared_background_style: SharedStyle, } impl TableTrackGroup { |