Bug 1046055 part 3 - Add AnimationPlayerCollection::HasCurrentAnimationsForProperty; r=dbaron
authorBrian Birtles <birtles@gmail.com>
Thu, 02 Oct 2014 15:14:13 +0900
changeset 231563 860a94d6002a4b80b385dc47fae95ad505b64ddd
parent 231562 37090bda656483e2e7163403b3d67b2051431311
child 231564 4945682e29a6f714ff04e93e0221030f5d6a343e
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1046055
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1046055 part 3 - Add AnimationPlayerCollection::HasCurrentAnimationsForProperty; r=dbaron This patch adds another method to AnimationPlayerCollection alongside HasCurrentAnimations that returns true if there is a player in the collection with current source content that targets the specified property. At the same time it also makes the original HasCurrentAnimations a const method.
layout/style/AnimationCommon.cpp
layout/style/AnimationCommon.h
--- a/layout/style/AnimationCommon.cpp
+++ b/layout/style/AnimationCommon.cpp
@@ -714,20 +714,34 @@ void
 AnimationPlayerCollection::UpdateAnimationGeneration(
   nsPresContext* aPresContext)
 {
   mAnimationGeneration =
     aPresContext->RestyleManager()->GetAnimationGeneration();
 }
 
 bool
-AnimationPlayerCollection::HasCurrentAnimations()
+AnimationPlayerCollection::HasCurrentAnimations() const
 {
   for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
     if (mPlayers[playerIdx]->HasCurrentSource()) {
       return true;
     }
   }
 
   return false;
 }
 
+bool
+AnimationPlayerCollection::HasCurrentAnimationsForProperty(nsCSSProperty
+                                                             aProperty) const
+{
+  for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
+    const Animation* anim = mPlayers[playerIdx]->GetSource();
+    if (anim && anim->IsCurrent() && anim->HasAnimationOfProperty(aProperty)) {
+      return true;
+    }
+  }
+
+  return false;
 }
+
+}
--- a/layout/style/AnimationCommon.h
+++ b/layout/style/AnimationCommon.h
@@ -299,19 +299,21 @@ struct AnimationPlayerCollection : publi
   // mAnimationGeneration is the sequence number of the last flush where a
   // transition/animation changed.  We keep a similar count on the
   // corresponding layer so we can check that the layer is up to date with
   // the animation manager.
   uint64_t mAnimationGeneration;
   // Update mAnimationGeneration to nsCSSFrameConstructor's count
   void UpdateAnimationGeneration(nsPresContext* aPresContext);
 
-  // Returns true if there is an animation in the before or active phase
-  // at the current time.
-  bool HasCurrentAnimations();
+  // Returns true if there is an animation that has yet to finish.
+  bool HasCurrentAnimations() const;
+  // Returns true if there is an animation of the specified property that
+  // has yet to finish.
+  bool HasCurrentAnimationsForProperty(nsCSSProperty aProperty) const;
 
   // The refresh time associated with mStyleRule.
   TimeStamp mStyleRuleRefreshTime;
 
   // False when we know that our current style rule is valid
   // indefinitely into the future (because all of our animations are
   // either completed or paused).  May be invalidated by a style change.
   bool mNeedsRefreshes;