From d61c9a8d31ff7d5c3b6962fa815f17de850a12d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 24 Nov 2017 15:15:38 +0100 Subject: [PATCH] style: Bring back the optimization to avoid traversing XBL subtrees that will likely change. We need to get rid of BindingHolder to handle properly the case of an invalid binding URL. Bug: 1420496 Reviewed-by: heycam MozReview-Commit-ID: 3sIGtcVOt0r --- components/style/properties/gecko.mako.rs | 4 ++-- components/style/traversal.rs | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 2030a27f503..f4bdd136f61 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -296,7 +296,7 @@ impl ComputedValuesInner { #[allow(non_snake_case)] pub fn has_moz_binding(&self) -> bool { - !self.get_box().gecko.mBinding.mPtr.mRawPtr.is_null() + !self.get_box().gecko.mBinding.mRawPtr.is_null() } // FIXME(bholley): Implement this properly. @@ -3290,7 +3290,7 @@ fn static_assert() { longhands::scroll_snap_coordinate::computed_value::T(vec) } - ${impl_css_url('_moz_binding', 'mBinding.mPtr')} + ${impl_css_url('_moz_binding', 'mBinding')} ${impl_transition_time_value('delay', 'Delay')} ${impl_transition_time_value('duration', 'Duration')} diff --git a/components/style/traversal.rs b/components/style/traversal.rs index b646b715d89..da7750d1ff0 100644 --- a/components/style/traversal.rs +++ b/components/style/traversal.rs @@ -255,6 +255,7 @@ pub trait DomTraversal : Sync { context: &mut StyleContext, parent: E, parent_data: &ElementData, + is_initial_style: bool, ) -> bool { debug_assert!(parent.has_current_styles_for_traversal( parent_data, @@ -267,6 +268,21 @@ pub trait DomTraversal : Sync { return true; } + // Gecko-only XBL handling. + // + // When we apply the XBL binding during frame construction, we restyle + // the whole subtree again if the binding is valid, so assuming it's + // likely to load valid bindings, we avoid wasted work here, which may + // be a very big perf hit when elements with bindings are nested + // heavily. + if cfg!(feature = "gecko") && + is_initial_style && + parent_data.styles.primary().has_moz_binding() + { + debug!("Parent {:?} has XBL binding, deferring traversal", parent); + return true; + } + return false; } @@ -476,7 +492,7 @@ where traverse_children = traverse_children && - !traversal.should_cull_subtree(context, element, &data); + !traversal.should_cull_subtree(context, element, &data, is_initial_style); // Examine our children, and enqueue the appropriate ones for traversal. if traverse_children {