From c384c21cb657ce36edb728576765758e7d566bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 20 Jan 2018 02:26:59 +0100 Subject: [PATCH] style: Make the MatchingMode in MatchingContext private. It used to be the case that MatchingContext was immutable and thus we didn't care to have accessors. This is no longer true, so let's make this code a bit nicer. --- components/selectors/context.rs | 8 +++++++- components/selectors/matching.rs | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/components/selectors/context.rs b/components/selectors/context.rs index 75abfea9f18..874d782ae88 100644 --- a/components/selectors/context.rs +++ b/components/selectors/context.rs @@ -100,7 +100,7 @@ where Impl: SelectorImpl, { /// Input with the matching mode we should use when matching selectors. - pub matching_mode: MatchingMode, + matching_mode: MatchingMode, /// Input with the bloom filter used to fast-reject selectors. pub bloom_filter: Option<&'a BloomFilter>, /// An optional cache to speed up nth-index-like selectors. @@ -194,6 +194,12 @@ where self.quirks_mode } + /// The matching-mode for this selector-matching operation. + #[inline] + pub fn matching_mode(&self) -> MatchingMode { + self.matching_mode + } + /// The case-sensitivity for class and ID selectors #[inline] pub fn classes_and_ids_case_sensitivity(&self) -> CaseSensitivity { diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs index 6b1fae8cc32..62dcc6b8e72 100644 --- a/components/selectors/matching.rs +++ b/components/selectors/matching.rs @@ -285,7 +285,7 @@ where { // If this is the special pseudo-element mode, consume the ::pseudo-element // before proceeding, since the caller has already handled that part. - if context.matching_mode == MatchingMode::ForStatelessPseudoElement && + if context.matching_mode() == MatchingMode::ForStatelessPseudoElement && !context.is_nested() { // Consume the pseudo. match *iter.next().unwrap() { @@ -349,7 +349,7 @@ fn matches_hover_and_active_quirk( // This compound selector had a pseudo-element to the right that we // intentionally skipped. if rightmost == Rightmost::Yes && - context.matching_mode == MatchingMode::ForStatelessPseudoElement { + context.matching_mode() == MatchingMode::ForStatelessPseudoElement { return MatchesHoverAndActiveQuirk::No; }