layout: Properly parent table-row and table-row-group (#31619)

Put table cell content fragments into a hieararchy of fragments that
include their table row and table row group fragments. This ensures that
things like relative positioning and transforms set on rows and row
groups properly affect cells and cell content.

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Martin Robinson 2024-03-14 11:33:42 +01:00 committed by GitHub
parent 0e78c8114b
commit 78fe461ff2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 439 additions and 160 deletions

View file

@ -21,6 +21,19 @@ use crate::geom::{
};
use crate::style_ext::ComputedValuesExt;
/// Describes how a [`BoxFragment`] paints its background.
pub(crate) enum BackgroundMode {
/// Draw the normal [`BoxFragment`] background as well as the extra backgrounds
/// based on the style and positioning rectangles in this data structure.
Extra(Vec<ExtraBackground>),
/// Do not draw a background for this Fragment. This is used for elements like
/// table tracks and table track groups, which rely on cells to paint their
/// backgrounds.
None,
/// Draw the background normally, getting information from the Fragment style.
Normal,
}
pub(crate) struct ExtraBackground {
pub style: ServoArc<ComputedValues>,
pub rect: LogicalRect<Au>,
@ -70,7 +83,7 @@ pub(crate) struct BoxFragment {
pub(crate) resolved_sticky_insets: Option<PhysicalSides<LengthOrAuto>>,
#[serde(skip_serializing)]
pub extra_backgrounds: Vec<ExtraBackground>,
pub background_mode: BackgroundMode,
}
impl BoxFragment {
@ -160,7 +173,7 @@ impl BoxFragment {
scrollable_overflow_from_children,
overconstrained,
resolved_sticky_insets: None,
extra_backgrounds: Vec::new(),
background_mode: BackgroundMode::Normal,
}
}
@ -178,7 +191,14 @@ impl BoxFragment {
}
pub fn add_extra_background(&mut self, extra_background: ExtraBackground) {
self.extra_backgrounds.push(extra_background);
match self.background_mode {
BackgroundMode::Extra(ref mut backgrounds) => backgrounds.push(extra_background),
_ => self.background_mode = BackgroundMode::Extra(vec![extra_background]),
}
}
pub fn set_does_not_paint_background(&mut self) {
self.background_mode = BackgroundMode::None;
}
pub fn scrollable_overflow(