зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1032573 part 4 - Add AnimationTimeline::ToTimelineTime helper method; r=dbaron
This patch simply factors out the conversion from a TimeStamp value to a nullable-double value relative to the start of the timeline. This is so that, in a subsequent patch, this functionality can be reused by ElementAnimation when it reports its start time (which is currently recorded as a TimeStamp).
This commit is contained in:
Родитель
7bb5ae0ed8
Коммит
728dbd075d
|
@ -29,20 +29,7 @@ AnimationTimeline::WrapObject(JSContext* aCx)
|
|||
Nullable<double>
|
||||
AnimationTimeline::GetCurrentTime() const
|
||||
{
|
||||
Nullable<double> result; // Default ctor initializes to null
|
||||
|
||||
nsRefPtr<nsDOMNavigationTiming> timing = mDocument->GetNavigationTiming();
|
||||
if (!timing) {
|
||||
return result;
|
||||
}
|
||||
|
||||
TimeStamp now = GetCurrentTimeStamp();
|
||||
if (now.IsNull()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result.SetValue(timing->TimeStampToDOMHighRes(now));
|
||||
return result;
|
||||
return ToTimelineTime(GetCurrentTimeStamp());
|
||||
}
|
||||
|
||||
TimeStamp
|
||||
|
@ -65,5 +52,22 @@ AnimationTimeline::GetCurrentTimeStamp() const
|
|||
return result;
|
||||
}
|
||||
|
||||
Nullable<double>
|
||||
AnimationTimeline::ToTimelineTime(const mozilla::TimeStamp& aTimeStamp) const
|
||||
{
|
||||
Nullable<double> result; // Initializes to null
|
||||
if (aTimeStamp.IsNull()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
nsRefPtr<nsDOMNavigationTiming> timing = mDocument->GetNavigationTiming();
|
||||
if (MOZ_UNLIKELY(!timing)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result.SetValue(timing->TimeStampToDOMHighRes(aTimeStamp));
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -38,6 +38,8 @@ public:
|
|||
Nullable<double> GetCurrentTime() const;
|
||||
mozilla::TimeStamp GetCurrentTimeStamp() const;
|
||||
|
||||
Nullable<double> ToTimelineTime(const mozilla::TimeStamp& aTimeStamp) const;
|
||||
|
||||
protected:
|
||||
virtual ~AnimationTimeline() { }
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче