mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Auto merge of #18290 - jdm:selectorerr, r=heycam
Report more specific CSS selector errors Report more specific errors for invalid CSS selectors. Reviewed by @heycam in https://bugzilla.mozilla.org/show_bug.cgi?id=1384216. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18290) <!-- Reviewable:end -->
This commit is contained in:
commit
b2f8974ab8
4 changed files with 211 additions and 103 deletions
|
@ -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, ParseError<'i>> {
|
||||
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<Namespace> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue