From d603de6d36452a28d3454ca8a6251743faf3616d Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Thu, 18 Dec 2014 08:42:41 +0900 Subject: [PATCH] Bug 927349 part 7 - Factor out AnimationTimeline::GetRefreshDriver into a separate method; r=jwatt This is in preparation for adding AnimationTimeline::FastForward in the next patch which will reuse this code. --- dom/animation/AnimationTimeline.cpp | 27 +++++++++++++++++++-------- dom/animation/AnimationTimeline.h | 8 ++++++-- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/dom/animation/AnimationTimeline.cpp b/dom/animation/AnimationTimeline.cpp index db5b0c91f7a..550fc766c66 100644 --- a/dom/animation/AnimationTimeline.cpp +++ b/dom/animation/AnimationTimeline.cpp @@ -55,17 +55,12 @@ AnimationTimeline::GetCurrentTimeStamp() const result = timing->GetNavigationStartTimeStamp(); } - nsIPresShell* presShell = mDocument->GetShell(); - if (MOZ_UNLIKELY(!presShell)) { + nsRefreshDriver* refreshDriver = GetRefreshDriver(); + if (!refreshDriver) { return result; } - nsPresContext* presContext = presShell->GetPresContext(); - if (MOZ_UNLIKELY(!presContext)) { - return result; - } - - result = presContext->RefreshDriver()->MostRecentRefresh(); + result = refreshDriver->MostRecentRefresh(); // FIXME: We would like to assert that: // mLastCurrentTime.IsNull() || result >= mLastCurrentTime // but due to bug 1043078 this will not be the case when the refresh driver @@ -104,5 +99,21 @@ AnimationTimeline::ToTimeStamp(const TimeDuration& aTimeDuration) const return result; } +nsRefreshDriver* +AnimationTimeline::GetRefreshDriver() const +{ + nsIPresShell* presShell = mDocument->GetShell(); + if (MOZ_UNLIKELY(!presShell)) { + return nullptr; + } + + nsPresContext* presContext = presShell->GetPresContext(); + if (MOZ_UNLIKELY(!presContext)) { + return nullptr; + } + + return presContext->RefreshDriver(); +} + } // namespace dom } // namespace mozilla diff --git a/dom/animation/AnimationTimeline.h b/dom/animation/AnimationTimeline.h index 7d019b9a130..21d63e86efb 100644 --- a/dom/animation/AnimationTimeline.h +++ b/dom/animation/AnimationTimeline.h @@ -14,6 +14,7 @@ #include "nsIDocument.h" struct JSContext; +class nsRefreshDriver; namespace mozilla { namespace dom { @@ -26,6 +27,10 @@ public: { } +protected: + virtual ~AnimationTimeline() { } + +public: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AnimationTimeline) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AnimationTimeline) @@ -47,8 +52,7 @@ public: protected: TimeStamp GetCurrentTimeStamp() const; - - virtual ~AnimationTimeline() { } + nsRefreshDriver* GetRefreshDriver() const; nsCOMPtr mDocument;