From 1d6892afa30b80a10362900434985d9fbad0cf78 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Fri, 21 Apr 2017 18:22:17 -0700 Subject: [PATCH] Make it clearer that we never insert elements with preshints into the cache. MozReview-Commit-ID: 9bdc0sNZeEy --- components/style/matching.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/components/style/matching.rs b/components/style/matching.rs index 8b01b9305e4..20344b86f21 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -152,7 +152,7 @@ fn element_matches_candidate(element: &E, miss!(Class) } - if !have_same_presentational_hints(element, candidate_element) { + if has_presentational_hints(element) { miss!(PresHints) } @@ -168,18 +168,10 @@ fn element_matches_candidate(element: &E, Ok(current_styles.primary.clone()) } -fn have_same_presentational_hints(element: &E, candidate: &E) -> bool { - let mut first = ForgetfulSink::new(); - element.synthesize_presentational_hints_for_legacy_attributes(&mut first); - - if cfg!(debug_assertions) { - let mut second = vec![]; - candidate.synthesize_presentational_hints_for_legacy_attributes(&mut second); - debug_assert!(second.is_empty(), - "Should never have inserted an element with preshints in the cache!"); - } - - first.is_empty() +fn has_presentational_hints(element: &E) -> bool { + let mut hints = ForgetfulSink::new(); + element.synthesize_presentational_hints_for_legacy_attributes(&mut hints); + !hints.is_empty() } fn have_same_class(element: &E, @@ -296,6 +288,14 @@ impl StyleSharingCandidateCache { return; } + // Make sure we noted any presentational hints in the StyleRelations. + if cfg!(debug_assertions) { + let mut hints = ForgetfulSink::new(); + element.synthesize_presentational_hints_for_legacy_attributes(&mut hints); + debug_assert!(hints.is_empty(), "Style relations should not be shareable!"); + } + + let box_style = style.get_box(); if box_style.specifies_transitions() { debug!("Failing to insert to the cache: transitions");