diff --git a/components/style/cache.rs b/components/style/cache.rs index a2432ee9fa7..2b12c8acf8f 100644 --- a/components/style/cache.rs +++ b/components/style/cache.rs @@ -31,6 +31,11 @@ impl LRUCache { } } + /// Returns the number of elements in the cache. + pub fn num_entries(&self) -> usize { + self.entries.len() + } + #[inline] /// Touch a given position, and put it in the last item on the list. pub fn touch(&mut self, pos: usize) { diff --git a/components/style/matching.rs b/components/style/matching.rs index aa8492a26bf..e7433fdc002 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -265,6 +265,11 @@ impl StyleSharingCandidateCache { } } + /// Returns the number of entries in the cache. + pub fn num_entries(&self) -> usize { + self.cache.num_entries() + } + fn iter_mut(&mut self) -> LRUCacheMutIterator> { self.cache.iter_mut() } @@ -1029,18 +1034,22 @@ pub trait MatchMethods : TElement { data: &mut AtomicRefMut) -> StyleSharingResult { if is_share_style_cache_disabled() { + debug!("{:?} Cannot share style: style sharing cache disabled", self); return StyleSharingResult::CannotShare } if self.parent_element().is_none() { + debug!("{:?} Cannot share style: element has style attribute", self); return StyleSharingResult::CannotShare } if self.style_attribute().is_some() { + debug!("{:?} Cannot share style: element has style attribute", self); return StyleSharingResult::CannotShare } if self.has_attr(&ns!(), &local_name!("id")) { + debug!("{:?} Cannot share style: element has id", self); return StyleSharingResult::CannotShare } @@ -1101,6 +1110,9 @@ pub trait MatchMethods : TElement { } } } + + debug!("{:?} Cannot share style: {} cache entries", self, cache.num_entries()); + if should_clear_cache { cache.clear(); }