diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 0ad9937acfc..21897405c88 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -24,6 +24,7 @@ use error_reporting::ParseErrorReporter; use euclid::size::Size2D; use computed_values; use font_metrics::FontMetricsProvider; +#[cfg(feature = "gecko")] use gecko_bindings::structs::nsCSSPropertyID; #[cfg(feature = "servo")] use logical_geometry::{LogicalMargin, PhysicalSide}; use logical_geometry::WritingMode; use parser::{Parse, ParserContext, ParserContextExtraData}; @@ -637,6 +638,38 @@ impl PropertyId { } } + #[cfg(feature = "gecko")] + #[allow(non_upper_case_globals)] + pub fn from_nscsspropertyid(id: nsCSSPropertyID) -> Result { + use gecko_bindings::structs::*; + <% + def to_nscsspropertyid(ident): + if ident == "word_wrap": + return "nsCSSPropertyID_eCSSPropertyAlias_WordWrap" + + if ident == "float": + ident = "float_" + elif "outline_radius" in ident: + ident = ident.replace("right", "Right").replace("left", "Left") + elif ident.startswith("_moz_"): + ident = ident[len("_moz_"):] + return "nsCSSPropertyID::eCSSProperty_" + ident + %> + match id { + % for property in data.longhands: + ${to_nscsspropertyid(property.ident)} => { + Ok(PropertyId::Longhand(LonghandId::${property.camel_case})) + } + % endfor + % for property in data.shorthands: + ${to_nscsspropertyid(property.ident)} => { + Ok(PropertyId::Shorthand(ShorthandId::${property.camel_case})) + } + % endfor + _ => Err(()) + } + } + pub fn as_shorthand(&self) -> Result { match *self { PropertyId::Shorthand(id) => Ok(id),