style: Tweak Stylist API for getting animations to avoid exposing the hash table.

This commit is contained in:
Cameron McCormack 2017-08-07 16:04:30 +08:00
parent 6bdb0abebf
commit 68268226ea
3 changed files with 6 additions and 6 deletions

View file

@ -533,7 +533,7 @@ pub fn maybe_start_animations(context: &SharedStyleContext,
continue continue
} }
if let Some(ref anim) = context.stylist.animations().get(name) { if let Some(ref anim) = context.stylist.get_animation(name) {
debug!("maybe_start_animations: animation {} found", name); debug!("maybe_start_animations: animation {} found", name);
// If this animation doesn't have any keyframe, we can just continue // If this animation doesn't have any keyframe, we can just continue
@ -637,7 +637,7 @@ pub fn update_style_for_animation(context: &SharedStyleContext,
KeyframesRunningState::Paused(progress) => started_at + duration * progress, KeyframesRunningState::Paused(progress) => started_at + duration * progress,
}; };
let animation = match context.stylist.animations().get(name) { let animation = match context.stylist.get_animation(name) {
None => { None => {
warn!("update_style_for_animation: Animation {:?} not found", name); warn!("update_style_for_animation: Animation {:?} not found", name);
return; return;

View file

@ -1327,10 +1327,10 @@ impl Stylist {
self.is_device_dirty self.is_device_dirty
} }
/// Returns the map of registered `@keyframes` animations. /// Returns the registered `@keyframes` animation for the specified name.
#[inline] #[inline]
pub fn animations(&self) -> &PrecomputedHashMap<Atom, KeyframesAnimation> { pub fn get_animation(&self, name: &Atom) -> Option<&KeyframesAnimation> {
&self.animations self.animations.get(name)
} }
/// Computes the match results of a given element against the set of /// Computes the match results of a given element against the set of

View file

@ -3286,7 +3286,7 @@ pub extern "C" fn Servo_StyleSet_GetKeyframesForName(raw_data: RawServoStyleSetB
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 animation = match data.stylist.animations().get(&name) { let animation = match data.stylist.get_animation(&name) {
Some(animation) => animation, Some(animation) => animation,
None => return false, None => return false,
}; };