diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs index bbc1dc4a246..6d15a741ca4 100644 --- a/components/selectors/parser.rs +++ b/components/selectors/parser.rs @@ -58,7 +58,7 @@ pub enum SelectorParseError<'i, T> { UnexpectedTokenInAttributeSelector, PseudoElementExpectedColon, PseudoElementExpectedIdent, - UnsupportedPseudoClass, + UnsupportedPseudoClassOrElement(CowRcStr<'i>), UnexpectedIdent(CowRcStr<'i>), ExpectedNamespace(CowRcStr<'i>), Custom(T), @@ -136,7 +136,7 @@ pub trait Parser<'i> { fn parse_non_ts_pseudo_class(&self, name: CowRcStr<'i>) -> Result<::NonTSPseudoClass, ParseError<'i, SelectorParseError<'i, Self::Error>>> { - Err(ParseError::Custom(SelectorParseError::UnexpectedIdent(name))) + Err(ParseError::Custom(SelectorParseError::UnsupportedPseudoClassOrElement(name))) } fn parse_non_ts_functional_pseudo_class<'t> @@ -144,20 +144,20 @@ pub trait Parser<'i> { -> Result<::NonTSPseudoClass, ParseError<'i, SelectorParseError<'i, Self::Error>>> { - Err(ParseError::Custom(SelectorParseError::UnexpectedIdent(name))) + Err(ParseError::Custom(SelectorParseError::UnsupportedPseudoClassOrElement(name))) } fn parse_pseudo_element(&self, name: CowRcStr<'i>) -> Result<::PseudoElement, ParseError<'i, SelectorParseError<'i, Self::Error>>> { - Err(ParseError::Custom(SelectorParseError::UnexpectedIdent(name))) + Err(ParseError::Custom(SelectorParseError::UnsupportedPseudoClassOrElement(name))) } fn parse_functional_pseudo_element<'t> (&self, name: CowRcStr<'i>, _arguments: &mut CssParser<'i, 't>) -> Result<::PseudoElement, ParseError<'i, SelectorParseError<'i, Self::Error>>> { - Err(ParseError::Custom(SelectorParseError::UnexpectedIdent(name))) + Err(ParseError::Custom(SelectorParseError::UnsupportedPseudoClassOrElement(name))) } fn default_namespace(&self) -> Option<::NamespaceUrl> { @@ -1503,9 +1503,9 @@ fn parse_compound_selector<'i, 't, P, E, Impl>( }; let pseudo_class = - P::parse_non_ts_pseudo_class(parser, name)?; + P::parse_non_ts_pseudo_class(parser, name.clone())?; if !p.supports_pseudo_class(&pseudo_class) { - return Err(SelectorParseError::UnsupportedPseudoClass.into()); + return Err(SelectorParseError::UnsupportedPseudoClassOrElement(name).into()); } state_selectors.push(Component::NonTSPseudoClass(pseudo_class)); } diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs index 21c12305e6a..8000c0af5f4 100644 --- a/components/style/gecko/selector_parser.rs +++ b/components/style/gecko/selector_parser.rs @@ -308,7 +308,7 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> { keyword: [$(($k_css:expr, $k_name:ident, $k_gecko_type:tt, $k_state:tt, $k_flags:tt),)*]) => { match_ignore_ascii_case! { &name, $($css => NonTSPseudoClass::$name,)* - _ => return Err(::selectors::parser::SelectorParseError::UnexpectedIdent( + _ => return Err(::selectors::parser::SelectorParseError::UnsupportedPseudoClassOrElement( name.clone()).into()) } } @@ -317,7 +317,7 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> { if self.is_pseudo_class_enabled(&pseudo_class) { Ok(pseudo_class) } else { - Err(SelectorParseError::UnexpectedIdent(name).into()) + Err(SelectorParseError::UnsupportedPseudoClassOrElement(name).into()) } } @@ -354,7 +354,7 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> { } NonTSPseudoClass::MozAny(selectors.into_boxed_slice()) } - _ => return Err(SelectorParseError::UnexpectedIdent(name.clone()).into()) + _ => return Err(SelectorParseError::UnsupportedPseudoClassOrElement(name.clone()).into()) } } } @@ -362,13 +362,13 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> { if self.is_pseudo_class_enabled(&pseudo_class) { Ok(pseudo_class) } else { - Err(SelectorParseError::UnexpectedIdent(name).into()) + Err(SelectorParseError::UnsupportedPseudoClassOrElement(name).into()) } } fn parse_pseudo_element(&self, name: CowRcStr<'i>) -> Result> { PseudoElement::from_slice(&name, self.in_user_agent_stylesheet()) - .ok_or(SelectorParseError::UnexpectedIdent(name.clone()).into()) + .ok_or(SelectorParseError::UnsupportedPseudoClassOrElement(name.clone()).into()) } fn parse_functional_pseudo_element<'t>(&self, name: CowRcStr<'i>, @@ -392,7 +392,7 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> { return Ok(pseudo); } } - Err(SelectorParseError::UnexpectedIdent(name.clone()).into()) + Err(SelectorParseError::UnsupportedPseudoClassOrElement(name.clone()).into()) } fn default_namespace(&self) -> Option { diff --git a/ports/geckolib/error_reporter.rs b/ports/geckolib/error_reporter.rs index 583a9db6734..d487f649fef 100644 --- a/ports/geckolib/error_reporter.rs +++ b/ports/geckolib/error_reporter.rs @@ -250,6 +250,9 @@ fn extract_error_params<'a>(err: ParseError<'a>) -> Option> { PropertyDeclarationParseError::InvalidValue(property, Some(e))))) => (Some(ErrorString::Snippet(property.into())), Some(extract_value_error_param(e))), + CssParseError::Custom(SelectorParseError::UnsupportedPseudoClassOrElement(p)) => + (None, Some(ErrorString::Ident(p))), + err => match extract_error_param(err) { Some(e) => (Some(e), None), None => return None, @@ -325,8 +328,14 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> { _, CssParseError::Custom(SelectorParseError::Custom( StyleParseError::UnexpectedTokenWithinNamespace(_)))) => (b"PEAtNSUnexpected\0", Action::Nothing), - ContextualParseError::InvalidRule(..) => - (b"PEBadSelectorRSIgnored\0", Action::Nothing), + ContextualParseError::InvalidRule(_, ref err) => { + let prefix = match *err { + CssParseError::Custom(SelectorParseError::UnsupportedPseudoClassOrElement(_)) => + Some(&b"PEPseudoSelUnknown\0"[..]), + _ => None, + }; + return (prefix, b"PEBadSelectorRSIgnored\0", Action::Nothing); + } ContextualParseError::UnsupportedRule(..) => (b"PEDeclDropped\0", Action::Nothing), ContextualParseError::UnsupportedViewportDescriptorDeclaration(..) |