diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-10-28 01:48:08 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-10-28 02:13:59 +0200 |
commit | 4b43b7c7f851aebb518957a96137a72c26ee5d3f (patch) | |
tree | 212db2581fe61aa9c777ecdd3e2c88b2785a4a80 /components/style/sharing/checks.rs | |
parent | 328f142f38d8522ad9b0b3d360e000091221ecb8 (diff) | |
download | servo-4b43b7c7f851aebb518957a96137a72c26ee5d3f.tar.gz servo-4b43b7c7f851aebb518957a96137a72c26ee5d3f.zip |
style: Make style sharing look at XBL / Shadow DOM rules.
Bug: 1412251
Reviewed-by: bz
MozReview-Commit-ID: II6lk6OmSZU
Diffstat (limited to 'components/style/sharing/checks.rs')
-rw-r--r-- | components/style/sharing/checks.rs | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/components/style/sharing/checks.rs b/components/style/sharing/checks.rs index 20020b9497b..9cba67ca0f3 100644 --- a/components/style/sharing/checks.rs +++ b/components/style/sharing/checks.rs @@ -6,7 +6,6 @@ //! quickly whether it's worth to share style, and whether two different //! elements can indeed share the same style. -use Atom; use bloom::StyleBloom; use context::{SelectorFlagsMap, SharedStyleContext}; use dom::TElement; @@ -96,14 +95,16 @@ pub fn have_same_class<E>(target: &mut StyleSharingTarget<E>, /// :first-child, etc, or on attributes that we don't check off-hand (pretty /// much every attribute selector except `id` and `class`. #[inline] -pub fn revalidate<E>(target: &mut StyleSharingTarget<E>, - candidate: &mut StyleSharingCandidate<E>, - shared_context: &SharedStyleContext, - bloom: &StyleBloom<E>, - nth_index_cache: &mut NthIndexCache, - selector_flags_map: &mut SelectorFlagsMap<E>) - -> bool - where E: TElement, +pub fn revalidate<E>( + target: &mut StyleSharingTarget<E>, + candidate: &mut StyleSharingCandidate<E>, + shared_context: &SharedStyleContext, + bloom: &StyleBloom<E>, + nth_index_cache: &mut NthIndexCache, + selector_flags_map: &mut SelectorFlagsMap<E>, +) -> bool +where + E: TElement, { let stylist = &shared_context.stylist; @@ -130,16 +131,25 @@ pub fn revalidate<E>(target: &mut StyleSharingTarget<E>, /// Checks whether we might have rules for either of the two ids. #[inline] -pub fn may_have_rules_for_ids(shared_context: &SharedStyleContext, - element_id: Option<&Atom>, - candidate_id: Option<&Atom>) -> bool +pub fn may_match_different_id_rules<E>( + shared_context: &SharedStyleContext, + element: E, + candidate: E, +) -> bool +where + E: TElement, { - // We shouldn't be called unless the ids are different. - debug_assert!(element_id.is_some() || candidate_id.is_some()); + let element_id = element.get_id(); + let candidate_id = candidate.get_id(); + + if element_id == candidate_id { + return false; + } + let stylist = &shared_context.stylist; let may_have_rules_for_element = match element_id { - Some(id) => stylist.may_have_rules_for_id(id), + Some(ref id) => stylist.may_have_rules_for_id(id, element), None => false }; @@ -148,7 +158,7 @@ pub fn may_have_rules_for_ids(shared_context: &SharedStyleContext, } match candidate_id { - Some(id) => stylist.may_have_rules_for_id(id), + Some(ref id) => stylist.may_have_rules_for_id(id, candidate), None => false } } |