Store COW strings in CSS parser errors when possible.

This commit is contained in:
Josh Matthews 2017-07-19 12:57:07 -04:00
parent 2bb4f65100
commit bbf3280fef
3 changed files with 3 additions and 3 deletions

View file

@ -1478,7 +1478,7 @@ impl PropertyDeclaration {
Ok(keyword) => DeclaredValueOwned::CSSWideKeyword(keyword), Ok(keyword) => DeclaredValueOwned::CSSWideKeyword(keyword),
Err(_) => match ::custom_properties::SpecifiedValue::parse(context, input) { Err(_) => match ::custom_properties::SpecifiedValue::parse(context, input) {
Ok(value) => DeclaredValueOwned::Value(value), Ok(value) => DeclaredValueOwned::Value(value),
Err(_) => return Err(PropertyDeclarationParseError::InvalidValue(name.to_string())), Err(_) => return Err(PropertyDeclarationParseError::InvalidValue(name.to_string().into())),
} }
}; };
declarations.push(PropertyDeclaration::Custom(name, value)); declarations.push(PropertyDeclaration::Custom(name, value));

View file

@ -124,7 +124,7 @@ pub enum PropertyDeclarationParseError<'i> {
/// The property declaration was for a disabled experimental property. /// The property declaration was for a disabled experimental property.
ExperimentalProperty, ExperimentalProperty,
/// The property declaration contained an invalid value. /// The property declaration contained an invalid value.
InvalidValue(String), InvalidValue(CompactCowStr<'i>),
/// The declaration contained an animation property, and we were parsing /// The declaration contained an animation property, and we were parsing
/// this as a keyframe block (so that property should be ignored). /// this as a keyframe block (so that property should be ignored).
/// ///

View file

@ -224,7 +224,7 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> {
(_, CssParseError::Custom(SelectorParseError::Custom( (_, CssParseError::Custom(SelectorParseError::Custom(
StyleParseError::PropertyDeclaration( StyleParseError::PropertyDeclaration(
PropertyDeclarationParseError::InvalidValue(property))))) => PropertyDeclarationParseError::InvalidValue(property))))) =>
ErrorString::Snippet(property.into()), ErrorString::Snippet(property),
(_, CssParseError::Custom(SelectorParseError::UnexpectedIdent(ident))) => (_, CssParseError::Custom(SelectorParseError::UnexpectedIdent(ident))) =>
ErrorString::Ident(ident), ErrorString::Ident(ident),