mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
layout: Skip box tree construction when possible (#37957)
When a style change does not chang the structure of the box tree, it is possible to skip box tree rebuilding for an element. This change adds support for reusing old box trees when no element has that type of damage. In order to make this happen, there needs to be a type of "empty" `LayoutDamage` that just indicates that a fragment tree layout is necessary. This is the first step toward incremental fragment tree layout. Testing: This should not change observable behavior and thus is covered by existing WPT tests. Performance numbers to follow. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
d5d131c172
commit
436c9072c4
13 changed files with 181 additions and 78 deletions
|
@ -77,24 +77,24 @@ pub(super) enum LayoutBox {
|
|||
}
|
||||
|
||||
impl LayoutBox {
|
||||
fn invalidate_cached_fragment(&self) {
|
||||
fn clear_fragment_layout_cache(&self) {
|
||||
match self {
|
||||
LayoutBox::DisplayContents(..) => {},
|
||||
LayoutBox::BlockLevel(block_level_box) => {
|
||||
block_level_box.borrow().invalidate_cached_fragment()
|
||||
block_level_box.borrow().clear_fragment_layout_cache()
|
||||
},
|
||||
LayoutBox::InlineLevel(inline_items) => {
|
||||
for inline_item in inline_items.iter() {
|
||||
inline_item.borrow().invalidate_cached_fragment()
|
||||
inline_item.borrow().clear_fragment_layout_cache()
|
||||
}
|
||||
},
|
||||
LayoutBox::FlexLevel(flex_level_box) => {
|
||||
flex_level_box.borrow().invalidate_cached_fragment()
|
||||
flex_level_box.borrow().clear_fragment_layout_cache()
|
||||
},
|
||||
LayoutBox::TaffyItemBox(taffy_item_box) => {
|
||||
taffy_item_box.borrow_mut().invalidate_cached_fragment()
|
||||
taffy_item_box.borrow_mut().clear_fragment_layout_cache()
|
||||
},
|
||||
LayoutBox::TableLevelBox(table_box) => table_box.invalidate_cached_fragment(),
|
||||
LayoutBox::TableLevelBox(table_box) => table_box.clear_fragment_layout_cache(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ pub(crate) trait NodeExt<'dom> {
|
|||
fn unset_all_pseudo_boxes(&self);
|
||||
|
||||
fn fragments_for_pseudo(&self, pseudo_element: Option<PseudoElement>) -> Vec<Fragment>;
|
||||
fn invalidate_cached_fragment(&self);
|
||||
fn clear_fragment_layout_cache(&self);
|
||||
|
||||
fn repair_style(&self, context: &SharedStyleContext);
|
||||
fn take_restyle_damage(&self) -> LayoutDamage;
|
||||
|
@ -381,15 +381,15 @@ impl<'dom> NodeExt<'dom> for ServoLayoutNode<'dom> {
|
|||
self.layout_data_mut().pseudo_boxes.clear();
|
||||
}
|
||||
|
||||
fn invalidate_cached_fragment(&self) {
|
||||
fn clear_fragment_layout_cache(&self) {
|
||||
let data = self.layout_data_mut();
|
||||
if let Some(data) = data.self_box.borrow_mut().as_ref() {
|
||||
data.invalidate_cached_fragment();
|
||||
data.clear_fragment_layout_cache();
|
||||
}
|
||||
|
||||
for pseudo_layout_data in data.pseudo_boxes.iter() {
|
||||
if let Some(layout_box) = pseudo_layout_data.box_slot.borrow().as_ref() {
|
||||
layout_box.invalidate_cached_fragment();
|
||||
layout_box.clear_fragment_layout_cache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue