Do not fill computed values in missing keyframes for CSS animations during generating Keyframes

This commit is contained in:
Hiroyuki Ikezoe 2017-07-10 17:17:50 +09:00
parent 95a85a301f
commit eb63511304

View file

@ -98,7 +98,7 @@ use style::properties::parse_one_declaration_into;
use style::rule_tree::StyleSource; use style::rule_tree::StyleSource;
use style::selector_parser::PseudoElementCascadeType; use style::selector_parser::PseudoElementCascadeType;
use style::sequential; use style::sequential;
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard, Locked}; use style::shared_lock::{SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard, Locked};
use style::string_cache::Atom; use style::string_cache::Atom;
use style::style_adjuster::StyleAdjuster; use style::style_adjuster::StyleAdjuster;
use style::stylearc::Arc; use style::stylearc::Arc;
@ -2978,18 +2978,12 @@ pub extern "C" fn Servo_AssertTreeIsClean(root: RawGeckoElementBorrowed) {
} }
fn append_computed_property_value(keyframe: *mut structs::Keyframe, fn append_computed_property_value(keyframe: *mut structs::Keyframe,
style: &ComputedValues, property: &AnimatableLonghand) {
property: &AnimatableLonghand,
shared_lock: &SharedRwLock) {
let block = style.to_declaration_block(property.clone().into());
unsafe { unsafe {
let index = (*keyframe).mPropertyValues.len(); let index = (*keyframe).mPropertyValues.len();
(*keyframe).mPropertyValues.set_len((index + 1) as u32); (*keyframe).mPropertyValues.set_len((index + 1) as u32);
(*keyframe).mPropertyValues[index].mProperty = property.into(); (*keyframe).mPropertyValues[index].mProperty = property.into();
// FIXME. Bug 1360398: Do not set computed values once we handles (*keyframe).mPropertyValues[index].mServoDeclarationBlock.mRawPtr = ptr::null_mut();
// missing keyframes with additive composition.
(*keyframe).mPropertyValues[index].mServoDeclarationBlock.set_arc_leaky(
Arc::new(shared_lock.wrap(block)));
} }
} }
@ -3000,11 +2994,9 @@ enum Offset {
fn fill_in_missing_keyframe_values(all_properties: &[AnimatableLonghand], fn fill_in_missing_keyframe_values(all_properties: &[AnimatableLonghand],
timing_function: nsTimingFunctionBorrowed, timing_function: nsTimingFunctionBorrowed,
style: &ComputedValues,
properties_set_at_offset: &LonghandIdSet, properties_set_at_offset: &LonghandIdSet,
offset: Offset, offset: Offset,
keyframes: RawGeckoKeyframeListBorrowedMut, keyframes: RawGeckoKeyframeListBorrowedMut) {
shared_lock: &SharedRwLock) {
let needs_filling = all_properties.iter().any(|ref property| { let needs_filling = all_properties.iter().any(|ref property| {
!properties_set_at_offset.has_animatable_longhand_bit(property) !properties_set_at_offset.has_animatable_longhand_bit(property)
}); });
@ -3026,10 +3018,7 @@ fn fill_in_missing_keyframe_values(all_properties: &[AnimatableLonghand],
// Append properties that have not been set at this offset. // Append properties that have not been set at this offset.
for ref property in all_properties.iter() { for ref property in all_properties.iter() {
if !properties_set_at_offset.has_animatable_longhand_bit(property) { if !properties_set_at_offset.has_animatable_longhand_bit(property) {
append_computed_property_value(keyframe, append_computed_property_value(keyframe, property);
style,
property,
shared_lock);
} }
} }
} }
@ -3038,7 +3027,6 @@ fn fill_in_missing_keyframe_values(all_properties: &[AnimatableLonghand],
pub extern "C" fn Servo_StyleSet_GetKeyframesForName(raw_data: RawServoStyleSetBorrowed, pub extern "C" fn Servo_StyleSet_GetKeyframesForName(raw_data: RawServoStyleSetBorrowed,
name: *const nsACString, name: *const nsACString,
inherited_timing_function: nsTimingFunctionBorrowed, inherited_timing_function: nsTimingFunctionBorrowed,
style: ServoComputedValuesBorrowed,
keyframes: RawGeckoKeyframeListBorrowedMut) -> bool { keyframes: RawGeckoKeyframeListBorrowedMut) -> bool {
debug_assert!(keyframes.len() == 0, debug_assert!(keyframes.len() == 0,
"keyframes should be initially empty"); "keyframes should be initially empty");
@ -3051,7 +3039,6 @@ pub extern "C" fn Servo_StyleSet_GetKeyframesForName(raw_data: RawServoStyleSetB
None => return false, None => return false,
}; };
let style = ComputedValues::as_arc(&style);
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();
@ -3094,10 +3081,7 @@ pub extern "C" fn Servo_StyleSet_GetKeyframesForName(raw_data: RawServoStyleSetB
// animation should be set to the underlying computed value for // animation should be set to the underlying computed value for
// that keyframe. // that keyframe.
for property in animation.properties_changed.iter() { for property in animation.properties_changed.iter() {
append_computed_property_value(keyframe, append_computed_property_value(keyframe, property);
style,
property,
&global_style_data.shared_lock);
} }
if current_offset == 0.0 { if current_offset == 0.0 {
has_complete_initial_keyframe = true; has_complete_initial_keyframe = true;
@ -3150,20 +3134,16 @@ pub extern "C" fn Servo_StyleSet_GetKeyframesForName(raw_data: RawServoStyleSetB
if !has_complete_initial_keyframe { if !has_complete_initial_keyframe {
fill_in_missing_keyframe_values(&animation.properties_changed, fill_in_missing_keyframe_values(&animation.properties_changed,
inherited_timing_function, inherited_timing_function,
style,
&properties_set_at_start, &properties_set_at_start,
Offset::Zero, Offset::Zero,
keyframes, keyframes);
&global_style_data.shared_lock);
} }
if !has_complete_final_keyframe { if !has_complete_final_keyframe {
fill_in_missing_keyframe_values(&animation.properties_changed, fill_in_missing_keyframe_values(&animation.properties_changed,
inherited_timing_function, inherited_timing_function,
style,
&properties_set_at_end, &properties_set_at_end,
Offset::One, Offset::One,
keyframes, keyframes);
&global_style_data.shared_lock);
} }
true true
} }