From 4215d524dcf175fe7c71e42fa8b426ae0ca212a6 Mon Sep 17 00:00:00 2001 From: Masatoshi Kimura Date: Wed, 26 Aug 2020 11:45:35 +0000 Subject: [PATCH] Bug 1658690 - Replace :-moz-native-anonymous-no-specificity with :where(:-moz-native-anonymous). r=emilio Differential Revision: https://phabricator.services.mozilla.com/D88255 --- servo/components/selectors/builder.rs | 10 +++------- servo/components/selectors/parser.rs | 8 -------- .../components/style/gecko/non_ts_pseudo_class_list.rs | 1 - servo/components/style/gecko/selector_parser.rs | 6 ------ servo/components/style/gecko/wrapper.rs | 5 +---- servo/components/style/servo/selector_parser.rs | 5 ----- toolkit/content/minimal-xul.css | 10 ++-------- xpcom/ds/StaticAtoms.py | 1 - 8 files changed, 6 insertions(+), 40 deletions(-) diff --git a/servo/components/selectors/builder.rs b/servo/components/selectors/builder.rs index 4e295a1598fe..0bf894a72b55 100644 --- a/servo/components/selectors/builder.rs +++ b/servo/components/selectors/builder.rs @@ -17,7 +17,7 @@ //! is non-trivial. This module encapsulates those details and presents an //! easy-to-use API for the parser. -use crate::parser::{Combinator, Component, NonTSPseudoClass, SelectorImpl}; +use crate::parser::{Combinator, Component, SelectorImpl}; use crate::sink::Push; use servo_arc::{Arc, HeaderWithLength, ThinArc}; use smallvec::{self, SmallVec}; @@ -322,14 +322,10 @@ where Component::NthLastOfType(..) | Component::FirstOfType | Component::LastOfType | - Component::OnlyOfType => { + Component::OnlyOfType | + Component::NonTSPseudoClass(..) => { specificity.class_like_selectors += 1; }, - Component::NonTSPseudoClass(ref pseudo) => { - if !pseudo.has_zero_specificity() { - specificity.class_like_selectors += 1; - } - }, Component::Is(ref list) => { // https://drafts.csswg.org/selectors/#specificity-rules: // diff --git a/servo/components/selectors/parser.rs b/servo/components/selectors/parser.rs index 8f87c785f3e6..a1dcd119bf5e 100644 --- a/servo/components/selectors/parser.rs +++ b/servo/components/selectors/parser.rs @@ -53,9 +53,6 @@ pub trait NonTSPseudoClass: Sized + ToCss { /// https://drafts.csswg.org/selectors-4/#useraction-pseudos fn is_user_action_state(&self) -> bool; - /// Whether this pseudo-class has zero specificity. - fn has_zero_specificity(&self) -> bool; - fn visit(&self, _visitor: &mut V) -> bool where V: SelectorVisitor, @@ -2564,11 +2561,6 @@ pub mod tests { fn is_user_action_state(&self) -> bool { self.is_active_or_hover() } - - #[inline] - fn has_zero_specificity(&self) -> bool { - false - } } impl ToCss for PseudoClass { diff --git a/servo/components/style/gecko/non_ts_pseudo_class_list.rs b/servo/components/style/gecko/non_ts_pseudo_class_list.rs index fedbed331f04..66851f1d46b5 100644 --- a/servo/components/style/gecko/non_ts_pseudo_class_list.rs +++ b/servo/components/style/gecko/non_ts_pseudo_class_list.rs @@ -98,7 +98,6 @@ macro_rules! apply_non_ts_list { ("-moz-last-node", MozLastNode, _, _), ("-moz-only-whitespace", MozOnlyWhitespace, _, _), ("-moz-native-anonymous", MozNativeAnonymous, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), - ("-moz-native-anonymous-no-specificity", MozNativeAnonymousNoSpecificity, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), ("-moz-use-shadow-tree-root", MozUseShadowTreeRoot, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), ("-moz-is-html", MozIsHTML, _, _), ("-moz-placeholder", MozPlaceholder, _, _), diff --git a/servo/components/style/gecko/selector_parser.rs b/servo/components/style/gecko/selector_parser.rs index f06cae71b94d..99c43578a6b9 100644 --- a/servo/components/style/gecko/selector_parser.rs +++ b/servo/components/style/gecko/selector_parser.rs @@ -215,7 +215,6 @@ impl NonTSPseudoClass { NonTSPseudoClass::MozIsHTML | // We prevent style sharing for NAC. NonTSPseudoClass::MozNativeAnonymous | - NonTSPseudoClass::MozNativeAnonymousNoSpecificity | // :-moz-placeholder is parsed but never matches. NonTSPseudoClass::MozPlaceholder | // :-moz-locale-dir and :-moz-window-inactive depend only on @@ -248,11 +247,6 @@ impl ::selectors::parser::NonTSPseudoClass for NonTSPseudoClass { ) } - #[inline] - fn has_zero_specificity(&self) -> bool { - matches!(*self, NonTSPseudoClass::MozNativeAnonymousNoSpecificity) - } - fn visit(&self, visitor: &mut V) -> bool where V: SelectorVisitor, diff --git a/servo/components/style/gecko/wrapper.rs b/servo/components/style/gecko/wrapper.rs index 6f7ccfd0b17e..0fd55f0e7e8e 100644 --- a/servo/components/style/gecko/wrapper.rs +++ b/servo/components/style/gecko/wrapper.rs @@ -2103,10 +2103,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { } true }, - NonTSPseudoClass::MozNativeAnonymous | - NonTSPseudoClass::MozNativeAnonymousNoSpecificity => { - self.is_in_native_anonymous_subtree() - }, + NonTSPseudoClass::MozNativeAnonymous => self.is_in_native_anonymous_subtree(), NonTSPseudoClass::MozUseShadowTreeRoot => self.is_root_of_use_element_shadow_tree(), NonTSPseudoClass::MozTableBorderNonzero => unsafe { bindings::Gecko_IsTableBorderNonzero(self.0) diff --git a/servo/components/style/servo/selector_parser.rs b/servo/components/style/servo/selector_parser.rs index 3652eef0058a..99adfbde3a89 100644 --- a/servo/components/style/servo/selector_parser.rs +++ b/servo/components/style/servo/selector_parser.rs @@ -311,11 +311,6 @@ impl ::selectors::parser::NonTSPseudoClass for NonTSPseudoClass { ) } - #[inline] - fn has_zero_specificity(&self) -> bool { - false - } - fn visit(&self, _: &mut V) -> bool where V: SelectorVisitor, diff --git a/toolkit/content/minimal-xul.css b/toolkit/content/minimal-xul.css index 806e7e369191..7eeca7fa1252 100644 --- a/toolkit/content/minimal-xul.css +++ b/toolkit/content/minimal-xul.css @@ -34,11 +34,7 @@ /* Rules required for style caching of anonymous content scrollbar parts */ @supports -moz-bool-pref("layout.css.cached-scrollbar-styles.enabled") { - scrollcorner:-moz-native-anonymous-no-specificity, - resizer:-moz-native-anonymous-no-specificity, - scrollbar:-moz-native-anonymous-no-specificity, - scrollbarbutton:-moz-native-anonymous-no-specificity, - slider:-moz-native-anonymous-no-specificity { + :is(scrollcorner, resizer, scrollbar, scrollbarbutton, slider):where(:-moz-native-anonymous) { /* All scrollbar parts must not inherit any properties from the scrollable * element (except for visibility and pointer-events), for the anonymous * content style caching system to work. @@ -98,9 +94,7 @@ * expecting them to inherit into its children. Explicitly inherit those, * overriding the 'all: initial; direction: ltr;' declarations above. */ - scrollbarbutton:-moz-native-anonymous-no-specificity, - slider:-moz-native-anonymous-no-specificity, - thumb:-moz-native-anonymous-no-specificity { + :is(scrollbarbutton, slider, thumb):where(:-moz-native-anonymous) { direction: inherit; cursor: inherit; } diff --git a/xpcom/ds/StaticAtoms.py b/xpcom/ds/StaticAtoms.py index 17a9642a1737..74f823ff82be 100644 --- a/xpcom/ds/StaticAtoms.py +++ b/xpcom/ds/StaticAtoms.py @@ -670,7 +670,6 @@ STATIC_ATOMS = [ Atom("mozCustomContentContainer", "moz-custom-content-container"), Atom("mozGrabber", "mozGrabber"), Atom("mozNativeAnonymous", "-moz-native-anonymous"), - Atom("mozNativeAnonymousNoSpecificity", "-moz-native-anonymous-no-specificity"), Atom("mozprivatebrowsing", "mozprivatebrowsing"), Atom("mozResizer", "mozResizer"), Atom("mozResizingInfo", "mozResizingInfo"),