Early return if there is no animation matching to the given name.

This commit is contained in:
Hiroyuki Ikezoe 2017-05-12 19:28:20 +09:00
parent 5e5d3559d9
commit c53a8e8446

View file

@ -2195,14 +2195,18 @@ pub extern "C" fn Servo_StyleSet_FillKeyframesForName(raw_data: RawServoStyleSet
use style::gecko_bindings::structs::Keyframe; use style::gecko_bindings::structs::Keyframe;
use style::properties::LonghandIdSet; use style::properties::LonghandIdSet;
let data = PerDocumentStyleData::from_ffi(raw_data).borrow(); let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
let name = unsafe { Atom::from(name.as_ref().unwrap().as_str_unchecked()) }; let name = unsafe { Atom::from(name.as_ref().unwrap().as_str_unchecked()) };
let style = ComputedValues::as_arc(&style);
if let Some(ref animation) = data.stylist.animations().get(&name) { let animation = match data.stylist.animations().get(&name) {
Some(animation) => animation,
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();
for step in &animation.steps { for step in &animation.steps {
// Override timing_function if the keyframe has animation-timing-function. // Override timing_function if the keyframe has animation-timing-function.
let timing_function = if let Some(val) = step.get_animation_timing_function(&guard) { let timing_function = if let Some(val) = step.get_animation_timing_function(&guard) {
@ -2284,9 +2288,7 @@ pub extern "C" fn Servo_StyleSet_FillKeyframesForName(raw_data: RawServoStyleSet
}, },
} }
} }
return true true
}
false
} }
#[no_mangle] #[no_mangle]