mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
Thread ParseError return values through CSS parsing.
This commit is contained in:
parent
58e39bfffa
commit
27ae1ef2e7
121 changed files with 2133 additions and 1505 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()))
|
||||
}
|
||||
|
@ -217,34 +219,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