diff options
Diffstat (limited to 'components/layout/table')
-rw-r--r-- | components/layout/table/construct.rs | 17 | ||||
-rw-r--r-- | components/layout/table/layout.rs | 8 | ||||
-rw-r--r-- | components/layout/table/mod.rs | 12 |
3 files changed, 30 insertions, 7 deletions
diff --git a/components/layout/table/construct.rs b/components/layout/table/construct.rs index 8370e9aeb89..133904db7ae 100644 --- a/components/layout/table/construct.rs +++ b/components/layout/table/construct.rs @@ -29,7 +29,7 @@ use crate::formatting_contexts::{ IndependentFormattingContext, IndependentFormattingContextContents, IndependentNonReplacedContents, }; -use crate::fragment_tree::BaseFragmentInfo; +use crate::fragment_tree::{BackgroundStyle, BaseFragmentInfo, SharedBackgroundStyle}; use crate::layout_box_base::LayoutBoxBase; use crate::style_ext::{DisplayGeneratingBox, DisplayLayoutInternal}; @@ -722,9 +722,10 @@ impl<'style, 'dom> TableBuilderTraversal<'style, 'dom> { let style = anonymous_info.style.clone(); self.push_table_row(ArcRefCell::new(TableTrack { - base: LayoutBoxBase::new((&anonymous_info).into(), style), + base: LayoutBoxBase::new((&anonymous_info).into(), style.clone()), group_index: self.current_row_group_index, is_anonymous: true, + shared_background_style: SharedBackgroundStyle::new(BackgroundStyle(style)), })); } @@ -766,6 +767,9 @@ impl<'dom> TraversalHandler<'dom> for TableBuilderTraversal<'_, 'dom> { base: LayoutBoxBase::new(info.into(), info.style.clone()), group_type: internal.into(), track_range: next_row_index..next_row_index, + shared_background_style: SharedBackgroundStyle::new(BackgroundStyle( + info.style.clone(), + )), }); self.builder.table.row_groups.push(row_group.clone()); @@ -808,6 +812,9 @@ impl<'dom> TraversalHandler<'dom> for TableBuilderTraversal<'_, 'dom> { base: LayoutBoxBase::new(info.into(), info.style.clone()), group_index: self.current_row_group_index, is_anonymous: false, + shared_background_style: SharedBackgroundStyle::new(BackgroundStyle( + info.style.clone(), + )), }); self.push_table_row(row.clone()); box_slot.set(LayoutBox::TableLevelBox(TableLevelBox::Track(row))); @@ -853,6 +860,9 @@ impl<'dom> TraversalHandler<'dom> for TableBuilderTraversal<'_, 'dom> { base: LayoutBoxBase::new(info.into(), info.style.clone()), group_type: internal.into(), track_range: first_column..self.builder.table.columns.len(), + shared_background_style: SharedBackgroundStyle::new(BackgroundStyle( + info.style.clone(), + )), }); self.builder.table.column_groups.push(column_group.clone()); box_slot.set(LayoutBox::TableLevelBox(TableLevelBox::TrackGroup( @@ -1135,6 +1145,9 @@ fn add_column( base: LayoutBoxBase::new(column_info.into(), column_info.style.clone()), group_index, is_anonymous, + shared_background_style: SharedBackgroundStyle::new(BackgroundStyle( + column_info.style.clone(), + )), }); collection.extend(repeat(column.clone()).take(span as usize)); column diff --git a/components/layout/table/layout.rs b/components/layout/table/layout.rs index 2efe339837e..00dac210625 100644 --- a/components/layout/table/layout.rs +++ b/components/layout/table/layout.rs @@ -2063,7 +2063,7 @@ impl<'a> TableLayout<'a> { let column_group = column_group.borrow(); let rect = make_relative_to_row_start(dimensions.get_column_group_rect(&column_group)); fragment.add_extra_background(ExtraBackground { - style: column_group.base.style.clone(), + style: column_group.shared_background_style.clone(), rect, }) } @@ -2072,7 +2072,7 @@ impl<'a> TableLayout<'a> { if !column.is_anonymous { let rect = make_relative_to_row_start(dimensions.get_column_rect(column_index)); fragment.add_extra_background(ExtraBackground { - style: column.base.style.clone(), + style: column.shared_background_style.clone(), rect, }) } @@ -2085,7 +2085,7 @@ impl<'a> TableLayout<'a> { let rect = make_relative_to_row_start(dimensions.get_row_group_rect(&row_group.borrow())); fragment.add_extra_background(ExtraBackground { - style: row_group.borrow().base.style.clone(), + style: row_group.borrow().shared_background_style.clone(), rect, }) } @@ -2093,7 +2093,7 @@ impl<'a> TableLayout<'a> { let row = row.borrow(); let rect = make_relative_to_row_start(row_fragment_layout.rect); fragment.add_extra_background(ExtraBackground { - style: row.base.style.clone(), + style: row.shared_background_style.clone(), rect, }) } diff --git a/components/layout/table/mod.rs b/components/layout/table/mod.rs index fe7f90437b8..8e2783e2919 100644 --- a/components/layout/table/mod.rs +++ b/components/layout/table/mod.rs @@ -85,7 +85,7 @@ use super::flow::BlockFormattingContext; use crate::cell::ArcRefCell; use crate::flow::BlockContainer; use crate::formatting_contexts::IndependentFormattingContext; -use crate::fragment_tree::{BaseFragmentInfo, Fragment}; +use crate::fragment_tree::{BaseFragmentInfo, Fragment, SharedBackgroundStyle}; use crate::geom::PhysicalVec; use crate::layout_box_base::LayoutBoxBase; use crate::style_ext::BorderStyleColor; @@ -288,6 +288,11 @@ pub struct TableTrack { /// Whether or not this [`TableTrack`] was anonymous, for instance created due to /// a `span` attribute set on a parent `<colgroup>`. is_anonymous: bool, + + /// 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, } #[derive(Debug, MallocSizeOf, PartialEq)] @@ -308,6 +313,11 @@ pub struct TableTrackGroup { /// The range of tracks in this [`TableTrackGroup`]. track_range: Range<usize>, + + /// 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, } impl TableTrackGroup { |