Split off animation related process in a function.

This commit is contained in:
Hiroyuki Ikezoe 2017-03-10 11:09:17 +09:00
parent 22de4dc7a6
commit fdb8c48094

View file

@ -562,7 +562,6 @@ trait PrivateMatchMethods: TElement {
possibly_expired_animations: &mut Vec<PropertyAnimation>, possibly_expired_animations: &mut Vec<PropertyAnimation>,
booleans: CascadeBooleans) { booleans: CascadeBooleans) {
// Collect some values. // Collect some values.
let shared_context = context.shared;
let (mut styles, restyle) = data.styles_and_restyle_mut(); let (mut styles, restyle) = data.styles_and_restyle_mut();
let mut primary_style = &mut styles.primary; let mut primary_style = &mut styles.primary;
let pseudos = &mut styles.pseudos; let pseudos = &mut styles.pseudos;
@ -575,8 +574,45 @@ trait PrivateMatchMethods: TElement {
&mut pseudo_style, &booleans); &mut pseudo_style, &booleans);
// Handle animations. // Handle animations.
if booleans.animate && cfg!(feature = "servo") { if booleans.animate {
if let Some(ref mut old) = old_values { self.process_animations(&context,
&mut old_values,
&mut new_values,
pseudo,
possibly_expired_animations);
}
// Accumulate restyle damage.
if let Some(old) = old_values {
self.accumulate_damage(restyle.unwrap(), &old, &new_values, pseudo);
}
// Set the new computed values.
if let Some((_, ref mut style)) = pseudo_style {
style.values = Some(new_values);
} else {
primary_style.values = Some(new_values);
}
}
#[cfg(feature = "gecko")]
fn process_animations(&self,
_context: &StyleContext<Self>,
_old_values: &mut Option<Arc<ComputedValues>>,
_new_values: &mut Arc<ComputedValues>,
_pseudo: Option<&PseudoElement>,
_possibly_expired_animations: &mut Vec<PropertyAnimation>) {
}
#[cfg(feature = "servo")]
fn process_animations(&self,
context: &StyleContext<Self>,
old_values: &mut Option<Arc<ComputedValues>>,
new_values: &mut Arc<ComputedValues>,
_pseudo: Option<&PseudoElement>,
possibly_expired_animations: &mut Vec<PropertyAnimation>) {
let shared_context = context.shared;
if let Some(ref mut old) = *old_values {
self.update_animations_for_cascade(shared_context, old, self.update_animations_for_cascade(shared_context, old,
possibly_expired_animations); possibly_expired_animations);
} }
@ -590,31 +626,18 @@ trait PrivateMatchMethods: TElement {
// Trigger transitions if necessary. This will reset `new_values` back // Trigger transitions if necessary. This will reset `new_values` back
// to its old value if it did trigger a transition. // to its old value if it did trigger a transition.
if let Some(ref values) = old_values { if let Some(ref values) = *old_values {
animation::start_transitions_if_applicable( animation::start_transitions_if_applicable(
new_animations_sender, new_animations_sender,
this_opaque, this_opaque,
self.as_node().to_unsafe(), self.as_node().to_unsafe(),
&**values, &**values,
&mut new_values, new_values,
&shared_context.timer, &shared_context.timer,
&possibly_expired_animations); &possibly_expired_animations);
} }
} }
// Accumulate restyle damage.
if let Some(old) = old_values {
self.accumulate_damage(restyle.unwrap(), &old, &new_values, pseudo);
}
// Set the new computed values.
if let Some((_, ref mut style)) = pseudo_style {
style.values = Some(new_values);
} else {
primary_style.values = Some(new_values);
}
}
/// Computes and applies non-redundant damage. /// Computes and applies non-redundant damage.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
fn accumulate_damage(&self, fn accumulate_damage(&self,