mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
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:
parent
96ea1a335c
commit
d81fe27b11
4 changed files with 21 additions and 35 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue