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;