Bug 927349 part 14 - Store reference to owning document on PendingPlayerTracker; r=jwatt
authorBrian Birtles <birtles@gmail.com>
Mon, 22 Dec 2014 09:35:41 +0900
changeset 220798 9ff976d369ff942753e52e63a200f404276be184
parent 220797 0743f344f853387ab01b574f43192e9bceed580e
child 220799 da5d7b9bff8f11a62427a9a4507a131ea4a9e058
push id53192
push userbbirtles@mozilla.com
push dateMon, 22 Dec 2014 00:36:19 +0000
treeherdermozilla-inbound@c7aaf7025e59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs927349
milestone37.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 927349 part 14 - Store reference to owning document on PendingPlayerTracker; r=jwatt This patch adds a reference from PendingPlayerTracker back to the document object that owns it. This is used in the next patch in this series to find the document's root frame for scheduling a paint.
dom/animation/PendingPlayerTracker.cpp
dom/animation/PendingPlayerTracker.h
dom/base/nsDocument.cpp
--- a/dom/animation/PendingPlayerTracker.cpp
+++ b/dom/animation/PendingPlayerTracker.cpp
@@ -6,17 +6,17 @@
 #include "PendingPlayerTracker.h"
 
 #include "mozilla/dom/AnimationTimeline.h"
 
 using namespace mozilla;
 
 namespace mozilla {
 
-NS_IMPL_CYCLE_COLLECTION(PendingPlayerTracker, mPlayPendingSet)
+NS_IMPL_CYCLE_COLLECTION(PendingPlayerTracker, mPlayPendingSet, mDocument)
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(PendingPlayerTracker, AddRef)
 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(PendingPlayerTracker, Release)
 
 void
 PendingPlayerTracker::AddPlayPending(dom::AnimationPlayer& aPlayer)
 {
   mPlayPendingSet.PutEntry(&aPlayer);
--- a/dom/animation/PendingPlayerTracker.h
+++ b/dom/animation/PendingPlayerTracker.h
@@ -3,23 +3,28 @@
  * 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/. */
 
 #ifndef mozilla_dom_PendingPlayerTracker_h
 #define mozilla_dom_PendingPlayerTracker_h
 
 #include "mozilla/dom/AnimationPlayer.h"
 #include "nsCycleCollectionParticipant.h"
+#include "nsIDocument.h"
 #include "nsTHashtable.h"
 
 namespace mozilla {
 
 class PendingPlayerTracker MOZ_FINAL
 {
 public:
+  explicit PendingPlayerTracker(nsIDocument* aDocument)
+    : mDocument(aDocument)
+  { }
+
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(PendingPlayerTracker)
   NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(PendingPlayerTracker)
 
   void AddPlayPending(dom::AnimationPlayer& aPlayer);
   void RemovePlayPending(dom::AnimationPlayer& aPlayer);
   bool IsWaitingToPlay(dom::AnimationPlayer const& aPlayer) const;
 
   // Causes any pending players to resume at |aReadyTime| by first
@@ -28,13 +33,14 @@ public:
 
 private:
   ~PendingPlayerTracker() { }
 
   typedef nsTHashtable<nsRefPtrHashKey<dom::AnimationPlayer>>
     AnimationPlayerSet;
 
   AnimationPlayerSet mPlayPendingSet;
+  nsCOMPtr<nsIDocument> mDocument;
 };
 
 } // namespace mozilla
 
 #endif // mozilla_dom_PendingPlayerTracker_h
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -7392,17 +7392,17 @@ nsDocument::GetAnimationController()
 
   return mAnimationController;
 }
 
 PendingPlayerTracker*
 nsDocument::GetOrCreatePendingPlayerTracker()
 {
   if (!mPendingPlayerTracker) {
-    mPendingPlayerTracker = new PendingPlayerTracker();
+    mPendingPlayerTracker = new PendingPlayerTracker(this);
   }
 
   return mPendingPlayerTracker;
 }
 
 /**
  * Retrieve the "direction" property of the document.
  *