From fdb8c48094ba6b38703d7880c173bfe3368590d2 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Fri, 10 Mar 2017 11:09:17 +0900 Subject: [PATCH] Split off animation related process in a function. --- components/style/matching.rs | 75 +++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/components/style/matching.rs b/components/style/matching.rs index f47276d83a6..d0649ee181e 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -562,7 +562,6 @@ trait PrivateMatchMethods: TElement { possibly_expired_animations: &mut Vec, booleans: CascadeBooleans) { // Collect some values. - let shared_context = context.shared; let (mut styles, restyle) = data.styles_and_restyle_mut(); let mut primary_style = &mut styles.primary; let pseudos = &mut styles.pseudos; @@ -575,31 +574,12 @@ trait PrivateMatchMethods: TElement { &mut pseudo_style, &booleans); // Handle animations. - if booleans.animate && cfg!(feature = "servo") { - if let Some(ref mut old) = old_values { - self.update_animations_for_cascade(shared_context, old, - possibly_expired_animations); - } - - let new_animations_sender = &context.thread_local.new_animations_sender; - let this_opaque = self.as_node().opaque(); - // Trigger any present animations if necessary. - animation::maybe_start_animations(&shared_context, - new_animations_sender, - this_opaque, &new_values); - - // Trigger transitions if necessary. This will reset `new_values` back - // to its old value if it did trigger a transition. - if let Some(ref values) = old_values { - animation::start_transitions_if_applicable( - new_animations_sender, - this_opaque, - self.as_node().to_unsafe(), - &**values, - &mut new_values, - &shared_context.timer, - &possibly_expired_animations); - } + if booleans.animate { + self.process_animations(&context, + &mut old_values, + &mut new_values, + pseudo, + possibly_expired_animations); } // Accumulate restyle damage. @@ -615,6 +595,49 @@ trait PrivateMatchMethods: TElement { } } + #[cfg(feature = "gecko")] + fn process_animations(&self, + _context: &StyleContext, + _old_values: &mut Option>, + _new_values: &mut Arc, + _pseudo: Option<&PseudoElement>, + _possibly_expired_animations: &mut Vec) { + } + + #[cfg(feature = "servo")] + fn process_animations(&self, + context: &StyleContext, + old_values: &mut Option>, + new_values: &mut Arc, + _pseudo: Option<&PseudoElement>, + possibly_expired_animations: &mut Vec) { + let shared_context = context.shared; + if let Some(ref mut old) = *old_values { + self.update_animations_for_cascade(shared_context, old, + possibly_expired_animations); + } + + let new_animations_sender = &context.thread_local.new_animations_sender; + let this_opaque = self.as_node().opaque(); + // Trigger any present animations if necessary. + animation::maybe_start_animations(&shared_context, + new_animations_sender, + this_opaque, &new_values); + + // Trigger transitions if necessary. This will reset `new_values` back + // to its old value if it did trigger a transition. + if let Some(ref values) = *old_values { + animation::start_transitions_if_applicable( + new_animations_sender, + this_opaque, + self.as_node().to_unsafe(), + &**values, + new_values, + &shared_context.timer, + &possibly_expired_animations); + } + } + /// Computes and applies non-redundant damage. #[cfg(feature = "gecko")] fn accumulate_damage(&self,