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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// |property| should be an animatable longhand
|
||||||
|
let animatable_longhand = AnimatableLonghand::from_transition_property(property).unwrap();
|
||||||
|
|
||||||
if existing_transitions.contains_key(property) {
|
if existing_transitions.contains_key(property) {
|
||||||
// If there is an existing transition, update only if the end value differs.
|
// 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
|
// 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.
|
// transition as-is since we don't want to interrupt its timing function.
|
||||||
let after_value =
|
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;
|
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 &&
|
combined_duration > 0.0f32 &&
|
||||||
AnimatedProperty::from_animatable_longhand(&animatable_longhand,
|
AnimatedProperty::from_animatable_longhand(&animatable_longhand,
|
||||||
before_change_style,
|
before_change_style,
|
||||||
|
|
|
@ -621,15 +621,14 @@ impl AnimationValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get an AnimationValue for a TransitionProperty from a given computed values.
|
/// Get an AnimationValue for an AnimatableLonghand from a given computed values.
|
||||||
pub fn from_computed_values(transition_property: &TransitionProperty,
|
pub fn from_computed_values(property: &AnimatableLonghand,
|
||||||
computed_values: &ComputedValues)
|
computed_values: &ComputedValues)
|
||||||
-> Self {
|
-> Self {
|
||||||
match *transition_property {
|
match *property {
|
||||||
TransitionProperty::All => panic!("Can't use TransitionProperty::All here."),
|
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
% if prop.animatable:
|
% if prop.animatable:
|
||||||
TransitionProperty::${prop.camel_case} => {
|
AnimatableLonghand::${prop.camel_case} => {
|
||||||
AnimationValue::${prop.camel_case}(
|
AnimationValue::${prop.camel_case}(
|
||||||
% if prop.is_animatable_with_computed_value:
|
% if prop.is_animatable_with_computed_value:
|
||||||
computed_values.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}())
|
computed_values.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}())
|
||||||
|
@ -640,7 +639,6 @@ impl AnimationValue {
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% 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)
|
property_id: nsCSSPropertyID)
|
||||||
-> RawServoAnimationValueStrong
|
-> RawServoAnimationValueStrong
|
||||||
{
|
{
|
||||||
|
let property = match AnimatableLonghand::from_nscsspropertyid(property_id) {
|
||||||
|
Some(longhand) => longhand,
|
||||||
|
None => { return Strong::null(); }
|
||||||
|
};
|
||||||
|
|
||||||
let computed_values = ComputedValues::as_arc(&computed_values);
|
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]
|
#[no_mangle]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue