mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06: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
|
@ -313,27 +313,32 @@ ${helpers.predefined_type("object-position",
|
|||
}
|
||||
|
||||
/// [ row | column ] || dense
|
||||
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>> {
|
||||
use self::computed_value::AutoFlow;
|
||||
|
||||
let mut value = None;
|
||||
let mut dense = false;
|
||||
|
||||
while !input.is_exhausted() {
|
||||
match_ignore_ascii_case! { &input.expect_ident()?,
|
||||
let ident = input.expect_ident()?;
|
||||
let success = match_ignore_ascii_case! { &ident,
|
||||
"row" if value.is_none() => {
|
||||
value = Some(AutoFlow::Row);
|
||||
continue
|
||||
true
|
||||
},
|
||||
"column" if value.is_none() => {
|
||||
value = Some(AutoFlow::Column);
|
||||
continue
|
||||
true
|
||||
},
|
||||
"dense" if !dense => {
|
||||
dense = true;
|
||||
continue
|
||||
true
|
||||
},
|
||||
_ => return Err(())
|
||||
_ => false
|
||||
};
|
||||
if !success {
|
||||
return Err(SelectorParseError::UnexpectedIdent(ident).into());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,7 +348,7 @@ ${helpers.predefined_type("object-position",
|
|||
dense: dense,
|
||||
})
|
||||
} else {
|
||||
Err(())
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
@ -372,7 +377,8 @@ ${helpers.predefined_type("object-position",
|
|||
Either::Second(None_)
|
||||
}
|
||||
|
||||
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>> {
|
||||
SpecifiedValue::parse(context, input)
|
||||
}
|
||||
|
||||
|
@ -394,13 +400,15 @@ ${helpers.predefined_type("object-position",
|
|||
impl ComputedValueAsSpecified for TemplateAreas {}
|
||||
|
||||
impl Parse for TemplateAreas {
|
||||
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
let mut strings = vec![];
|
||||
while let Ok(string) = input.try(Parser::expect_string) {
|
||||
strings.push(string.into_owned().into_boxed_str());
|
||||
}
|
||||
|
||||
TemplateAreas::from_vec(strings)
|
||||
.map_err(|()| StyleParseError::UnspecifiedError.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue