mirror of
https://github.com/servo/servo.git
synced 2025-06-23 16:44:33 +01:00
Convert AnimationValue::from_computed_values to take an AnimatableLonghand
This commit is contained in:
parent
8f3dad598f
commit
a2307adf46
3 changed files with 15 additions and 11 deletions
|
@ -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,
|
||||
|
|
|
@ -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}())
|
||||
|
@ -640,7 +639,6 @@ impl AnimationValue {
|
|||
}
|
||||
% endif
|
||||
% endfor
|
||||
ref other => panic!("Can't use TransitionProperty::{:?} here.", other),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue