diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index c1249816ec3..d1e50e23ce8 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -63,8 +63,8 @@ use std::mem::{forget, transmute, zeroed}; use std::ptr; use stylearc::Arc; use std::cmp; +use values::{Auto, CustomIdent, Either, KeyframesName}; use values::computed::{Shadow, ToComputedValue}; -use values::{Either, Auto, KeyframesName}; use computed_values::border_style; pub mod style_structs { @@ -2430,8 +2430,8 @@ fn static_assert() { self.gecko.mTransitionPropertyCount = v.len() as u32; for (servo, gecko) in v.zip(self.gecko.mTransitions.iter_mut()) { match servo { - TransitionProperty::Unsupported(ref atom) => unsafe { - Gecko_StyleTransition_SetUnsupportedProperty(gecko, atom.as_ptr()) + TransitionProperty::Unsupported(ref ident) => unsafe { + Gecko_StyleTransition_SetUnsupportedProperty(gecko, ident.0.as_ptr()) }, _ => gecko.mProperty = (&servo).into(), } @@ -2466,11 +2466,11 @@ fn static_assert() { if property == eCSSProperty_UNKNOWN || property == eCSSPropertyExtra_variable { let atom = self.gecko.mTransitions[index].mUnknownProperty.raw::(); debug_assert!(!atom.is_null()); - TransitionProperty::Unsupported(atom.into()) + TransitionProperty::Unsupported(CustomIdent(atom.into())) } else if property == eCSSPropertyExtra_no_properties { // Actually, we don't expect TransitionProperty::Unsupported also represents "none", // but if the caller wants to convert it, it is fine. Please use it carefully. - TransitionProperty::Unsupported(atom!("none")) + TransitionProperty::Unsupported(CustomIdent(atom!("none"))) } else { property.into() } diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index dfc55107435..d10ded92245 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -7,7 +7,7 @@ <% from data import SYSTEM_FONT_LONGHANDS %> use app_units::Au; -use cssparser::{Parser, RGBA, serialize_identifier}; +use cssparser::{Parser, RGBA}; use euclid::{Point2D, Size2D}; #[cfg(feature = "gecko")] use gecko_bindings::bindings::RawServoAnimationValueMap; #[cfg(feature = "gecko")] use gecko_bindings::structs::RawGeckoGfxMatrix4x4; @@ -28,15 +28,13 @@ use properties::longhands::vertical_align::computed_value::T as VerticalAlign; use properties::longhands::visibility::computed_value::T as Visibility; #[cfg(feature = "gecko")] use properties::{PropertyDeclarationId, LonghandId}; use selectors::parser::SelectorParseError; -#[cfg(feature = "servo")] use servo_atoms::Atom; use smallvec::SmallVec; use std::cmp; #[cfg(feature = "gecko")] use std::collections::HashMap; use std::fmt; use style_traits::{ToCss, ParseError}; use super::ComputedValues; -use values::CSSFloat; -use values::{Auto, Either}; +use values::{Auto, CSSFloat, CustomIdent, Either}; use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; use values::computed::{BorderCornerRadius, ClipRect}; use values::computed::{CalcLengthOrPercentage, Color, Context, ComputedValueAsSpecified}; @@ -193,7 +191,7 @@ pub enum TransitionProperty { % endfor /// Unrecognized property which could be any non-transitionable, custom property, or /// unknown property. - Unsupported(Atom) + Unsupported(CustomIdent) } no_viewport_percentage!(TransitionProperty); @@ -226,21 +224,22 @@ impl TransitionProperty { /// Parse a transition-property value. pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result> { let ident = try!(input.expect_ident()); - (match_ignore_ascii_case! { &ident, - "all" => Ok(TransitionProperty::All), + let supported = match_ignore_ascii_case! { &ident, + "all" => Ok(Some(TransitionProperty::All)), % for prop in data.longhands + data.shorthands_except_all(): % if prop.transitionable: - "${prop.name}" => Ok(TransitionProperty::${prop.camel_case}), + "${prop.name}" => Ok(Some(TransitionProperty::${prop.camel_case})), % endif % endfor "none" => Err(()), - _ => { - match CSSWideKeyword::from_ident(&ident) { - Some(_) => Err(()), - None => Ok(TransitionProperty::Unsupported((&*ident).into())) - } - } - }).map_err(|()| SelectorParseError::UnexpectedIdent(ident.into()).into()) + _ => Ok(None), + }; + + match supported { + Ok(Some(property)) => Ok(property), + Ok(None) => CustomIdent::from_ident(ident, &[]).map(TransitionProperty::Unsupported), + Err(()) => Err(SelectorParseError::UnexpectedIdent(ident).into()), + } } /// Return transitionable longhands of this shorthand TransitionProperty, except for "all". @@ -290,11 +289,7 @@ impl ToCss for TransitionProperty { TransitionProperty::${prop.camel_case} => dest.write_str("${prop.name}"), % endif % endfor - #[cfg(feature = "gecko")] - TransitionProperty::Unsupported(ref atom) => serialize_identifier(&atom.to_string(), - dest), - #[cfg(feature = "servo")] - TransitionProperty::Unsupported(ref atom) => serialize_identifier(atom, dest), + TransitionProperty::Unsupported(ref ident) => ident.to_css(dest), } } } @@ -329,7 +324,7 @@ impl From for TransitionProperty { => TransitionProperty::${prop.camel_case}, % else: ${helpers.to_nscsspropertyid(prop.ident)} - => TransitionProperty::Unsupported(Atom::from("${prop.ident}")), + => TransitionProperty::Unsupported(CustomIdent(Atom::from("${prop.ident}"))), % endif % endfor nsCSSPropertyID::eCSSPropertyExtra_all_properties => TransitionProperty::All, diff --git a/tests/unit/style/parsing/transition_property.rs b/tests/unit/style/parsing/transition_property.rs index 5929489651c..68663b3cb19 100644 --- a/tests/unit/style/parsing/transition_property.rs +++ b/tests/unit/style/parsing/transition_property.rs @@ -7,6 +7,7 @@ use servo_atoms::Atom; use style::properties::animated_properties::TransitionProperty; use style::properties::longhands::transition_property; use style::properties::shorthands::transition; +use style::values::CustomIdent; use style_traits::ToCss; #[test] @@ -19,12 +20,15 @@ fn test_longhand_properties() { assert_roundtrip_with_context!(transition_property::parse, "-other-unsupported-property"); assert_roundtrip_with_context!(transition_property::parse, "--var"); - assert_eq!(parse_longhand!(transition_property, "margin-left, transition-delay, width, --var"), - transition_property::SpecifiedValue( - vec![TransitionProperty::MarginLeft, - TransitionProperty::Unsupported(Atom::from("transition-delay")), - TransitionProperty::Width, - TransitionProperty::Unsupported(Atom::from("--var"))])); + assert_eq!( + parse_longhand!(transition_property, "margin-left, transition-delay, width, --var"), + transition_property::SpecifiedValue(vec![ + TransitionProperty::MarginLeft, + TransitionProperty::Unsupported(CustomIdent(Atom::from("transition-delay"))), + TransitionProperty::Width, + TransitionProperty::Unsupported(CustomIdent(Atom::from("--var"))), + ]) + ); assert!(parse(transition_property::parse, ".width").is_err()); assert!(parse(transition_property::parse, "1width").is_err());