commit 76250e12d931995fded6ef5e12c9bce79fdbeaaa
parent 45e0d9331038853fbb892b57f39befc18f5a06b8
Author: Oriol Brufau <obrufau@igalia.com>
Date: Tue, 7 Oct 2025 23:16:10 +0000
Bug 1992880 - Enable :state pseudo-class for Servo. r=firefox-style-system-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D267699
Diffstat:
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()))),
};