From a62f6c78b24df339e4a328fc00ddb78d825dc73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 20 Oct 2022 14:24:35 +0000 Subject: [PATCH] style: Make a wrapper struct for extra matching data No behavior change but we're about to add some extra field to it. Differential Revision: https://phabricator.services.mozilla.com/D159850 --- components/style/gecko/selector_parser.rs | 10 +++++++++- components/style/gecko/wrapper.rs | 2 +- .../style/invalidation/element/document_state.rs | 7 +++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs index 6c975862f19..bf1cad4311d 100644 --- a/components/style/gecko/selector_parser.rs +++ b/components/style/gecko/selector_parser.rs @@ -230,8 +230,16 @@ impl ::selectors::parser::NonTSPseudoClass for NonTSPseudoClass { #[derive(Clone, Debug, Eq, PartialEq)] pub struct SelectorImpl; +/// A set of extra data to carry along with the matching context, either for +/// selector-matching or invalidation. +#[derive(Debug, Default)] +pub struct ExtraMatchingData { + /// The invalidation data to invalidate doc-state pseudo-classes correctly. + pub invalidation_data: InvalidationMatchingData, +} + impl ::selectors::SelectorImpl for SelectorImpl { - type ExtraMatchingData = InvalidationMatchingData; + type ExtraMatchingData = ExtraMatchingData; type AttrValue = AtomString; type Identifier = AtomIdent; type LocalName = AtomIdent; diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index e0fded22e22..92a532907f7 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -2109,7 +2109,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { ); return false; } - if context.extra_data.document_state.intersects(state_bit) { + if context.extra_data.invalidation_data.document_state.intersects(state_bit) { return !context.in_negation(); } self.document_state().contains(state_bit) diff --git a/components/style/invalidation/element/document_state.rs b/components/style/invalidation/element/document_state.rs index f79b70c6cc3..110394549ad 100644 --- a/components/style/invalidation/element/document_state.rs +++ b/components/style/invalidation/element/document_state.rs @@ -17,6 +17,7 @@ use style_traits::dom::DocumentState; /// A struct holding the members necessary to invalidate document state /// selectors. +#[derive(Debug)] pub struct InvalidationMatchingData { /// The document state that has changed, which makes it always match. pub document_state: DocumentState, @@ -43,7 +44,7 @@ impl<'a, E: TElement, I> DocumentStateInvalidationProcessor<'a, E, I> { /// Creates a new DocumentStateInvalidationProcessor. #[inline] pub fn new(rules: I, document_states_changed: DocumentState, quirks_mode: QuirksMode) -> Self { - let mut matching_context = MatchingContext::new_for_visited( + let mut matching_context = MatchingContext::<'a, E::Impl>::new_for_visited( MatchingMode::Normal, None, None, @@ -52,9 +53,7 @@ impl<'a, E: TElement, I> DocumentStateInvalidationProcessor<'a, E, I> { NeedsSelectorFlags::No, ); - matching_context.extra_data = InvalidationMatchingData { - document_state: document_states_changed, - }; + matching_context.extra_data.invalidation_data.document_state = document_states_changed; Self { rules,