Bug 1073336 part 12 - Add AnimationPlayer::GetCollection(); r=dbaron
authorBrian Birtles <birtles@gmail.com>
Mon, 17 Nov 2014 13:45:59 +0900
changeset 240286 80cffa4575c6e34bf94526df05d7d055ae4eb1bc
parent 240285 0758acd887497d5a4dee16dcdd2cc881d38904cc
child 240287 52a3c36054d602faf5ce1f84447e26efac7a78ca
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1073336
milestone36.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 1073336 part 12 - Add AnimationPlayer::GetCollection(); r=dbaron This patch adds a method to animation players that looks up the AnimationPlayerCollection to which the player belongs.
dom/animation/AnimationPlayer.cpp
dom/animation/AnimationPlayer.h
--- a/dom/animation/AnimationPlayer.cpp
+++ b/dom/animation/AnimationPlayer.cpp
@@ -1,16 +1,18 @@
 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "AnimationPlayer.h"
 #include "AnimationUtils.h"
 #include "mozilla/dom/AnimationPlayerBinding.h"
+#include "AnimationCommon.h" // For AnimationPlayerCollection,
+                             // CommonAnimationManager
 #include "nsIDocument.h" // For nsIDocument
 #include "nsIPresShell.h" // For nsIPresShell
 #include "nsLayoutUtils.h" // For PostRestyleEvent (remove after bug 1073336)
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AnimationPlayer, mTimeline, mSource)
@@ -271,10 +273,28 @@ AnimationPlayer::GetPresContext() const
   }
   nsIPresShell* shell = doc->GetShell();
   if (!shell) {
     return nullptr;
   }
   return shell->GetPresContext();
 }
 
+AnimationPlayerCollection*
+AnimationPlayer::GetCollection() const
+{
+  css::CommonAnimationManager* manager = GetAnimationManager();
+  if (!manager) {
+    return nullptr;
+  }
+  MOZ_ASSERT(mSource, "A player with an animation manager must have a source");
+
+  Element* targetElement;
+  nsCSSPseudoElements::Type targetPseudoType;
+  mSource->GetTarget(targetElement, targetPseudoType);
+  MOZ_ASSERT(targetElement,
+             "A player with an animation manager must have a target");
+
+  return manager->GetAnimationPlayers(targetElement, targetPseudoType, false);
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -21,16 +21,17 @@
 #endif
 
 struct JSContext;
 class nsCSSPropertySet;
 class nsIDocument;
 class nsPresContext;
 
 namespace mozilla {
+struct AnimationPlayerCollection;
 namespace css {
 class AnimValuesStyleRule;
 class CommonAnimationManager;
 } // namespace css
 
 class CSSAnimationPlayer;
 class CSSTransitionPlayer;
 
@@ -127,16 +128,17 @@ public:
 protected:
   void FlushStyle() const;
   void MaybePostRestyle() const;
   StickyTimeDuration SourceContentEnd() const;
 
   nsIDocument* GetRenderedDocument() const;
   nsPresContext* GetPresContext() const;
   virtual css::CommonAnimationManager* GetAnimationManager() const = 0;
+  AnimationPlayerCollection* GetCollection() const;
 
   nsRefPtr<AnimationTimeline> mTimeline;
   nsRefPtr<Animation> mSource;
   Nullable<TimeDuration> mHoldTime;  // Player timescale
   bool mIsPaused;
   bool mIsRunningOnCompositor;
   // Indicates whether we were in the finished state during our
   // most recent unthrottled sample (our last ComposeStyle call).