From 43f9f8ca957a41f0e4dada0c33bf15d870be50a9 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Wed, 19 Apr 2017 10:44:30 +0800 Subject: [PATCH] Bug 1353628 - Part 3: Create PropertyAnimation for shorthands. Therefore, we can start transitions on shorthand properties properly. MozReview-Commit-ID: Ev2u2tEalnK --- components/style/animation.rs | 11 +++++++++++ .../properties/helpers/animated_properties.mako.rs | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/components/style/animation.rs b/components/style/animation.rs index aeff683f407..63998083d6d 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -272,6 +272,15 @@ impl PropertyAnimation { let timing_function = box_style.transition_timing_function_mod(transition_index); let duration = box_style.transition_duration_mod(transition_index); + if transition_property.is_shorthand() { + return transition_property.longhands().iter().filter_map(|transition_property| { + PropertyAnimation::from_transition_property(*transition_property, + timing_function, + duration, + old_style, + new_style) + }).collect(); + } if transition_property != TransitionProperty::All { if let Some(property_animation) = @@ -305,6 +314,8 @@ impl PropertyAnimation { old_style: &ComputedValues, new_style: &ComputedValues) -> Option { + debug_assert!(!transition_property.is_shorthand() && + transition_property != TransitionProperty::All); let animated_property = AnimatedProperty::from_transition_property(&transition_property, old_style, new_style); diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 721b858e59b..5e49b263605 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -158,6 +158,16 @@ impl TransitionProperty { _ => panic!("Not allowed to call longhands() for this TransitionProperty") } } + + /// Returns true if this TransitionProperty is a shorthand. + pub fn is_shorthand(&self) -> bool { + match *self { + % for prop in data.shorthands_except_all(): + TransitionProperty::${prop.camel_case} => true, + % endfor + _ => false + } + } } /// Returns true if this nsCSSPropertyID is one of the animatable properties.