aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/table
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout/table')
-rw-r--r--components/layout/table/construct.rs22
-rw-r--r--components/layout/table/layout.rs1
-rw-r--r--components/layout/table/mod.rs59
3 files changed, 62 insertions, 20 deletions
diff --git a/components/layout/table/construct.rs b/components/layout/table/construct.rs
index 133904db7ae..0c238073df2 100644
--- a/components/layout/table/construct.rs
+++ b/components/layout/table/construct.rs
@@ -19,7 +19,6 @@ use super::{
Table, TableCaption, TableLevelBox, TableSlot, TableSlotCell, TableSlotCoordinates,
TableSlotOffset, TableTrack, TableTrackGroup, TableTrackGroupType,
};
-use crate::PropagatedBoxTreeData;
use crate::cell::ArcRefCell;
use crate::context::LayoutContext;
use crate::dom::{BoxSlot, LayoutBox};
@@ -29,9 +28,10 @@ use crate::formatting_contexts::{
IndependentFormattingContext, IndependentFormattingContextContents,
IndependentNonReplacedContents,
};
-use crate::fragment_tree::{BackgroundStyle, BaseFragmentInfo, SharedBackgroundStyle};
+use crate::fragment_tree::BaseFragmentInfo;
use crate::layout_box_base::LayoutBoxBase;
use crate::style_ext::{DisplayGeneratingBox, DisplayLayoutInternal};
+use crate::{PropagatedBoxTreeData, SharedStyle};
/// A reference to a slot and its coordinates in the table
#[derive(Debug)]
@@ -725,7 +725,7 @@ impl<'style, 'dom> TableBuilderTraversal<'style, 'dom> {
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)),
+ shared_background_style: SharedStyle::new(style),
}));
}
@@ -767,9 +767,7 @@ 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(),
- )),
+ shared_background_style: SharedStyle::new(info.style.clone()),
});
self.builder.table.row_groups.push(row_group.clone());
@@ -812,9 +810,7 @@ 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(),
- )),
+ shared_background_style: SharedStyle::new(info.style.clone()),
});
self.push_table_row(row.clone());
box_slot.set(LayoutBox::TableLevelBox(TableLevelBox::Track(row)));
@@ -860,9 +856,7 @@ 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(),
- )),
+ shared_background_style: SharedStyle::new(info.style.clone()),
});
self.builder.table.column_groups.push(column_group.clone());
box_slot.set(LayoutBox::TableLevelBox(TableLevelBox::TrackGroup(
@@ -1145,9 +1139,7 @@ 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(),
- )),
+ shared_background_style: SharedStyle::new(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 00dac210625..5b7e79d7fb0 100644
--- a/components/layout/table/layout.rs
+++ b/components/layout/table/layout.rs
@@ -2867,6 +2867,7 @@ impl TableSlotCell {
block: vertical_align_offset,
};
let vertical_align_fragment = PositioningFragment::new_anonymous(
+ self.base.style.clone(),
vertical_align_fragment_rect.as_physical(None),
layout.layout.fragments,
);
diff --git a/components/layout/table/mod.rs b/components/layout/table/mod.rs
index 8e2783e2919..72b67863e7d 100644
--- a/components/layout/table/mod.rs
+++ b/components/layout/table/mod.rs
@@ -76,16 +76,20 @@ pub(crate) use construct::AnonymousTableContent;
pub use construct::TableBuilder;
use euclid::{Point2D, Size2D, UnknownUnit, Vector2D};
use malloc_size_of_derive::MallocSizeOf;
+use script::layout_dom::ServoLayoutElement;
use servo_arc::Arc;
+use style::context::SharedStyleContext;
use style::properties::ComputedValues;
use style::properties::style_structs::Font;
+use style::selector_parser::PseudoElement;
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 +102,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
@@ -192,6 +194,19 @@ impl Table {
),
}
}
+
+ pub(crate) fn repair_style(
+ &mut self,
+ context: &SharedStyleContext,
+ new_style: &Arc<ComputedValues>,
+ ) {
+ self.style = new_style.clone();
+ self.grid_style = context.stylist.style_for_anonymous::<ServoLayoutElement>(
+ &context.guards,
+ &PseudoElement::ServoTableGrid,
+ new_style,
+ );
+ }
}
type TableSlotCoordinates = Point2D<usize, UnknownUnit>;
@@ -233,6 +248,10 @@ impl TableSlotCell {
pub fn node_id(&self) -> usize {
self.base.base_fragment_info.tag.map_or(0, |tag| tag.node.0)
}
+
+ fn repair_style(&mut self, new_style: &Arc<ComputedValues>) {
+ self.base.repair_style(new_style);
+ }
}
/// A single table slot. It may be an actual cell, or a reference
@@ -292,7 +311,14 @@ 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,
+}
+
+impl TableTrack {
+ fn repair_style(&mut self, new_style: &Arc<ComputedValues>) {
+ self.base.repair_style(new_style);
+ self.shared_background_style = SharedStyle::new(new_style.clone());
+ }
}
#[derive(Debug, MallocSizeOf, PartialEq)]
@@ -317,13 +343,18 @@ 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 {
pub(super) fn is_empty(&self) -> bool {
self.track_range.is_empty()
}
+
+ fn repair_style(&mut self, new_style: &Arc<ComputedValues>) {
+ self.base.repair_style(new_style);
+ self.shared_background_style = SharedStyle::new(new_style.clone());
+ }
}
#[derive(Debug, MallocSizeOf)]
@@ -390,4 +421,22 @@ impl TableLevelBox {
TableLevelBox::Track(track) => track.borrow().base.fragments(),
}
}
+
+ pub(crate) fn repair_style(
+ &self,
+ context: &SharedStyleContext<'_>,
+ new_style: &Arc<ComputedValues>,
+ ) {
+ match self {
+ TableLevelBox::Caption(caption) => caption
+ .borrow_mut()
+ .context
+ .repair_style(context, new_style),
+ TableLevelBox::Cell(cell) => cell.borrow_mut().repair_style(new_style),
+ TableLevelBox::TrackGroup(track_group) => {
+ track_group.borrow_mut().repair_style(new_style);
+ },
+ TableLevelBox::Track(track) => track.borrow_mut().repair_style(new_style),
+ }
+ }
}