diff --git a/components/style/traversal.rs b/components/style/traversal.rs index e4b1d8f11de..69521c1557a 100644 --- a/components/style/traversal.rs +++ b/components/style/traversal.rs @@ -148,7 +148,11 @@ pub trait DomTraversalContext { /// Process `node` on the way up, after its children have been processed. fn process_postorder(&self, node: N); - /// Returns if the node should be processed by the preorder traversal. + /// Returns if the node should be processed by the preorder traversal (and + /// then by the post-order one). + /// + /// Note that this is true unconditionally for servo, since it requires to + /// bubble the widths bottom-up for all the DOM. fn should_process(&self, _node: N) -> bool { true } /// Do an action over the child before pushing him to the work queue. diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 95f316f5cc1..288e65431e5 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -113,13 +113,13 @@ fn restyle_subtree(node: GeckoNode, raw_data: *mut RawServoStyleSet) { timer: Timer::new(), }; - if node.is_dirty() || node.has_dirty_descendants() { - if per_doc_data.num_threads == 1 { - sequential::traverse_dom::(node, &shared_style_context); - } else { - parallel::traverse_dom::(node, &shared_style_context, - &mut per_doc_data.work_queue); - } + // We ensure this is true before calling Servo_RestyleSubtree() + debug_assert!(node.is_dirty() || node.has_dirty_descendants()); + if per_doc_data.num_threads == 1 { + sequential::traverse_dom::(node, &shared_style_context); + } else { + parallel::traverse_dom::(node, &shared_style_context, + &mut per_doc_data.work_queue); } } diff --git a/ports/geckolib/traversal.rs b/ports/geckolib/traversal.rs index 6a3667e0b96..562153baf07 100644 --- a/ports/geckolib/traversal.rs +++ b/ports/geckolib/traversal.rs @@ -36,12 +36,14 @@ impl<'lc, 'ln> DomTraversalContext> for RecalcStyleOnly<'lc> { recalc_style_at(&self.context, self.root, node); } + fn process_postorder(&self, _: GeckoNode<'ln>) {} + + /// In Gecko we use this traversal just for restyling, so we can stop once + /// we know there aren't more dirty nodes under ourselves. fn should_process(&self, node: GeckoNode<'ln>) -> bool { node.is_dirty() || node.has_dirty_descendants() } - fn process_postorder(&self, _: GeckoNode<'ln>) {} - fn pre_process_child_hook(&self, parent: GeckoNode<'ln>, kid: GeckoNode<'ln>) { // NOTE: At this point is completely safe to modify either the parent or // the child, since we have exclusive access to them.