Bug 1434130 part 2 - Derive SpecifiedValueInfo for keywords types. r?emilio draft
authorXidorn Quan <me@upsuper.org>
Wed, 25 Apr 2018 14:59:08 +1000
changeset 787713 eaa465ddc6f2d225f964f179fa0cc95d6eabe065
parent 787712 eaf93e2fa00be04e5be8032b3c0f128db9e9065f
child 787714 3a214f7403cf0cdacc01fe652fd47c377d559602
push id107784
push userxquan@mozilla.com
push dateWed, 25 Apr 2018 09:07:56 +0000
reviewersemilio
bugs1434130
milestone61.0a1
Bug 1434130 part 2 - Derive SpecifiedValueInfo for keywords types. r?emilio I don't know why I didn't do that, but it seems it's easy to just have them derived... MozReview-Commit-ID: 6enkA0mEfbg
servo/components/style/properties/helpers.mako.rs
--- a/servo/components/style/properties/helpers.mako.rs
+++ b/servo/components/style/properties/helpers.mako.rs
@@ -391,29 +391,29 @@
         ]}
         keyword = keyword=Keyword(name, values, **keyword_kwargs)
     %>
     <%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
         use properties::longhands::system_font::SystemFont;
 
         pub mod computed_value {
             #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
-            #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse)]
-            #[derive(PartialEq, ToCss)]
+            #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse,
+                     PartialEq, SpecifiedValueInfo, ToCss)]
             pub enum T {
             % for value in keyword.values_for(product):
                 ${to_camel_case(value)},
             % endfor
             }
 
             ${gecko_keyword_conversion(keyword, keyword.values_for(product), type="T", cast_to="i32")}
         }
 
         #[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
-        #[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss)]
+        #[derive(Clone, Copy, Debug, Eq, PartialEq, SpecifiedValueInfo, ToCss)]
         pub enum SpecifiedValue {
             Keyword(computed_value::T),
             #[css(skip)]
             System(SystemFont),
         }
 
         pub fn parse<'i, 't>(_: &ParserContext, input: &mut Parser<'i, 't>) -> Result<SpecifiedValue, ParseError<'i>> {
             Ok(SpecifiedValue::Keyword(computed_value::T::parse(input)?))
@@ -454,18 +454,16 @@
             pub fn get_system(&self) -> Option<SystemFont> {
                 if let SpecifiedValue::System(s) = *self {
                     Some(s)
                 } else {
                     None
                 }
             }
         }
-
-        impl ::style_traits::SpecifiedValueInfo for SpecifiedValue {}
     </%call>
 </%def>
 
 <%def name="gecko_keyword_conversion(keyword, values=None, type='SpecifiedValue', cast_to=None)">
     <%
         if not values:
             values = keyword.values_for(product)
         maybe_cast = "as %s" % cast_to if cast_to else ""
@@ -556,28 +554,29 @@
             #[css(aliases = "${','.join(aliases)}")]
             % endif
             % endif
             ${to_camel_case(variant)},
             % endfor
         </%def>
         % if extra_specified:
             #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
-            #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)]
+            #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq,
+                     SpecifiedValueInfo, ToCss)]
             pub enum SpecifiedValue {
                 ${variants(keyword.values_for(product) + extra_specified.split(), bool(extra_specified))}
             }
         % else:
             pub use self::computed_value::T as SpecifiedValue;
         % endif
         pub mod computed_value {
             #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
             #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToCss)]
             % if not extra_specified:
-            #[derive(Parse, ToComputedValue)]
+            #[derive(Parse, SpecifiedValueInfo, ToComputedValue)]
             % endif
             pub enum T {
                 ${variants(data.longhands_by_name[name].keyword.values_for(product), not extra_specified)}
             }
         }
         #[inline]
         pub fn get_initial_value() -> computed_value::T {
             computed_value::T::${to_camel_case(values.split()[0])}
@@ -586,17 +585,16 @@
         pub fn get_initial_specified_value() -> SpecifiedValue {
             SpecifiedValue::${to_camel_case(values.split()[0])}
         }
         #[inline]
         pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
                              -> Result<SpecifiedValue, ParseError<'i>> {
             SpecifiedValue::parse(input)
         }
-        impl ::style_traits::SpecifiedValueInfo for SpecifiedValue {}
 
         % if needs_conversion:
             <%
                 conversion_values = keyword.values_for(product)
                 if extra_specified:
                     conversion_values += extra_specified.split()
                 conversion_values += keyword.aliases_for(product).keys()
             %>