mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
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>
This commit is contained in:
parent
db83601b62
commit
a0dd2c1beb
24 changed files with 369 additions and 187 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue