mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Report an error for invalid CSS color values (bug 1381143).
This commit is contained in:
parent
cf5602e84f
commit
4b736354c4
6 changed files with 154 additions and 82 deletions
|
@ -124,10 +124,31 @@ pub enum StyleParseError<'i> {
|
|||
UnspecifiedError,
|
||||
/// An unexpected token was found within a namespace rule.
|
||||
UnexpectedTokenWithinNamespace(Token<'i>),
|
||||
/// An error was encountered while parsing a property value.
|
||||
ValueError(ValueParseError<'i>),
|
||||
}
|
||||
|
||||
/// Specific errors that can be encountered while parsing property values.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum ValueParseError<'i> {
|
||||
/// An invalid token was encountered while parsing a color value.
|
||||
InvalidColor(Token<'i>),
|
||||
}
|
||||
|
||||
impl<'i> ValueParseError<'i> {
|
||||
/// Attempt to extract a ValueParseError value from a ParseError.
|
||||
pub fn from_parse_error(this: ParseError<'i>) -> Option<ValueParseError<'i>> {
|
||||
match this {
|
||||
cssparser::ParseError::Custom(
|
||||
SelectorParseError::Custom(
|
||||
StyleParseError::ValueError(e))) => Some(e),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The result of parsing a property declaration.
|
||||
#[derive(Eq, PartialEq, Clone, Debug)]
|
||||
#[derive(PartialEq, Clone, Debug)]
|
||||
pub enum PropertyDeclarationParseError<'i> {
|
||||
/// The property declaration was for an unknown property.
|
||||
UnknownProperty(CowRcStr<'i>),
|
||||
|
@ -136,7 +157,7 @@ pub enum PropertyDeclarationParseError<'i> {
|
|||
/// The property declaration was for a disabled experimental property.
|
||||
ExperimentalProperty,
|
||||
/// The property declaration contained an invalid value.
|
||||
InvalidValue(CowRcStr<'i>),
|
||||
InvalidValue(CowRcStr<'i>, Option<ValueParseError<'i>>),
|
||||
/// The declaration contained an animation property, and we were parsing
|
||||
/// this as a keyframe block (so that property should be ignored).
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue