style: Break needs_animations_update into pieces.

To hopefully make some sense out of it.
This commit is contained in:
Emilio Cobos Álvarez 2018-02-24 22:43:00 +01:00
parent e30a4d2ad2
commit f2a808ad58
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -238,26 +238,43 @@ trait PrivateMatchMethods: TElement {
None => return has_new_animation_style, None => return has_new_animation_style,
}; };
let has_animations = self.has_css_animations();
let old_box_style = old.get_box(); let old_box_style = old.get_box();
let old_display_style = old_box_style.clone_display();
let new_display_style = new_box_style.clone_display();
// If the traverse is triggered by CSS rule changes, we need to let keyframes_could_have_changed =
// try to update all CSS animations on the element if the element context.shared.traversal_flags.contains(TraversalFlags::ForCSSRuleChanges);
// has or will have CSS animation style regardless of whether the
// animation is running or not. // If the traversal is triggered due to changes in CSS rules changes, we
// TODO: We should check which @keyframes changed/added/deleted // need to try to update all CSS animations on the element if the
// and update only animations corresponding to those @keyframes. // element has or will have CSS animation style regardless of whether
(context.shared.traversal_flags.contains(TraversalFlags::ForCSSRuleChanges) && // the animation is running or not.
(has_new_animation_style || has_animations)) || //
!old_box_style.animations_equals(new_box_style) || // TODO: We should check which @keyframes were added/changed/deleted and
(old_display_style == Display::None && // update only animations corresponding to those @keyframes.
new_display_style != Display::None && if keyframes_could_have_changed &&
has_new_animation_style) || (has_new_animation_style || self.has_css_animations())
(old_display_style != Display::None && {
new_display_style == Display::None && return true;
has_animations) }
// If the animations changed, well...
if !old_box_style.animations_equals(new_box_style) {
return true;
}
let old_display = old_box_style.clone_display();
let new_display = new_box_style.clone_display();
// If we were display: none, we may need to trigger animations.
if old_display == Display::None && new_display != Display::None {
return has_new_animation_style;
}
// If we are becoming display: none, we may need to stop animations.
if old_display != Display::None && new_display == Display::None {
return self.has_css_animations();
}
false
} }
/// Create a SequentialTask for resolving descendants in a SMIL display property /// Create a SequentialTask for resolving descendants in a SMIL display property