From b7d7a43ce41b3f332e0ac5243adb9395ec932512 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Thu, 24 Aug 2017 17:43:58 +0900 Subject: [PATCH] Try to update running CSS animations when CSS rules are changed. In the case where values in CSS rules changed directly by CSSOM, the old value in the CSS rule block is immediately replaced by the new one. So if the element, which is applied to the CSS rule, has running animations, the new value is used during cascading process in animation-only restyle. Thus in a subsequent normal restyle, we can't tell whether the value in the CSS rule has changed or not. As a result, transitions may not be triggered (bug 1393323) and CSS animations may not be cancelled if the updated animation-name is 'none' (this bug). For the latter case of CSS animations where animation-name has been updated to 'none', this patch introduces a workaround whereby we trigger an update of running animations whenever the traversal is triggered by changes to CSS rules and we have existing CSS animations. --- components/style/matching.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/style/matching.rs b/components/style/matching.rs index a00871018f5..701c20304f5 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -170,12 +170,12 @@ trait PrivateMatchMethods: TElement { // If the traverse is triggered by CSS rule changes, we need to // try to update all CSS animations on the element if the element - // has CSS animation style regardless of whether the animation is - // running or not. + // has or will have CSS animation style regardless of whether the + // animation is running or not. // TODO: We should check which @keyframes changed/added/deleted // and update only animations corresponding to those @keyframes. (context.shared.traversal_flags.contains(traversal_flags::ForCSSRuleChanges) && - has_new_animation_style) || + (has_new_animation_style || has_animations)) || !old_box_style.animations_equals(new_box_style) || (old_display_style == display::T::none && new_display_style != display::T::none &&