From bbf3280fef8f8888401f17a59e0ec83e0d188c93 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Wed, 19 Jul 2017 12:57:07 -0400 Subject: [PATCH] Store COW strings in CSS parser errors when possible. --- components/style/properties/properties.mako.rs | 2 +- components/style_traits/lib.rs | 2 +- ports/geckolib/error_reporter.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 9c6a017ced3..2457d809bc2 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1478,7 +1478,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(name.to_string())), + Err(_) => return Err(PropertyDeclarationParseError::InvalidValue(name.to_string().into())), } }; declarations.push(PropertyDeclaration::Custom(name, value)); diff --git a/components/style_traits/lib.rs b/components/style_traits/lib.rs index 04e19f2c12d..b0b299ec64f 100644 --- a/components/style_traits/lib.rs +++ b/components/style_traits/lib.rs @@ -124,7 +124,7 @@ pub enum PropertyDeclarationParseError<'i> { /// The property declaration was for a disabled experimental property. ExperimentalProperty, /// The property declaration contained an invalid value. - InvalidValue(String), + InvalidValue(CompactCowStr<'i>), /// The declaration contained an animation property, and we were parsing /// this as a keyframe block (so that property should be ignored). /// diff --git a/ports/geckolib/error_reporter.rs b/ports/geckolib/error_reporter.rs index fcb2bbe1069..a8abdb0347f 100644 --- a/ports/geckolib/error_reporter.rs +++ b/ports/geckolib/error_reporter.rs @@ -224,7 +224,7 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> { (_, CssParseError::Custom(SelectorParseError::Custom( StyleParseError::PropertyDeclaration( PropertyDeclarationParseError::InvalidValue(property))))) => - ErrorString::Snippet(property.into()), + ErrorString::Snippet(property), (_, CssParseError::Custom(SelectorParseError::UnexpectedIdent(ident))) => ErrorString::Ident(ident),