diff options
author | Oriol Brufau <obrufau@igalia.com> | 2023-08-16 08:24:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-16 06:24:42 +0000 |
commit | d6ae8dc112deb479f345c94970dde442332c8c27 (patch) | |
tree | 0d0f19804d9ee17d5e51b7285fed739a65390a71 /components/style/sharing/mod.rs | |
parent | 8e15389caedd9b8e1b87cc9e4bfe8350a581546d (diff) | |
download | servo-d6ae8dc112deb479f345c94970dde442332c8c27.tar.gz servo-d6ae8dc112deb479f345c94970dde442332c8c27.zip |
Revert "Backport several style changes from Gecko (5) (#30099)" (#30104)
This reverts commit 8e15389caedd9b8e1b87cc9e4bfe8350a581546d.
Diffstat (limited to 'components/style/sharing/mod.rs')
-rw-r--r-- | components/style/sharing/mod.rs | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/components/style/sharing/mod.rs b/components/style/sharing/mod.rs index 91e4f02e084..50eb51fba35 100644 --- a/components/style/sharing/mod.rs +++ b/components/style/sharing/mod.rs @@ -66,8 +66,9 @@ use crate::applicable_declarations::ApplicableDeclarationBlock; use crate::bloom::StyleBloom; -use crate::context::{SharedStyleContext, StyleContext}; +use crate::context::{SelectorFlagsMap, SharedStyleContext, StyleContext}; use crate::dom::{SendElement, TElement}; +use crate::matching::MatchMethods; use crate::properties::ComputedValues; use crate::rule_tree::StrongRuleNode; use crate::style_resolver::{PrimaryStyle, ResolvedElementStyles}; @@ -75,7 +76,7 @@ use crate::stylist::Stylist; use crate::values::AtomIdent; use atomic_refcell::{AtomicRefCell, AtomicRefMut}; use owning_ref::OwningHandle; -use selectors::matching::{VisitedHandlingMode, NeedsSelectorFlags}; +use selectors::matching::{ElementSelectorFlags, VisitedHandlingMode}; use selectors::NthIndexCache; use servo_arc::Arc; use smallbitvec::SmallBitVec; @@ -222,17 +223,18 @@ impl ValidationData { /// Computes the revalidation results if needed, and returns it. /// Inline so we know at compile time what bloom_known_valid is. #[inline] - fn revalidation_match_results<E>( + fn revalidation_match_results<E, F>( &mut self, element: E, stylist: &Stylist, bloom: &StyleBloom<E>, nth_index_cache: &mut NthIndexCache, bloom_known_valid: bool, - needs_selector_flags: NeedsSelectorFlags, + flags_setter: &mut F, ) -> &SmallBitVec where E: TElement, + F: FnMut(&E, ElementSelectorFlags), { self.revalidation_match_results.get_or_insert_with(|| { // The bloom filter may already be set up for our element. @@ -255,7 +257,7 @@ impl ValidationData { element, bloom_to_use, nth_index_cache, - needs_selector_flags, + flags_setter, ) }) } @@ -325,9 +327,7 @@ impl<E: TElement> StyleSharingCandidate<E> { bloom, nth_index_cache, /* bloom_known_valid = */ false, - // The candidate must already have the right bits already, if - // needed. - NeedsSelectorFlags::No, + &mut |_, _| {}, ) } } @@ -384,6 +384,7 @@ impl<E: TElement> StyleSharingTarget<E> { stylist: &Stylist, bloom: &StyleBloom<E>, nth_index_cache: &mut NthIndexCache, + selector_flags_map: &mut SelectorFlagsMap<E>, ) -> &SmallBitVec { // It's important to set the selector flags. Otherwise, if we succeed in // sharing the style, we may not set the slow selector flags for the @@ -400,13 +401,18 @@ impl<E: TElement> StyleSharingTarget<E> { // The style sharing cache will get a hit for the second span. When the // child span is subsequently removed from the DOM, missing selector // flags would cause us to miss the restyle on the second span. + let element = self.element; + let mut set_selector_flags = |el: &E, flags: ElementSelectorFlags| { + element.apply_selector_flags(selector_flags_map, el, flags); + }; + self.validation_data.revalidation_match_results( self.element, stylist, bloom, nth_index_cache, /* bloom_known_valid = */ true, - NeedsSelectorFlags::Yes, + &mut set_selector_flags, ) } @@ -417,6 +423,7 @@ impl<E: TElement> StyleSharingTarget<E> { ) -> Option<ResolvedElementStyles> { let cache = &mut context.thread_local.sharing_cache; let shared_context = &context.shared; + let selector_flags_map = &mut context.thread_local.selector_flags; let bloom_filter = &context.thread_local.bloom_filter; let nth_index_cache = &mut context.thread_local.nth_index_cache; @@ -436,6 +443,7 @@ impl<E: TElement> StyleSharingTarget<E> { cache.share_style_if_possible( shared_context, + selector_flags_map, bloom_filter, nth_index_cache, self, @@ -623,13 +631,13 @@ impl<E: TElement> StyleSharingCache<E> { // // These are things we don't check in the candidate match because they // are either uncommon or expensive. - let ui_style = style.style().get_ui(); - if ui_style.specifies_transitions() { + let box_style = style.style().get_box(); + if box_style.specifies_transitions() { debug!("Failing to insert to the cache: transitions"); return; } - if ui_style.specifies_animations() { + if box_style.specifies_animations() { debug!("Failing to insert to the cache: animations"); return; } @@ -659,6 +667,7 @@ impl<E: TElement> StyleSharingCache<E> { fn share_style_if_possible( &mut self, shared_context: &SharedStyleContext, + selector_flags_map: &mut SelectorFlagsMap<E>, bloom_filter: &StyleBloom<E>, nth_index_cache: &mut NthIndexCache, target: &mut StyleSharingTarget<E>, @@ -691,6 +700,7 @@ impl<E: TElement> StyleSharingCache<E> { &shared_context, bloom_filter, nth_index_cache, + selector_flags_map, shared_context, ) }) @@ -702,6 +712,7 @@ impl<E: TElement> StyleSharingCache<E> { shared: &SharedStyleContext, bloom: &StyleBloom<E>, nth_index_cache: &mut NthIndexCache, + selector_flags_map: &mut SelectorFlagsMap<E>, shared_context: &SharedStyleContext, ) -> Option<ResolvedElementStyles> { debug_assert!(!target.is_in_native_anonymous_subtree()); @@ -806,6 +817,7 @@ impl<E: TElement> StyleSharingCache<E> { shared, bloom, nth_index_cache, + selector_flags_map, ) { trace!("Miss: Revalidation"); return None; |