mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +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
|
@ -27,7 +27,8 @@ ${helpers.predefined_type("opacity",
|
|||
pub type T = Shadow;
|
||||
}
|
||||
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<specified::Shadow, ()> {
|
||||
pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<specified::Shadow, ParseError<'i>> {
|
||||
specified::Shadow::parse(context, input, false)
|
||||
}
|
||||
</%helpers:vector_longhand>
|
||||
|
@ -263,7 +264,8 @@ ${helpers.predefined_type("clip",
|
|||
computed_value::T::new(Vec::new())
|
||||
}
|
||||
|
||||
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 filters = Vec::new();
|
||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
return Ok(SpecifiedValue(filters))
|
||||
|
@ -290,23 +292,24 @@ ${helpers.predefined_type("clip",
|
|||
"drop-shadow" => specified::Shadow::parse(context, input, true)
|
||||
.map(SpecifiedFilter::DropShadow),
|
||||
% endif
|
||||
_ => Err(())
|
||||
_ => Err(StyleParseError::UnexpectedFunction(function_name.clone()).into())
|
||||
}
|
||||
})));
|
||||
} else if filters.is_empty() {
|
||||
return Err(())
|
||||
return Err(StyleParseError::UnspecifiedError.into())
|
||||
} else {
|
||||
return Ok(SpecifiedValue(filters))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_factor(input: &mut Parser) -> Result<::values::CSSFloat, ()> {
|
||||
fn parse_factor<'i, 't>(input: &mut Parser<'i, 't>) -> Result<::values::CSSFloat, ParseError<'i>> {
|
||||
use cssparser::Token;
|
||||
match input.next() {
|
||||
Ok(Token::Number(value)) if value.value.is_sign_positive() => Ok(value.value),
|
||||
Ok(Token::Percentage(value)) if value.unit_value.is_sign_positive() => Ok(value.unit_value),
|
||||
_ => Err(())
|
||||
Ok(t) => Err(BasicParseError::UnexpectedToken(t).into()),
|
||||
Err(e) => Err(e.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue