mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Merge keyframe values at the same offset and of the same timing function.
This commit is contained in:
parent
285da1b621
commit
07a24471de
1 changed files with 33 additions and 20 deletions
|
@ -40,7 +40,7 @@ use style::gecko_bindings::bindings::{RawServoStyleSheetStrong, ServoComputedVal
|
||||||
use style::gecko_bindings::bindings::{RawServoSupportsRule, RawServoSupportsRuleBorrowed};
|
use style::gecko_bindings::bindings::{RawServoSupportsRule, RawServoSupportsRuleBorrowed};
|
||||||
use style::gecko_bindings::bindings::{ServoCssRulesBorrowed, ServoCssRulesStrong};
|
use style::gecko_bindings::bindings::{ServoCssRulesBorrowed, ServoCssRulesStrong};
|
||||||
use style::gecko_bindings::bindings::{nsACString, nsAString};
|
use style::gecko_bindings::bindings::{nsACString, nsAString};
|
||||||
use style::gecko_bindings::bindings::Gecko_AnimationAppendKeyframe;
|
use style::gecko_bindings::bindings::Gecko_GetOrCreateKeyframeAtStart;
|
||||||
use style::gecko_bindings::bindings::RawGeckoAnimationPropertySegmentBorrowed;
|
use style::gecko_bindings::bindings::RawGeckoAnimationPropertySegmentBorrowed;
|
||||||
use style::gecko_bindings::bindings::RawGeckoComputedKeyframeValuesListBorrowedMut;
|
use style::gecko_bindings::bindings::RawGeckoComputedKeyframeValuesListBorrowedMut;
|
||||||
use style::gecko_bindings::bindings::RawGeckoComputedTimingBorrowed;
|
use style::gecko_bindings::bindings::RawGeckoComputedTimingBorrowed;
|
||||||
|
@ -2207,15 +2207,27 @@ pub extern "C" fn Servo_StyleSet_FillKeyframesForName(raw_data: RawServoStyleSet
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
let guard = global_style_data.shared_lock.read();
|
let guard = global_style_data.shared_lock.read();
|
||||||
|
|
||||||
for step in &animation.steps {
|
let mut properties_set_at_current_offset = LonghandIdSet::new();
|
||||||
|
let mut current_offset = -1.;
|
||||||
|
|
||||||
|
// Walk backwards through the keyframes and drop overridden properties.
|
||||||
|
for step in animation.steps.iter().rev() {
|
||||||
|
if step.start_percentage.0 != current_offset {
|
||||||
|
properties_set_at_current_offset.clear();
|
||||||
|
current_offset = step.start_percentage.0;
|
||||||
|
}
|
||||||
|
|
||||||
// Override timing_function if the keyframe has animation-timing-function.
|
// Override timing_function if the keyframe has animation-timing-function.
|
||||||
let timing_function = match step.get_animation_timing_function(&guard) {
|
let timing_function = match step.get_animation_timing_function(&guard) {
|
||||||
Some(val) => val.into(),
|
Some(val) => val.into(),
|
||||||
None => *timing_function,
|
None => *timing_function,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Look for an existing keyframe with the same offset and timing
|
||||||
|
// function or else add a new keyframe at the beginning of the keyframe
|
||||||
|
// array.
|
||||||
let keyframe = unsafe {
|
let keyframe = unsafe {
|
||||||
Gecko_AnimationAppendKeyframe(keyframes,
|
Gecko_GetOrCreateKeyframeAtStart(keyframes,
|
||||||
step.start_percentage.0 as f32,
|
step.start_percentage.0 as f32,
|
||||||
&timing_function)
|
&timing_function)
|
||||||
};
|
};
|
||||||
|
@ -2253,9 +2265,12 @@ pub extern "C" fn Servo_StyleSet_FillKeyframesForName(raw_data: RawServoStyleSet
|
||||||
declaration.is_animatable()
|
declaration.is_animatable()
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut seen = LonghandIdSet::new();
|
let mut index = unsafe { (*keyframe).mPropertyValues.len() };
|
||||||
|
for &(ref declaration, _) in animatable {
|
||||||
|
let property = TransitionProperty::from_declaration(declaration).unwrap();
|
||||||
|
if !properties_set_at_current_offset.has_transition_property_bit(&property) {
|
||||||
|
properties_set_at_current_offset.set_transition_property_bit(&property);
|
||||||
|
|
||||||
for (index, &(ref declaration, _)) in animatable.enumerate() {
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let property = TransitionProperty::from_declaration(declaration).unwrap();
|
let property = TransitionProperty::from_declaration(declaration).unwrap();
|
||||||
(*keyframe).mPropertyValues.set_len((index + 1) as u32);
|
(*keyframe).mPropertyValues.set_len((index + 1) as u32);
|
||||||
|
@ -2265,10 +2280,8 @@ pub extern "C" fn Servo_StyleSet_FillKeyframesForName(raw_data: RawServoStyleSet
|
||||||
PropertyDeclarationBlock::with_one(
|
PropertyDeclarationBlock::with_one(
|
||||||
declaration.clone(), Importance::Normal
|
declaration.clone(), Importance::Normal
|
||||||
))));
|
))));
|
||||||
if step.start_percentage.0 == 0. ||
|
|
||||||
step.start_percentage.0 == 1. {
|
|
||||||
seen.set_transition_property_bit(&property);
|
|
||||||
}
|
}
|
||||||
|
index += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2277,7 +2290,7 @@ pub extern "C" fn Servo_StyleSet_FillKeyframesForName(raw_data: RawServoStyleSet
|
||||||
step.start_percentage.0 == 1. {
|
step.start_percentage.0 == 1. {
|
||||||
let mut index = unsafe { (*keyframe).mPropertyValues.len() };
|
let mut index = unsafe { (*keyframe).mPropertyValues.len() };
|
||||||
for property in animation.properties_changed.iter() {
|
for property in animation.properties_changed.iter() {
|
||||||
if !seen.has_transition_property_bit(&property) {
|
if !properties_set_at_current_offset.has_transition_property_bit(&property) {
|
||||||
add_computed_property_value(
|
add_computed_property_value(
|
||||||
keyframe, index, style, property, &global_style_data.shared_lock);
|
keyframe, index, style, property, &global_style_data.shared_lock);
|
||||||
index += 1;
|
index += 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue