diff options
author | Bobby Holley <bobbyholley@gmail.com> | 2017-04-08 20:05:38 +0800 |
---|---|---|
committer | Bobby Holley <bobbyholley@gmail.com> | 2017-04-09 14:52:49 +0800 |
commit | 3f52052cf9699020326fb6d0f3965b0402d79beb (patch) | |
tree | a6825088f7bee3d5dbd203e304370c0fa3295b24 /components/style/traversal.rs | |
parent | 1b363ac9094594110908793c0e2af12cd011e55e (diff) | |
download | servo-3f52052cf9699020326fb6d0f3965b0402d79beb.tar.gz servo-3f52052cf9699020326fb6d0f3965b0402d79beb.zip |
Do the sequential traversal breadth-first.
While we're at it, we also eliminate the 'unknown' dom depth for the
bloom filter. Computing depth has negligible cost relative to the
amount of work we do setting up the bloom filter at a given depth.
Doing it once per traversal should be totally fine.
I originally separated the elimination of unknown dom depth from the
traversal changes, but I got bloom filter crashes on the intermediate
patch, presumably because I didn't properly fix the sequential traversal
for this case. Given that the final state is green, I just decided to
squash and move on.
Diffstat (limited to 'components/style/traversal.rs')
-rw-r--r-- | components/style/traversal.rs | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/components/style/traversal.rs b/components/style/traversal.rs index 2e35c37904e..f5be141cb66 100644 --- a/components/style/traversal.rs +++ b/components/style/traversal.rs @@ -23,11 +23,11 @@ use stylist::Stylist; /// NB: Keep this as small as possible, please! #[derive(Clone, Debug)] pub struct PerLevelTraversalData { - /// The current dom depth, if known, or `None` otherwise. + /// The current dom depth. /// /// This is kept with cooperation from the traversal code and the bloom /// filter. - pub current_dom_depth: Option<usize>, + pub current_dom_depth: usize, } bitflags! { @@ -119,7 +119,7 @@ pub trait DomTraversal<E: TElement> : Sync { type ThreadLocalContext: Send + BorrowMut<ThreadLocalStyleContext<E>>; /// Process `node` on the way down, before its children have been processed. - fn process_preorder(&self, data: &mut PerLevelTraversalData, + fn process_preorder(&self, data: &PerLevelTraversalData, thread_local: &mut Self::ThreadLocalContext, node: E::ConcreteNode); @@ -521,7 +521,7 @@ pub fn resolve_style<E, F, G, H>(context: &mut StyleContext<E>, element: E, #[inline] #[allow(unsafe_code)] pub fn recalc_style_at<E, D>(traversal: &D, - traversal_data: &mut PerLevelTraversalData, + traversal_data: &PerLevelTraversalData, context: &mut StyleContext<E>, element: E, mut data: &mut AtomicRefMut<ElementData>) @@ -619,7 +619,7 @@ pub fn recalc_style_at<E, D>(traversal: &D, } fn compute_style<E, D>(_traversal: &D, - traversal_data: &mut PerLevelTraversalData, + traversal_data: &PerLevelTraversalData, context: &mut StyleContext<E>, element: E, mut data: &mut AtomicRefMut<ElementData>) @@ -650,16 +650,8 @@ fn compute_style<E, D>(_traversal: &D, match kind { MatchAndCascade => { // Ensure the bloom filter is up to date. - let dom_depth = - context.thread_local.bloom_filter - .insert_parents_recovering(element, - traversal_data.current_dom_depth); - - // Update the dom depth with the up-to-date dom depth. - // - // Note that this is always the same than the pre-existing depth, - // but it can change from unknown to known at this step. - traversal_data.current_dom_depth = Some(dom_depth); + context.thread_local.bloom_filter + .insert_parents_recovering(element, traversal_data.current_dom_depth); context.thread_local.bloom_filter.assert_complete(element); context.thread_local.statistics.elements_matched += 1; |