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.
This commit is contained in:
Brian Birtles 2014-12-18 08:42:41 +09:00
parent eaf8eca4e5
commit d603de6d36
2 changed files with 25 additions and 10 deletions

View File

@ -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

View File

@ -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<nsIDocument> mDocument;