Bug 1353628 - Part 3: Create PropertyAnimation for shorthands.

Therefore, we can start transitions on shorthand properties properly.

MozReview-Commit-ID: Ev2u2tEalnK
This commit is contained in:
Boris Chiou 2017-04-19 10:44:30 +08:00
parent 3a1421491b
commit 43f9f8ca95
2 changed files with 21 additions and 0 deletions

View file

@ -272,6 +272,15 @@ impl PropertyAnimation {
let timing_function = box_style.transition_timing_function_mod(transition_index); let timing_function = box_style.transition_timing_function_mod(transition_index);
let duration = box_style.transition_duration_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 transition_property != TransitionProperty::All {
if let Some(property_animation) = if let Some(property_animation) =
@ -305,6 +314,8 @@ impl PropertyAnimation {
old_style: &ComputedValues, old_style: &ComputedValues,
new_style: &ComputedValues) new_style: &ComputedValues)
-> Option<PropertyAnimation> { -> Option<PropertyAnimation> {
debug_assert!(!transition_property.is_shorthand() &&
transition_property != TransitionProperty::All);
let animated_property = AnimatedProperty::from_transition_property(&transition_property, let animated_property = AnimatedProperty::from_transition_property(&transition_property,
old_style, old_style,
new_style); new_style);

View file

@ -158,6 +158,16 @@ impl TransitionProperty {
_ => panic!("Not allowed to call longhands() for this 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. /// Returns true if this nsCSSPropertyID is one of the animatable properties.