Introduce is_native_anonymous and cull style traversal of doomed native anonymous content.

MozReview-Commit-ID: LqwmavJnqW
This commit is contained in:
Bobby Holley 2017-02-23 14:55:26 -08:00
parent e2671459cb
commit 7e3671fc4c
3 changed files with 24 additions and 0 deletions

View file

@ -386,6 +386,10 @@ pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + Pre
unsafe fn unset_animation_only_dirty_descendants(&self) {
}
/// Returns true if this element is native anonymous (only Gecko has native
/// anonymous content).
fn is_native_anonymous(&self) -> bool { false }
/// Atomically stores the number of children of this node that we will
/// need to process during bottom-up traversal.
fn store_children_to_process(&self, n: isize);

View file

@ -47,6 +47,7 @@ use gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel;
use gecko_bindings::structs::NODE_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO;
use gecko_bindings::structs::NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO;
use gecko_bindings::structs::NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE;
use gecko_bindings::structs::NODE_IS_NATIVE_ANONYMOUS;
use gecko_bindings::sugar::ownership::HasArcFFI;
use parking_lot::RwLock;
use parser::ParserContextExtraData;
@ -543,6 +544,10 @@ impl<'le> TElement for GeckoElement<'le> {
self.unset_flags(NODE_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO as u32)
}
fn is_native_anonymous(&self) -> bool {
self.flags() & (NODE_IS_NATIVE_ANONYMOUS as u32) != 0
}
fn store_children_to_process(&self, _: isize) {
// This is only used for bottom-up traversal, and is thus a no-op for Gecko.
}

View file

@ -182,6 +182,21 @@ pub trait DomTraversal<E: TElement> : Sync {
match node.as_element() {
None => Self::text_node_needs_traversal(node),
Some(el) => {
// If the element is native-anonymous and an ancestor frame will
// be reconstructed, the child and all its descendants will be
// destroyed. In that case, we don't need to traverse the subtree.
if el.is_native_anonymous() {
if let Some(parent) = el.parent_element() {
let parent_data = parent.borrow_data().unwrap();
if let Some(r) = parent_data.get_restyle() {
if (r.damage | r.damage_handled()).contains(RestyleDamage::reconstruct()) {
debug!("Element {:?} is in doomed NAC subtree - culling traversal", el);
return false;
}
}
}
}
// In case of animation-only traversal we need to traverse
// the element if the element has animation only dirty
// descendants bit, animation-only restyle hint or recascade.