From 5ce7b1cc5576ceb3286cacf0f9d2a9dd87984925 Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Thu, 15 Jun 2017 10:19:22 +0900 Subject: [PATCH] Move is_discrete from TransitionProperty to AnimatableLonghand --- components/style/gecko/wrapper.rs | 10 ++++---- .../helpers/animated_properties.mako.rs | 25 +++++++++---------- ports/geckolib/glue.rs | 7 +++--- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index f1e84c2129c..8aa229f7d26 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1130,14 +1130,14 @@ impl<'le> TElement for GeckoElement<'le> { -> bool { use properties::animated_properties::AnimatedProperty; - // We don't allow transitions on properties that are not interpolable. - if property.is_discrete() { - return false; - } - // |property| should be an animatable longhand let animatable_longhand = AnimatableLonghand::from_transition_property(property).unwrap(); + // We don't allow transitions on properties that are not interpolable. + if animatable_longhand.is_discrete() { + return false; + } + if existing_transitions.contains_key(property) { // If there is an existing transition, update only if the end value differs. // If the end value has not changed, we should leave the currently running diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 57b5cd1138e..315673c591f 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -63,6 +63,18 @@ pub enum AnimatableLonghand { } impl AnimatableLonghand { + /// Returns true if this AnimatableLonghand is one of the discretely animatable properties. + pub fn is_discrete(&self) -> bool { + match *self { + % for prop in data.longhands: + % if prop.animation_value_type == "discrete": + AnimatableLonghand::${prop.camel_case} => true, + % endif + % endfor + _ => false + } + } + /// Converts from an nsCSSPropertyID. Returns None if nsCSSPropertyID is not an animatable /// longhand in Servo. #[cfg(feature = "gecko")] @@ -224,19 +236,6 @@ impl TransitionProperty { }).map_err(|()| SelectorParseError::UnexpectedIdent(ident.into()).into()) } - /// Returns true if this TransitionProperty is one of the discrete animatable properties and - /// this TransitionProperty should be a longhand property. - pub fn is_discrete(&self) -> bool { - match *self { - % for prop in data.longhands: - % if prop.animation_value_type == "discrete": - TransitionProperty::${prop.camel_case} => true, - % endif - % endfor - _ => false - } - } - /// Return animatable longhands of this shorthand TransitionProperty, except for "all". pub fn longhands(&self) -> &'static [TransitionProperty] { % for prop in data.shorthands_except_all(): diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index dc9d7417266..4f997459cf2 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -96,7 +96,6 @@ use style::properties::{CascadeFlags, ComputedValues, Importance, SourceProperty use style::properties::{LonghandIdSet, PropertyDeclaration, PropertyDeclarationBlock, PropertyId, StyleBuilder}; use style::properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP; use style::properties::animated_properties::{Animatable, AnimatableLonghand, AnimationValue}; -use style::properties::animated_properties::TransitionProperty; use style::properties::parse_one_declaration_into; use style::rule_tree::StyleSource; use style::selector_parser::PseudoElementCascadeType; @@ -705,8 +704,10 @@ pub extern "C" fn Servo_Property_IsAnimatable(property: nsCSSPropertyID) -> bool #[no_mangle] pub extern "C" fn Servo_Property_IsDiscreteAnimatable(property: nsCSSPropertyID) -> bool { - let property: TransitionProperty = property.into(); - property.is_discrete() + match AnimatableLonghand::from_nscsspropertyid(property) { + Some(longhand) => longhand.is_discrete(), + None => false + } } #[no_mangle]