style: Avoid propagating the restyle flag all through the dom when a node gets dirty.

This puts us in pair with stylo.
This commit is contained in:
Emilio Cobos Álvarez 2016-07-22 19:33:53 -07:00
parent 96ea1a335c
commit d81fe27b11
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 21 additions and 35 deletions

View file

@ -153,10 +153,24 @@ pub trait DomTraversalContext<N: TNode> {
///
/// 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 }
fn should_process(&self, node: N) -> bool {
node.is_dirty() || node.has_dirty_descendants()
}
/// Do an action over the child before pushing him to the work queue.
fn pre_process_child_hook(&self, _parent: N, _kid: N) {}
///
/// By default, propagate the IS_DIRTY flag down the tree.
#[allow(unsafe_code)]
fn pre_process_child_hook(&self, parent: N, kid: N) {
// NOTE: At this point is completely safe to modify either the parent or
// the child, since we have exclusive access to both of them.
if parent.is_dirty() {
unsafe {
kid.set_dirty(true);
parent.set_dirty_descendants(true);
}
}
}
}
/// Calculates the style for a single node.