diff options
Diffstat (limited to 'components/style_traits/lib.rs')
-rw-r--r-- | components/style_traits/lib.rs | 65 |
1 files changed, 25 insertions, 40 deletions
diff --git a/components/style_traits/lib.rs b/components/style_traits/lib.rs index fea9d074ecf..a46c233b8f3 100644 --- a/components/style_traits/lib.rs +++ b/components/style_traits/lib.rs @@ -90,9 +90,6 @@ pub type ParseError<'i> = cssparser::ParseError<'i, StyleParseErrorKind<'i>>; /// Error in property value parsing pub type ValueParseError<'i> = cssparser::ParseError<'i, ValueParseErrorKind<'i>>; -/// Error in property parsing -pub type PropertyDeclarationParseError<'i> = cssparser::ParseError<'i, PropertyDeclarationParseErrorKind<'i>>; - #[derive(Clone, Debug, PartialEq)] /// Errors that can be encountered while parsing CSS values. pub enum StyleParseErrorKind<'i> { @@ -106,8 +103,6 @@ pub enum StyleParseErrorKind<'i> { UnbalancedCloseSquareBracketInDeclarationValueBlock, /// Unexpected closing curly bracket in a DVB. UnbalancedCloseCurlyBracketInDeclarationValueBlock, - /// A property declaration parsing error. - PropertyDeclaration(PropertyDeclarationParseErrorKind<'i>), /// A property declaration value had input remaining after successfully parsing. PropertyDeclarationValueNotExhausted, /// An unexpected dimension token was encountered. @@ -138,6 +133,26 @@ pub enum StyleParseErrorKind<'i> { ValueError(ValueParseErrorKind<'i>), /// An error was encountered while parsing a selector SelectorError(SelectorParseErrorKind<'i>), + + /// The property declaration was for an unknown property. + UnknownProperty(CowRcStr<'i>), + /// An unknown vendor-specific identifier was encountered. + UnknownVendorProperty, + /// The property declaration was for a disabled experimental property. + ExperimentalProperty, + /// The property declaration contained an invalid color value. + InvalidColor(CowRcStr<'i>, Token<'i>), + /// The property declaration contained an invalid filter value. + InvalidFilter(CowRcStr<'i>, Token<'i>), + /// The property declaration contained an invalid value. + OtherInvalidValue(CowRcStr<'i>), + /// The declaration contained an animation property, and we were parsing + /// this as a keyframe block (so that property should be ignored). + /// + /// See: https://drafts.csswg.org/css-animations/#keyframes + AnimationPropertyInKeyframeBlock, + /// The property is not allowed within a page rule. + NotAllowedInPageRule, } impl<'i> From<ValueParseErrorKind<'i>> for StyleParseErrorKind<'i> { @@ -152,12 +167,6 @@ impl<'i> From<SelectorParseErrorKind<'i>> for StyleParseErrorKind<'i> { } } -impl<'i> From<PropertyDeclarationParseErrorKind<'i>> for StyleParseErrorKind<'i> { - fn from(this: PropertyDeclarationParseErrorKind<'i>) -> Self { - StyleParseErrorKind::PropertyDeclaration(this) - } -} - /// Specific errors that can be encountered while parsing property values. #[derive(Clone, Debug, PartialEq)] pub enum ValueParseErrorKind<'i> { @@ -167,45 +176,21 @@ pub enum ValueParseErrorKind<'i> { InvalidFilter(Token<'i>), } -/// The result of parsing a property declaration. -#[derive(Clone, Debug, PartialEq)] -pub enum PropertyDeclarationParseErrorKind<'i> { - /// The property declaration was for an unknown property. - UnknownProperty(CowRcStr<'i>), - /// An unknown vendor-specific identifier was encountered. - UnknownVendorProperty, - /// The property declaration was for a disabled experimental property. - ExperimentalProperty, - /// The property declaration contained an invalid color value. - InvalidColor(CowRcStr<'i>, Token<'i>), - /// The property declaration contained an invalid filter value. - InvalidFilter(CowRcStr<'i>, Token<'i>), - /// The property declaration contained an invalid value. - OtherInvalidValue(CowRcStr<'i>), - /// The declaration contained an animation property, and we were parsing - /// this as a keyframe block (so that property should be ignored). - /// - /// See: https://drafts.csswg.org/css-animations/#keyframes - AnimationPropertyInKeyframeBlock, - /// The property is not allowed within a page rule. - NotAllowedInPageRule, -} - -impl<'i> PropertyDeclarationParseErrorKind<'i> { +impl<'i> StyleParseErrorKind<'i> { /// Create an InvalidValue parse error - pub fn new_invalid(name: CowRcStr<'i>, value_error: ParseError<'i>) -> PropertyDeclarationParseError<'i> { + pub fn new_invalid(name: CowRcStr<'i>, value_error: ParseError<'i>) -> ParseError<'i> { let variant = match value_error.kind { cssparser::ParseErrorKind::Custom(StyleParseErrorKind::ValueError(e)) => { match e { ValueParseErrorKind::InvalidColor(token) => { - PropertyDeclarationParseErrorKind::InvalidColor(name, token) + StyleParseErrorKind::InvalidColor(name, token) } ValueParseErrorKind::InvalidFilter(token) => { - PropertyDeclarationParseErrorKind::InvalidFilter(name, token) + StyleParseErrorKind::InvalidFilter(name, token) } } } - _ => PropertyDeclarationParseErrorKind::OtherInvalidValue(name), + _ => StyleParseErrorKind::OtherInvalidValue(name), }; cssparser::ParseError { kind: cssparser::ParseErrorKind::Custom(variant), |