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:
Brian Birtles 2014-07-16 09:02:30 +09:00
Родитель 7bb5ae0ed8
Коммит 728dbd075d
2 изменённых файлов: 20 добавлений и 14 удалений

Просмотреть файл

@ -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() { }