Bug 1074054 part 2 - Make Element::GetAnimationPlayers return in-effect animations too; r=dbaron
authorBrian Birtles <birtles@gmail.com>
Thu, 02 Oct 2014 15:14:14 +0900
changeset 208352 35e518128ca302874769f17abcee7f754dae9d30
parent 208351 3a4ecfff302a300e8165265eabca94f95d95dfda
child 208353 28519d825a239e028fd12c8c59a8e53ba3f24ffc
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdbaron
bugs1074054
milestone35.0a1
Bug 1074054 part 2 - Make Element::GetAnimationPlayers return in-effect animations too; r=dbaron This patch makes Element::GetAnimationPlayers return not only current animations but also animations that have finished but are filling forwards. This brings the implementation into line with recent changes to the Web Animations spec and allows querying all the animations that are currently affecting an element or which are scheduled to do so in the future.
content/base/src/Element.cpp
dom/animation/AnimationPlayer.h
dom/animation/test/css-integration/test_element-get-animation-players.html
--- a/content/base/src/Element.cpp
+++ b/content/base/src/Element.cpp
@@ -2953,17 +2953,17 @@ Element::GetAnimationPlayers(nsTArray<ns
         GetProperty(properties[propIdx]));
     if (!collection) {
       continue;
     }
     for (size_t playerIdx = 0;
          playerIdx < collection->mPlayers.Length();
          playerIdx++) {
       AnimationPlayer* player = collection->mPlayers[playerIdx];
-      if (player->HasCurrentSource()) {
+      if (player->HasCurrentSource() || player->HasInEffectSource()) {
         aPlayers.AppendElement(player);
       }
     }
   }
 }
 
 NS_IMETHODIMP
 Element::GetInnerHTML(nsAString& aInnerHTML)
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -63,16 +63,19 @@ public:
     return mPlayState == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED;
   }
 
   bool IsRunning() const;
 
   bool HasCurrentSource() const {
     return GetSource() && GetSource()->IsCurrent();
   }
+  bool HasInEffectSource() const {
+    return GetSource() && GetSource()->IsInEffect();
+  }
 
   // Return the duration since the start time of the player, taking into
   // account the pause state.  May be negative or null.
   Nullable<TimeDuration> GetCurrentTimeDuration() const;
 
   // The beginning of the delay period.
   Nullable<TimeDuration> mStartTime;
   Nullable<TimeDuration> mHoldTime;
--- a/dom/animation/test/css-integration/test_element-get-animation-players.html
+++ b/dom/animation/test/css-integration/test_element-get-animation-players.html
@@ -148,16 +148,33 @@ async_test(function(t) {
   // Add a very short animation
   div.style.animation = 'anim1 0.01s';
 }, 'getAnimationPlayers for CSS Animations that have finished');
 
 async_test(function(t) {
   var div = addDiv();
 
   // Set up event listener
+  div.addEventListener('animationend', t.step_func(function() {
+    assert_equals(div.getAnimationPlayers().length, 1,
+      'getAnimationPlayers returns players for CSS Animations that have'
+      + ' finished but are filling forwards');
+    div.remove();
+    t.done();
+  }));
+
+  // Add a very short animation
+  div.style.animation = 'anim1 0.01s forwards';
+}, 'getAnimationPlayers for CSS Animations that have finished but are'
+   + ' forwards filling');
+
+async_test(function(t) {
+  var div = addDiv();
+
+  // Set up event listener
   div.addEventListener('transitionend', t.step_func(function() {
     assert_equals(div.getAnimationPlayers().length, 0,
       'getAnimationPlayers does not return finished CSS Transitions');
     div.remove();
     t.done();
   }));
 
   // Add a very short transition