Skip to content

Commit

Permalink
Convert AnimationValue::from_computed_values to take an AnimatableLon…
Browse files Browse the repository at this point in the history
…ghand
  • Loading branch information
birtles committed Jun 15, 2017
1 parent 8f3dad5 commit a2307ad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
9 changes: 5 additions & 4 deletions components/style/gecko/wrapper.rs
Expand Up @@ -1135,18 +1135,19 @@ impl<'le> TElement for GeckoElement<'le> {
return false;
}

// |property| should be an animatable longhand
let animatable_longhand = AnimatableLonghand::from_transition_property(property).unwrap();

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
// transition as-is since we don't want to interrupt its timing function.
let after_value =
Arc::new(AnimationValue::from_computed_values(property, after_change_style));
Arc::new(AnimationValue::from_computed_values(&animatable_longhand,
after_change_style));
return existing_transitions.get(property).unwrap() != &after_value;
}

// |property| should be an animatable longhand
let animatable_longhand = AnimatableLonghand::from_transition_property(property).unwrap();

combined_duration > 0.0f32 &&
AnimatedProperty::from_animatable_longhand(&animatable_longhand,
before_change_style,
Expand Down
10 changes: 4 additions & 6 deletions components/style/properties/helpers/animated_properties.mako.rs
Expand Up @@ -621,15 +621,14 @@ impl AnimationValue {
}
}

/// Get an AnimationValue for a TransitionProperty from a given computed values.
pub fn from_computed_values(transition_property: &TransitionProperty,
/// Get an AnimationValue for an AnimatableLonghand from a given computed values.
pub fn from_computed_values(property: &AnimatableLonghand,
computed_values: &ComputedValues)
-> Self {
match *transition_property {
TransitionProperty::All => panic!("Can't use TransitionProperty::All here."),
match *property {
% for prop in data.longhands:
% if prop.animatable:
TransitionProperty::${prop.camel_case} => {
AnimatableLonghand::${prop.camel_case} => {
AnimationValue::${prop.camel_case}(
% if prop.is_animatable_with_computed_value:
computed_values.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}())
Expand All @@ -640,7 +639,6 @@ impl AnimationValue {
}
% endif
% endfor
ref other => panic!("Can't use TransitionProperty::{:?} here.", other),
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion ports/geckolib/glue.rs
Expand Up @@ -688,8 +688,13 @@ pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(computed_values: Se
property_id: nsCSSPropertyID)
-> RawServoAnimationValueStrong
{
let property = match AnimatableLonghand::from_nscsspropertyid(property_id) {
Some(longhand) => longhand,
None => { return Strong::null(); }
};

let computed_values = ComputedValues::as_arc(&computed_values);
Arc::new(AnimationValue::from_computed_values(&property_id.into(), computed_values)).into_strong()
Arc::new(AnimationValue::from_computed_values(&property, computed_values)).into_strong()
}

#[no_mangle]
Expand Down

0 comments on commit a2307ad

Please sign in to comment.