aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-04-01 14:34:33 -0500
committerGitHub <noreply@github.com>2017-04-01 14:34:33 -0500
commitfb3c52e7926cc79078cc444da9d547ade407b9b6 (patch)
tree7acdcae88f23a162e90d1202aabbaad86a496b62
parente2671459cbf548eed4399a959c3a870880482778 (diff)
parent7e3671fc4cb65b06b49be6b6322cbbf316da2eaf (diff)
downloadservo-fb3c52e7926cc79078cc444da9d547ade407b9b6.tar.gz
servo-fb3c52e7926cc79078cc444da9d547ade407b9b6.zip
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
-rw-r--r--components/style/dom.rs4
-rw-r--r--components/style/gecko/wrapper.rs5
-rw-r--r--components/style/traversal.rs15
3 files changed, 24 insertions, 0 deletions
diff --git a/components/style/dom.rs b/components/style/dom.rs
index 31319e3655a..602401530ca 100644
--- a/components/style/dom.rs
+++ b/components/style/dom.rs
@@ -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);
diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs
index 3aab96b36f7..2450b885d04 100644
--- a/components/style/gecko/wrapper.rs
+++ b/components/style/gecko/wrapper.rs
@@ -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.
}
diff --git a/components/style/traversal.rs b/components/style/traversal.rs
index fb70be69cc7..9712b3d84af 100644
--- a/components/style/traversal.rs
+++ b/components/style/traversal.rs
@@ -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.