diff options
author | Oriol Brufau <obrufau@igalia.com> | 2025-05-24 01:40:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-23 23:40:02 +0000 |
commit | d18000fee8d1f4ef95be21525b013ca5213f9d59 (patch) | |
tree | b68d09c046e8670cf64a2f9a4fd49b7e66d39eb0 /components/layout/layout_impl.rs | |
parent | 1f5087d7734e464ef2cdf7db25c143a5e5720b6a (diff) | |
download | servo-d18000fee8d1f4ef95be21525b013ca5213f9d59.tar.gz servo-d18000fee8d1f4ef95be21525b013ca5213f9d59.zip |
Add another incremental layout that starts at stacking tree construction (#37088)
This allows to skip rebuilding the box tree when it's only necessary to
rebuild the stacking context tree.
Bumps Stylo to https://github.com/servo/stylo/pull/187
Testing: Unneeded (no behavior change). Just improving performance.
However, this adds a new test for dynamic changes of `z-index`, which we
were breaking in an earlier iteration of this patch.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/layout/layout_impl.rs')
-rw-r--r-- | components/layout/layout_impl.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/components/layout/layout_impl.rs b/components/layout/layout_impl.rs index 4ab69976671..3452c9a6e4c 100644 --- a/components/layout/layout_impl.rs +++ b/components/layout/layout_impl.rs @@ -646,7 +646,7 @@ impl LayoutThread { highlighted_dom_node: reflow_request.highlighted_dom_node, }; - let did_reflow = self.restyle_and_build_trees( + let damage = self.restyle_and_build_trees( &reflow_request, root_element, rayon_pool, @@ -654,7 +654,7 @@ impl LayoutThread { viewport_changed, ); - self.build_stacking_context_tree(&reflow_request, did_reflow); + self.build_stacking_context_tree(&reflow_request, damage); self.build_display_list(&reflow_request, &mut layout_context); self.first_reflow.set(false); @@ -744,7 +744,7 @@ impl LayoutThread { rayon_pool: Option<&ThreadPool>, layout_context: &mut LayoutContext<'_>, viewport_changed: bool, - ) -> bool { + ) -> RestyleDamage { let dirty_root = unsafe { ServoLayoutNode::new(&reflow_request.dirty_root.unwrap()) .as_element() @@ -760,7 +760,7 @@ impl LayoutThread { if !token.should_traverse() { layout_context.style_context.stylist.rule_tree().maybe_gc(); - return false; + return RestyleDamage::empty(); } let dirty_root: ServoLayoutNode = @@ -768,9 +768,9 @@ impl LayoutThread { let root_node = root_element.as_node(); let damage = compute_damage_and_repair_style(layout_context.shared_context(), root_node); - if !viewport_changed && (damage.is_empty() || damage == RestyleDamage::REPAINT) { + if !viewport_changed && !damage.contains(RestyleDamage::REBUILD_BOX) { layout_context.style_context.stylist.rule_tree().maybe_gc(); - return false; + return damage; } let mut box_tree = self.box_tree.borrow_mut(); @@ -828,10 +828,10 @@ impl LayoutThread { // GC the rule tree if some heuristics are met. layout_context.style_context.stylist.rule_tree().maybe_gc(); - true + damage } - fn build_stacking_context_tree(&self, reflow_request: &ReflowRequest, did_reflow: bool) { + fn build_stacking_context_tree(&self, reflow_request: &ReflowRequest, damage: RestyleDamage) { if !reflow_request.reflow_goal.needs_display_list() && !reflow_request.reflow_goal.needs_display() { @@ -840,7 +840,9 @@ impl LayoutThread { let Some(fragment_tree) = &*self.fragment_tree.borrow() else { return; }; - if !did_reflow && self.stacking_context_tree.borrow().is_some() { + if !damage.contains(RestyleDamage::REBUILD_STACKING_CONTEXT) && + self.stacking_context_tree.borrow().is_some() + { return; } |