diff --git a/dom/animation/PendingPlayerTracker.cpp b/dom/animation/PendingPlayerTracker.cpp index 7fb7d872b92..efddaf564c0 100644 --- a/dom/animation/PendingPlayerTracker.cpp +++ b/dom/animation/PendingPlayerTracker.cpp @@ -13,15 +13,19 @@ using namespace mozilla; namespace mozilla { -NS_IMPL_CYCLE_COLLECTION(PendingPlayerTracker, mPlayPendingSet, mDocument) +NS_IMPL_CYCLE_COLLECTION(PendingPlayerTracker, + mPlayPendingSet, + mPausePendingSet, + mDocument) NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(PendingPlayerTracker, AddRef) NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(PendingPlayerTracker, Release) void -PendingPlayerTracker::AddPlayPending(dom::AnimationPlayer& aPlayer) +PendingPlayerTracker::AddPending(dom::AnimationPlayer& aPlayer, + AnimationPlayerSet& aSet) { - mPlayPendingSet.PutEntry(&aPlayer); + aSet.PutEntry(&aPlayer); // Schedule a paint. Otherwise animations that don't trigger a paint by // themselves (e.g. CSS animations with an empty keyframes rule) won't @@ -30,15 +34,17 @@ PendingPlayerTracker::AddPlayPending(dom::AnimationPlayer& aPlayer) } void -PendingPlayerTracker::RemovePlayPending(dom::AnimationPlayer& aPlayer) +PendingPlayerTracker::RemovePending(dom::AnimationPlayer& aPlayer, + AnimationPlayerSet& aSet) { - mPlayPendingSet.RemoveEntry(&aPlayer); + aSet.RemoveEntry(&aPlayer); } bool -PendingPlayerTracker::IsWaitingToPlay(dom::AnimationPlayer const& aPlayer) const +PendingPlayerTracker::IsWaiting(const dom::AnimationPlayer& aPlayer, + const AnimationPlayerSet& aSet) const { - return mPlayPendingSet.Contains(const_cast(&aPlayer)); + return aSet.Contains(const_cast(&aPlayer)); } PLDHashOperator diff --git a/dom/animation/PendingPlayerTracker.h b/dom/animation/PendingPlayerTracker.h index 9f974dd5ac7..8438f90f1dd 100644 --- a/dom/animation/PendingPlayerTracker.h +++ b/dom/animation/PendingPlayerTracker.h @@ -25,13 +25,41 @@ public: 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; + void AddPlayPending(dom::AnimationPlayer& aPlayer) + { + MOZ_ASSERT(!IsWaitingToPause(aPlayer), + "Player is already waiting to pause"); + AddPending(aPlayer, mPlayPendingSet); + } + void RemovePlayPending(dom::AnimationPlayer& aPlayer) + { + RemovePending(aPlayer, mPlayPendingSet); + } + bool IsWaitingToPlay(const dom::AnimationPlayer& aPlayer) const + { + return IsWaiting(aPlayer, mPlayPendingSet); + } + + void AddPausePending(dom::AnimationPlayer& aPlayer) + { + MOZ_ASSERT(!IsWaitingToPlay(aPlayer), + "Player is already waiting to play"); + AddPending(aPlayer, mPausePendingSet); + } + void RemovePausePending(dom::AnimationPlayer& aPlayer) + { + RemovePending(aPlayer, mPausePendingSet); + } + bool IsWaitingToPause(const dom::AnimationPlayer& aPlayer) const + { + return IsWaiting(aPlayer, mPausePendingSet); + } void StartPendingPlayersOnNextTick(const TimeStamp& aReadyTime); void StartPendingPlayersNow(); - bool HasPendingPlayers() const { return mPlayPendingSet.Count() > 0; } + bool HasPendingPlayers() const { + return mPlayPendingSet.Count() > 0 || mPausePendingSet.Count() > 0; + } private: ~PendingPlayerTracker() { } @@ -41,7 +69,15 @@ private: typedef nsTHashtable> AnimationPlayerSet; + void AddPending(dom::AnimationPlayer& aPlayer, + AnimationPlayerSet& aSet); + void RemovePending(dom::AnimationPlayer& aPlayer, + AnimationPlayerSet& aSet); + bool IsWaiting(const dom::AnimationPlayer& aPlayer, + const AnimationPlayerSet& aSet) const; + AnimationPlayerSet mPlayPendingSet; + AnimationPlayerSet mPausePendingSet; nsCOMPtr mDocument; };