mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #16226 - bholley:doomed_nac, r=emilio
stylo: Introduce is_native_anonymous and cull style traversal of doomed NAC Reviewed in https://bugzilla.mozilla.org/show_bug.cgi?id=1352570
This commit is contained in:
commit
fb3c52e792
3 changed files with 24 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue