Bug 1504536 - Remove nscsspropertyid_is_{animatable,transitionable}. r=hiro
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 04 Nov 2018 14:01:19 +0100
changeset 444366 6884ba750aa3c76c3e9979c5da8c2caa12e761f1
parent 444365 a5cc88a8a6c3c551755268944937702f2b8318ae
child 444367 42257c17ab3712c7e59fdae516cf439e03afc75e
push id34994
push usercsabou@mozilla.com
push dateMon, 05 Nov 2018 16:18:20 +0000
treeherdermozilla-central@15adeb85dc27 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro
bugs1504536
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1504536 - Remove nscsspropertyid_is_{animatable,transitionable}. r=hiro There are better ways, plus the existing code didn't handle aliases at all (not that it needed to, but it's better if it does). Differential Revision: https://phabricator.services.mozilla.com/D10838
servo/components/style/properties/data.py
servo/components/style/properties/helpers/animated_properties.mako.rs
servo/components/style/properties/properties.mako.rs
servo/ports/geckolib/glue.rs
--- a/servo/components/style/properties/data.py
+++ b/servo/components/style/properties/data.py
@@ -427,16 +427,18 @@ class Shorthand(object):
 class Alias(object):
     def __init__(self, name, original, gecko_pref):
         self.name = name
         self.ident = to_rust_ident(name)
         self.camel_case = to_camel_case(self.ident)
         self.original = original
         self.enabled_in = original.enabled_in
         self.servo_pref = original.servo_pref
+        self.animatable = original.animatable
+        self.transitionable = original.transitionable
         self.gecko_pref = gecko_pref
         self.allowed_in_page_rule = original.allowed_in_page_rule
         self.allowed_in_keyframe_block = original.allowed_in_keyframe_block
 
     @staticmethod
     def type():
         return "alias"
 
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -45,30 +45,16 @@ use values::computed::transform::Scale a
 use values::computed::url::ComputedUrl;
 use values::generics::transform::{self, Rotate, Translate, Scale, Transform, TransformOperation};
 use values::distance::{ComputeSquaredDistance, SquaredDistance};
 use values::generics::effects::Filter;
 use values::generics::svg::{SVGLength,  SvgLengthOrPercentageOrNumber, SVGPaint};
 use values::generics::svg::{SVGPaintKind, SVGStrokeDashArray, SVGOpacity};
 use void::{self, Void};
 
-
-/// 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 + data.shorthands_except_all():
-            % if prop.animatable:
-                ${prop.nscsspropertyid()} => true,
-            % endif
-        % endfor
-        _ => false
-    }
-}
-
 /// Convert nsCSSPropertyID to TransitionProperty
 #[cfg(feature = "gecko")]
 #[allow(non_upper_case_globals)]
 impl From<nsCSSPropertyID> for TransitionProperty {
     fn from(property: nsCSSPropertyID) -> TransitionProperty {
         match property {
             % for prop in data.longhands:
             ${prop.nscsspropertyid()} => {
@@ -85,29 +71,16 @@ impl From<nsCSSPropertyID> for Transitio
             }
             _ => {
                 panic!("non-convertible nsCSSPropertyID")
             }
         }
     }
 }
 
-/// Returns true if this nsCSSPropertyID is one of the transitionable properties.
-#[cfg(feature = "gecko")]
-pub fn nscsspropertyid_is_transitionable(property: nsCSSPropertyID) -> bool {
-    match property {
-        % for prop in data.longhands + data.shorthands_except_all():
-            % if prop.transitionable:
-                ${prop.nscsspropertyid()} => true,
-            % endif
-        % endfor
-        _ => false
-    }
-}
-
 /// An animated property interpolation between two computed values for that
 /// property.
 #[derive(Clone, Debug, PartialEq)]
 #[cfg_attr(feature = "servo", derive(MallocSizeOf))]
 pub enum AnimatedProperty {
     % for prop in data.longhands:
         % if prop.animatable and not prop.logical:
             <%
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -466,16 +466,30 @@ impl NonCustomPropertyId {
         static MAP: [&'static str; NON_CUSTOM_PROPERTY_ID_COUNT] = [
             % for property in data.longhands + data.shorthands + data.all_aliases():
             "${property.name}",
             % endfor
         ];
         MAP[self.0]
     }
 
+    /// Returns whether this property is transitionable.
+    #[inline]
+    pub fn is_transitionable(self) -> bool {
+        ${static_non_custom_property_id_set("TRANSITIONABLE", lambda p: p.transitionable)}
+        TRANSITIONABLE.contains(self)
+    }
+
+    /// Returns whether this property is animatable.
+    #[inline]
+    pub fn is_animatable(self) -> bool {
+        ${static_non_custom_property_id_set("ANIMATABLE", lambda p: p.animatable)}
+        ANIMATABLE.contains(self)
+    }
+
     #[inline]
     fn enabled_for_all_content(self) -> bool {
         ${static_non_custom_property_id_set(
             "EXPERIMENTAL",
             lambda p: p.experimental(product)
         )}
 
         ${static_non_custom_property_id_set(
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -125,17 +125,17 @@ use style::gecko_bindings::structs::nsTi
 use style::gecko_bindings::structs::nsresult;
 use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasFFI, HasArcFFI};
 use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
 use style::gecko_bindings::sugar::refptr::RefPtr;
 use style::gecko_properties;
 use style::invalidation::element::restyle_hints;
 use style::media_queries::MediaList;
 use style::parser::{Parse, ParserContext, self};
-use style::properties::{ComputedValues, Importance};
+use style::properties::{ComputedValues, Importance, NonCustomPropertyId};
 use style::properties::{LonghandId, LonghandIdSet, PropertyDeclarationBlock, PropertyId};
 use style::properties::{PropertyDeclarationId, ShorthandId};
 use style::properties::{SourcePropertyDeclaration, StyleBuilder};
 use style::properties::{parse_one_declaration_into, parse_style_attribute};
 use style::properties::animated_properties::AnimationValue;
 use style::rule_cache::RuleCacheConditions;
 use style::rule_tree::{CascadeLevel, StrongRuleNode};
 use style::selector_parser::{PseudoElementCascadeType, SelectorImpl};
@@ -938,18 +938,16 @@ pub unsafe extern "C" fn Servo_Property_
     }
 }
 
 #[no_mangle]
 pub unsafe extern "C" fn Servo_Property_GetName(
     prop: nsCSSPropertyID,
     out_length: *mut u32,
 ) -> *const u8 {
-    use style::properties::NonCustomPropertyId;
-
     let (ptr, len) = match NonCustomPropertyId::from_nscsspropertyid(prop) {
         Ok(p) => {
             let name = p.name();
             (name.as_bytes().as_ptr(), name.len())
         }
         Err(..) => (ptr::null(), 0),
     };
 
@@ -1044,25 +1042,23 @@ pub unsafe extern "C" fn Servo_Property_
     bindings::Gecko_ResizeTArrayForStrings(result, len as u32);
 
     for (src, dest) in extras.iter().chain(values.iter()).zip(result.iter_mut()) {
         dest.write_str(src).unwrap();
     }
 }
 
 #[no_mangle]
-pub extern "C" fn Servo_Property_IsAnimatable(property: nsCSSPropertyID) -> bool {
-    use style::properties::animated_properties;
-    animated_properties::nscsspropertyid_is_animatable(property)
-}
-
-#[no_mangle]
-pub extern "C" fn Servo_Property_IsTransitionable(property: nsCSSPropertyID) -> bool {
-    use style::properties::animated_properties;
-    animated_properties::nscsspropertyid_is_transitionable(property)
+pub extern "C" fn Servo_Property_IsAnimatable(prop: nsCSSPropertyID) -> bool {
+    NonCustomPropertyId::from_nscsspropertyid(prop).ok().map_or(false, |p| p.is_animatable())
+}
+
+#[no_mangle]
+pub extern "C" fn Servo_Property_IsTransitionable(prop: nsCSSPropertyID) -> bool {
+    NonCustomPropertyId::from_nscsspropertyid(prop).ok().map_or(false, |p| p.is_transitionable())
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_Property_IsDiscreteAnimatable(property: nsCSSPropertyID) -> bool {
     match LonghandId::from_nscsspropertyid(property) {
         Ok(longhand) => longhand.is_discrete_animatable(),
         Err(()) => return false,
     }