Bug 1371518 - Move definition of animatable for shorthands to Shorthand object; r?hiro draft
authorBrian Birtles <birtles@gmail.com>
Wed, 14 Jun 2017 14:15:23 +0900
changeset 593851 faf5d7183ac77f3087afe5eff3d8551d3d2ed372
parent 593850 e393ef19c444c0933bc9edc058dd81a3c5f2389e
child 593852 2ec206dda31926dd66ee5930a09dd5cf5140ea5d
push id63840
push userbbirtles@mozilla.com
push dateWed, 14 Jun 2017 07:29:38 +0000
reviewershiro
bugs1371518
milestone56.0a1
Bug 1371518 - Move definition of animatable for shorthands to Shorthand object; r?hiro By moving this definition to the Shorthand object we can more easily re-use it in subsequent patches in this series. MozReview-Commit-ID: CVbxq6hlRCK
servo/components/style/properties/data.py
servo/components/style/properties/helpers/animated_properties.mako.rs
--- a/servo/components/style/properties/data.py
+++ b/servo/components/style/properties/data.py
@@ -229,16 +229,26 @@ class Shorthand(object):
 
         # https://drafts.csswg.org/css-animations/#keyframes
         # > The <declaration-list> inside of <keyframe-block> accepts any CSS property
         # > except those defined in this specification,
         # > but does accept the `animation-play-state` property and interprets it specially.
         self.allowed_in_keyframe_block = allowed_in_keyframe_block \
             and allowed_in_keyframe_block != "False"
 
+    def get_animatable(self):
+        animatable = False
+        for sub in self.sub_properties:
+            if sub.animatable:
+                animatable = True
+                break
+        return animatable
+
+    animatable = property(get_animatable)
+
 
 class Method(object):
     def __init__(self, name, return_type=None, arg_types=None, is_mut=False):
         self.name = name
         self.return_type = return_type
         self.arg_types = arg_types or []
         self.is_mut = is_mut
 
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -190,31 +190,21 @@ impl TransitionProperty {
         }
     }
 }
 
 /// Returns true if this nsCSSPropertyID is one of the animatable properties.
 #[cfg(feature = "gecko")]
 pub fn nscsspropertyid_is_animatable(property: nsCSSPropertyID) -> bool {
     match property {
-        % for prop in data.longhands:
+        % for prop in data.longhands + data.shorthands_except_all():
             % if prop.animatable:
                 ${helpers.to_nscsspropertyid(prop.ident)} => true,
             % endif
         % endfor
-        % for prop in data.shorthands_except_all():
-            <%
-                animatable = "false"
-                for sub in prop.sub_properties:
-                    if sub.animatable:
-                        animatable = "true"
-                        break
-            %>
-            ${helpers.to_nscsspropertyid(prop.ident)} => ${animatable},
-        % endfor
         _ => false
     }
 }
 
 impl ToCss for TransitionProperty {
     fn to_css<W>(&self, dest: &mut W) -> fmt::Result
         where W: fmt::Write,
     {