зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1475511: Make document condition parsing a bit nicer. r=xidorn
MozReview-Commit-ID: Gi0FxrEAYcE
This commit is contained in:
Родитель
235320a24a
Коммит
5c6cb85b41
|
@ -122,33 +122,32 @@ impl DocumentMatchingFunction {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if input
|
||||
.try(|input| input.expect_function_matching("url-prefix"))
|
||||
.is_ok()
|
||||
{
|
||||
return parse_quoted_or_unquoted_string!(input, DocumentMatchingFunction::UrlPrefix);
|
||||
if let Ok(url) = input.try(|input| CssUrl::parse(context, input)) {
|
||||
return Ok(DocumentMatchingFunction::Url(url))
|
||||
}
|
||||
|
||||
if input
|
||||
.try(|input| input.expect_function_matching("domain"))
|
||||
.is_ok()
|
||||
{
|
||||
return parse_quoted_or_unquoted_string!(input, DocumentMatchingFunction::Domain);
|
||||
}
|
||||
|
||||
if input
|
||||
.try(|input| input.expect_function_matching("regexp"))
|
||||
.is_ok()
|
||||
{
|
||||
return input.parse_nested_block(|input| {
|
||||
Ok(DocumentMatchingFunction::Regexp(
|
||||
input.expect_string()?.as_ref().to_owned(),
|
||||
let location = input.current_source_location();
|
||||
let function = input.expect_function()?.clone();
|
||||
match_ignore_ascii_case! { &function,
|
||||
"url-prefix" => {
|
||||
parse_quoted_or_unquoted_string!(input, DocumentMatchingFunction::UrlPrefix)
|
||||
}
|
||||
"domain" => {
|
||||
parse_quoted_or_unquoted_string!(input, DocumentMatchingFunction::Domain)
|
||||
}
|
||||
"regexp" => {
|
||||
input.parse_nested_block(|input| {
|
||||
Ok(DocumentMatchingFunction::Regexp(
|
||||
input.expect_string()?.as_ref().to_owned(),
|
||||
))
|
||||
})
|
||||
}
|
||||
_ => {
|
||||
Err(location.new_custom_error(
|
||||
StyleParseErrorKind::UnexpectedFunction(function.clone())
|
||||
))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let url = CssUrl::parse(context, input)?;
|
||||
Ok(DocumentMatchingFunction::Url(url))
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
|
|
Загрузка…
Ссылка в новой задаче