From 68268226eac23f064054be01d6839fbba45325be Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Mon, 7 Aug 2017 16:04:30 +0800 Subject: [PATCH] style: Tweak Stylist API for getting animations to avoid exposing the hash table. --- components/style/animation.rs | 4 ++-- components/style/stylist.rs | 6 +++--- ports/geckolib/glue.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/style/animation.rs b/components/style/animation.rs index 69b94edb580..c1a49fca7a1 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -533,7 +533,7 @@ pub fn maybe_start_animations(context: &SharedStyleContext, 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); // 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, }; - let animation = match context.stylist.animations().get(name) { + let animation = match context.stylist.get_animation(name) { None => { warn!("update_style_for_animation: Animation {:?} not found", name); return; diff --git a/components/style/stylist.rs b/components/style/stylist.rs index ccf7a196e1a..4b26371add1 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -1327,10 +1327,10 @@ impl Stylist { self.is_device_dirty } - /// Returns the map of registered `@keyframes` animations. + /// Returns the registered `@keyframes` animation for the specified name. #[inline] - pub fn animations(&self) -> &PrecomputedHashMap { - &self.animations + pub fn get_animation(&self, name: &Atom) -> Option<&KeyframesAnimation> { + self.animations.get(name) } /// Computes the match results of a given element against the set of diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index a8fadfc202c..131644f22c5 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -3286,7 +3286,7 @@ pub extern "C" fn Servo_StyleSet_GetKeyframesForName(raw_data: RawServoStyleSetB let data = PerDocumentStyleData::from_ffi(raw_data).borrow(); 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, None => return false, };