diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2023-08-12 00:26:15 +0200 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-08-16 17:46:41 +0200 |
commit | 4878422c937222fbf696e52ebdc4f3166a0fb9ae (patch) | |
tree | 5761039ce7f21460eb0a4c189e37ccbd37e3a810 /components/selectors/context.rs | |
parent | db538456940bc9e0beecbccb3a0e7f8b159b0eeb (diff) | |
download | servo-4878422c937222fbf696e52ebdc4f3166a0fb9ae.tar.gz servo-4878422c937222fbf696e52ebdc4f3166a0fb9ae.zip |
style: Simplify selector flags setup even more
In my investigation for bug 1766439, I am digging into why selector
matching regressed.
It doesn't help that the selector-matching code is instantiated a
gazillion times (so there's a ton of copies of the relevant functions).
This was needed in the past because we had different ways of setting the
selector flags on elements, but I unified that recently and now we only
need to either set them or not. That is the kind of thing that
MatchingContext is really good for, so pass that instead on
MatchingContext creation.
Differential Revision: https://phabricator.services.mozilla.com/D145428
Diffstat (limited to 'components/selectors/context.rs')
-rw-r--r-- | components/selectors/context.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/components/selectors/context.rs b/components/selectors/context.rs index 9146b133e38..f595389d2f2 100644 --- a/components/selectors/context.rs +++ b/components/selectors/context.rs @@ -68,6 +68,14 @@ impl VisitedHandlingMode { } } +/// Whether we need to set selector invalidation flags on elements for this +/// match request. +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum NeedsSelectorFlags { + No, + Yes, +} + /// Which quirks mode is this document in. /// /// See: https://quirks.spec.whatwg.org/ @@ -140,6 +148,7 @@ where pub extra_data: Impl::ExtraMatchingData, quirks_mode: QuirksMode, + needs_selector_flags: NeedsSelectorFlags, classes_and_ids_case_sensitivity: CaseSensitivity, _impl: ::std::marker::PhantomData<Impl>, } @@ -154,6 +163,7 @@ where bloom_filter: Option<&'a BloomFilter>, nth_index_cache: Option<&'a mut NthIndexCache>, quirks_mode: QuirksMode, + needs_selector_flags: NeedsSelectorFlags, ) -> Self { Self::new_for_visited( matching_mode, @@ -161,6 +171,7 @@ where nth_index_cache, VisitedHandlingMode::AllLinksUnvisited, quirks_mode, + needs_selector_flags, ) } @@ -171,6 +182,7 @@ where nth_index_cache: Option<&'a mut NthIndexCache>, visited_handling: VisitedHandlingMode, quirks_mode: QuirksMode, + needs_selector_flags: NeedsSelectorFlags, ) -> Self { Self { matching_mode, @@ -179,6 +191,7 @@ where nth_index_cache, quirks_mode, classes_and_ids_case_sensitivity: quirks_mode.classes_and_ids_case_sensitivity(), + needs_selector_flags, scope_element: None, current_host: None, nesting_level: 0, @@ -213,6 +226,12 @@ where self.matching_mode } + /// Whether we need to set selector flags. + #[inline] + pub fn needs_selector_flags(&self) -> bool { + self.needs_selector_flags == NeedsSelectorFlags::Yes + } + /// The case-sensitivity for class and ID selectors #[inline] pub fn classes_and_ids_case_sensitivity(&self) -> CaseSensitivity { |