tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 3c3da3086d1bd30865eac10add51ac9cc49d19a5
parent 93c3b64965bc2996c7a1a57fbcb5405f91860c77
Author: Oriol Brufau <obrufau@igalia.com>
Date:   Tue,  7 Oct 2025 12:23:20 +0000

Bug 1992880 - Enable :state pseudo-class for Servo. r=firefox-style-system-reviewers,emilio

Differential Revision: https://phabricator.services.mozilla.com/D267699

Diffstat:
Mservo/components/style/servo/selector_parser.rs | 14+++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/servo/components/style/servo/selector_parser.rs b/servo/components/style/servo/selector_parser.rs @@ -380,6 +380,11 @@ impl ToCss for NonTSPseudoClass { Self::AnyLink => ":any-link", Self::Autofill => ":autofill", Self::Checked => ":checked", + Self::CustomState(ref state) => { + dest.write_str(":state(")?; + state.0.to_css(dest)?; + return dest.write_char(')'); + }, Self::Default => ":default", Self::Defined => ":defined", Self::Disabled => ":disabled", @@ -410,7 +415,7 @@ impl ToCss for NonTSPseudoClass { Self::UserValid => ":user-valid", Self::Valid => ":valid", Self::Visited => ":visited", - Self::Lang(_) | Self::CustomState(_) => unreachable!(), + Self::Lang(_) => unreachable!(), }) } } @@ -597,10 +602,13 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> { parser: &mut CssParser<'i, 't>, after_part: bool, ) -> Result<NonTSPseudoClass, ParseError<'i>> { - use self::NonTSPseudoClass::*; let pseudo_class = match_ignore_ascii_case! { &name, "lang" if !after_part => { - Lang(parser.expect_ident_or_string()?.as_ref().into()) + NonTSPseudoClass::Lang(parser.expect_ident_or_string()?.as_ref().into()) + }, + "state" => { + let result = AtomIdent::from(parser.expect_ident()?.as_ref()); + NonTSPseudoClass::CustomState(CustomState(result)) }, _ => return Err(parser.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone()))), };