mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #16752 - jdm:css-parse-error, r=SimonSapin
Report more informative CSS errors This requires https://github.com/servo/rust-cssparser/pull/143 for the final commit. There's no better way to split that work up, unfortunately, and it's extremely easy to bitrot. I would appreciate if we could expedite reviewing this work. This is the work necessary to enable https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. It makes sense to merge it separately because it's so much effort to keep it up to date with the ongoing Stylo work. --- - [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/16752) <!-- Reviewable:end -->
This commit is contained in:
commit
061cb5f48e
123 changed files with 2212 additions and 1513 deletions
|
@ -104,7 +104,8 @@
|
|||
sides_are_logical: true,
|
||||
}
|
||||
}
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
let first = try!(Side::parse(context, input));
|
||||
let second = input.try(|input| Side::parse(context, input)).ok();
|
||||
Ok(SpecifiedValue {
|
||||
|
@ -113,13 +114,14 @@
|
|||
})
|
||||
}
|
||||
impl Parse for Side {
|
||||
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Side, ()> {
|
||||
fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Side, ParseError<'i>> {
|
||||
if let Ok(ident) = input.try(|input| input.expect_ident()) {
|
||||
match_ignore_ascii_case! { &ident,
|
||||
(match_ignore_ascii_case! { &ident,
|
||||
"clip" => Ok(Side::Clip),
|
||||
"ellipsis" => Ok(Side::Ellipsis),
|
||||
_ => Err(())
|
||||
}
|
||||
}).map_err(|()| SelectorParseError::UnexpectedIdent(ident).into())
|
||||
} else {
|
||||
Ok(Side::String(try!(input.expect_string()).into_owned().into_boxed_str()))
|
||||
}
|
||||
|
@ -216,34 +218,39 @@ ${helpers.single_keyword("unicode-bidi",
|
|||
SpecifiedValue::empty()
|
||||
}
|
||||
/// none | [ underline || overline || line-through || blink ]
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
let mut result = SpecifiedValue::empty();
|
||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
return Ok(result)
|
||||
}
|
||||
let mut empty = true;
|
||||
|
||||
while input.try(|input| {
|
||||
if let Ok(ident) = input.expect_ident() {
|
||||
match_ignore_ascii_case! { &ident,
|
||||
"underline" => if result.contains(UNDERLINE) { return Err(()) }
|
||||
else { empty = false; result.insert(UNDERLINE) },
|
||||
"overline" => if result.contains(OVERLINE) { return Err(()) }
|
||||
else { empty = false; result.insert(OVERLINE) },
|
||||
"line-through" => if result.contains(LINE_THROUGH) { return Err(()) }
|
||||
else { empty = false; result.insert(LINE_THROUGH) },
|
||||
"blink" => if result.contains(BLINK) { return Err(()) }
|
||||
else { empty = false; result.insert(BLINK) },
|
||||
_ => return Err(())
|
||||
loop {
|
||||
let result: Result<_, ParseError> = input.try(|input| {
|
||||
match input.expect_ident() {
|
||||
Ok(ident) => {
|
||||
(match_ignore_ascii_case! { &ident,
|
||||
"underline" => if result.contains(UNDERLINE) { Err(()) }
|
||||
else { empty = false; result.insert(UNDERLINE); Ok(()) },
|
||||
"overline" => if result.contains(OVERLINE) { Err(()) }
|
||||
else { empty = false; result.insert(OVERLINE); Ok(()) },
|
||||
"line-through" => if result.contains(LINE_THROUGH) { Err(()) }
|
||||
else { empty = false; result.insert(LINE_THROUGH); Ok(()) },
|
||||
"blink" => if result.contains(BLINK) { Err(()) }
|
||||
else { empty = false; result.insert(BLINK); Ok(()) },
|
||||
_ => Err(())
|
||||
}).map_err(|()| SelectorParseError::UnexpectedIdent(ident).into())
|
||||
}
|
||||
} else {
|
||||
return Err(());
|
||||
Err(e) => return Err(e.into())
|
||||
}
|
||||
Ok(())
|
||||
}).is_ok() {
|
||||
});
|
||||
if result.is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if !empty { Ok(result) } else { Err(()) }
|
||||
if !empty { Ok(result) } else { Err(StyleParseError::UnspecifiedError.into()) }
|
||||
}
|
||||
|
||||
% if product == "servo":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue