Don't traverse any elements that needed only for animation-only restyles in normal traversal.

Before this patch, we were setting the dirty descendants bit in animation-only
restyles and it triggered unnecessary traversal for elements that does not need
the traversal (i.e no need selector matching).
This commit is contained in:
Hiroyuki Ikezoe 2017-06-19 15:01:16 +09:00
parent 5a8e2562d5
commit a3da636f69
2 changed files with 11 additions and 3 deletions

View file

@ -462,7 +462,11 @@ pub trait DomTraversal<E: TElement> : Sync {
let el = kid.as_element(); let el = kid.as_element();
if el.as_ref().and_then(|el| el.borrow_data()) if el.as_ref().and_then(|el| el.borrow_data())
.map_or(false, |d| d.has_styles()) { .map_or(false, |d| d.has_styles()) {
unsafe { parent.set_dirty_descendants(); } if self.shared_context().traversal_flags.for_animation_only() {
unsafe { parent.set_animation_only_dirty_descendants(); }
} else {
unsafe { parent.set_dirty_descendants(); }
}
} }
} }
f(thread_local, kid); f(thread_local, kid);

View file

@ -300,7 +300,9 @@ pub extern "C" fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
return false; return false;
} }
element.has_dirty_descendants() || element.borrow_data().unwrap().restyle.contains_restyle_data() element.has_dirty_descendants() ||
element.has_animation_only_dirty_descendants() ||
element.borrow_data().unwrap().restyle.contains_restyle_data()
} }
/// Checks whether the rule tree has crossed its threshold for unused nodes, and /// Checks whether the rule tree has crossed its threshold for unused nodes, and
@ -2801,7 +2803,9 @@ pub extern "C" fn Servo_AssertTreeIsClean(root: RawGeckoElementBorrowed) {
let root = GeckoElement(root); let root = GeckoElement(root);
fn assert_subtree_is_clean<'le>(el: GeckoElement<'le>) { fn assert_subtree_is_clean<'le>(el: GeckoElement<'le>) {
debug_assert!(!el.has_dirty_descendants() && !el.has_animation_only_dirty_descendants()); debug_assert!(!el.has_dirty_descendants() && !el.has_animation_only_dirty_descendants(),
"{:?} has still dirty bit {:?} or animation-only dirty bit {:?}",
el, el.has_dirty_descendants(), el.has_animation_only_dirty_descendants());
for child in el.as_node().traversal_children() { for child in el.as_node().traversal_children() {
if let Some(child) = child.as_element() { if let Some(child) = child.as_element() {
assert_subtree_is_clean(child); assert_subtree_is_clean(child);