From 9092e6b4c2086f9380a397a5f03ca429d1b6045f Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Tue, 12 Sep 2017 16:42:04 -0700 Subject: [PATCH] Return the element rather than styles from the style sharing cache. This gives us more flexibility, and doesn't cost us anything. MozReview-Commit-ID: CuvOEcLA3My --- components/style/sharing/mod.rs | 9 ++++----- components/style/traversal.rs | 5 +++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/style/sharing/mod.rs b/components/style/sharing/mod.rs index db980a8c79a..435944bb1c7 100644 --- a/components/style/sharing/mod.rs +++ b/components/style/sharing/mod.rs @@ -70,7 +70,6 @@ use atomic_refcell::{AtomicRefCell, AtomicRefMut}; use bloom::StyleBloom; use cache::LRUCache; use context::{SelectorFlagsMap, SharedStyleContext, StyleContext}; -use data::ElementStyles; use dom::{TElement, SendElement}; use matching::MatchMethods; use owning_ref::OwningHandle; @@ -377,7 +376,7 @@ impl StyleSharingTarget { pub fn share_style_if_possible( &mut self, context: &mut StyleContext, - ) -> Option { + ) -> Option { let cache = &mut context.thread_local.sharing_cache; let shared_context = &context.shared; let selector_flags_map = &mut context.thread_local.selector_flags; @@ -435,7 +434,7 @@ impl SharingCache { }); } - fn lookup(&mut self, mut is_match: F) -> Option + fn lookup(&mut self, mut is_match: F) -> Option where F: FnMut(&mut StyleSharingCandidate) -> bool { @@ -453,7 +452,7 @@ impl SharingCache { self.entries.touch(i); let front = self.entries.front_mut().unwrap(); debug_assert!(is_match(front)); - Some(front.element.borrow_data().unwrap().styles.clone()) + Some(front.element) } } } @@ -610,7 +609,7 @@ impl StyleSharingCache { selector_flags_map: &mut SelectorFlagsMap, bloom_filter: &StyleBloom, target: &mut StyleSharingTarget, - ) -> Option { + ) -> Option { if shared_context.options.disable_style_sharing_cache { debug!("{:?} Cannot share style: style sharing cache disabled", target.element); diff --git a/components/style/traversal.rs b/components/style/traversal.rs index fdab3ab73c6..dc422f64cad 100644 --- a/components/style/traversal.rs +++ b/components/style/traversal.rs @@ -655,9 +655,10 @@ where // Now that our bloom filter is set up, try the style sharing // cache. match target.share_style_if_possible(context) { - Some(styles) => { + Some(shareable_element) => { context.thread_local.statistics.styles_shared += 1; - styles + let shareable_data = shareable_element.borrow_data().unwrap(); + shareable_data.styles.clone() } None => { context.thread_local.statistics.elements_matched += 1;