mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
stylo: Update rust-cssparser; extract more specific error types when reporting (bug 1352669).
This commit is contained in:
parent
dc2a500f4b
commit
f5a3830ea2
21 changed files with 315 additions and 79 deletions
|
@ -913,10 +913,17 @@ pub fn parse_one_declaration_into(declarations: &mut SourcePropertyDeclaration,
|
|||
parsing_mode,
|
||||
quirks_mode);
|
||||
let mut input = ParserInput::new(input);
|
||||
Parser::new(&mut input).parse_entirely(|parser| {
|
||||
let mut parser = Parser::new(&mut input);
|
||||
let start = parser.position();
|
||||
parser.parse_entirely(|parser| {
|
||||
PropertyDeclaration::parse_into(declarations, id, &context, parser)
|
||||
.map_err(|e| e.into())
|
||||
}).map_err(|_| ())
|
||||
}).map_err(|err| {
|
||||
let end = parser.position();
|
||||
let error = ContextualParseError::UnsupportedPropertyDeclaration(
|
||||
parser.slice(start..end), err);
|
||||
log_css_error(&mut parser, start, error, &context);
|
||||
})
|
||||
}
|
||||
|
||||
/// A struct to parse property declarations.
|
||||
|
|
|
@ -37,7 +37,8 @@ use properties::animated_properties::AnimatableLonghand;
|
|||
use selectors::parser::SelectorParseError;
|
||||
#[cfg(feature = "servo")] use servo_config::prefs::PREFS;
|
||||
use shared_lock::StylesheetGuards;
|
||||
use style_traits::{PARSING_MODE_DEFAULT, HasViewportPercentage, ToCss, ParseError, PropertyDeclarationParseError};
|
||||
use style_traits::{PARSING_MODE_DEFAULT, HasViewportPercentage, ToCss, ParseError};
|
||||
use style_traits::{PropertyDeclarationParseError, StyleParseError};
|
||||
use stylesheets::{CssRuleType, MallocSizeOf, MallocSizeOfFn, Origin, UrlExtraData};
|
||||
#[cfg(feature = "servo")] use values::Either;
|
||||
use values::generics::text::LineHeight;
|
||||
|
@ -1014,7 +1015,7 @@ impl PropertyId {
|
|||
match static_id(&property_name) {
|
||||
Some(&StaticId::Longhand(id)) => Ok(PropertyId::Longhand(id)),
|
||||
Some(&StaticId::Shorthand(id)) => Ok(PropertyId::Shorthand(id)),
|
||||
None => Err(SelectorParseError::UnexpectedIdent(property_name).into()),
|
||||
None => Err(StyleParseError::UnknownProperty(property_name).into()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1419,7 +1420,7 @@ impl PropertyDeclaration {
|
|||
Ok(keyword) => DeclaredValueOwned::CSSWideKeyword(keyword),
|
||||
Err(_) => match ::custom_properties::SpecifiedValue::parse(context, input) {
|
||||
Ok(value) => DeclaredValueOwned::Value(value),
|
||||
Err(_) => return Err(PropertyDeclarationParseError::InvalidValue),
|
||||
Err(_) => return Err(PropertyDeclarationParseError::InvalidValue(name.to_string())),
|
||||
}
|
||||
};
|
||||
declarations.push(PropertyDeclaration::Custom(name, value));
|
||||
|
@ -1447,7 +1448,7 @@ impl PropertyDeclaration {
|
|||
declarations.push(value);
|
||||
Ok(())
|
||||
},
|
||||
Err(_) => Err(PropertyDeclarationParseError::InvalidValue),
|
||||
Err(_) => Err(PropertyDeclarationParseError::InvalidValue("${property.ident}".into())),
|
||||
}
|
||||
% else:
|
||||
Err(PropertyDeclarationParseError::UnknownProperty)
|
||||
|
@ -1487,7 +1488,7 @@ impl PropertyDeclaration {
|
|||
},
|
||||
Err(_) => {
|
||||
shorthands::${shorthand.ident}::parse_into(declarations, context, input)
|
||||
.map_err(|_| PropertyDeclarationParseError::InvalidValue)
|
||||
.map_err(|_| PropertyDeclarationParseError::InvalidValue("${shorthand.ident}".into()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue