Bug 998246 part 4 - Add currentTime member to AnimationTimeline; r=bz

This commit is contained in:
Brian Birtles 2014-05-13 16:22:12 +09:00
Родитель 248c1facd0
Коммит 3312bd13c9
3 изменённых файлов: 30 добавлений и 1 удалений

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

@ -6,6 +6,10 @@
#include "AnimationTimeline.h"
#include "mozilla/dom/AnimationTimelineBinding.h"
#include "nsContentUtils.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsRefreshDriver.h"
#include "nsDOMNavigationTiming.h"
namespace mozilla {
namespace dom {
@ -21,5 +25,28 @@ AnimationTimeline::WrapObject(JSContext* aCx)
return AnimationTimelineBinding::Wrap(aCx, this);
}
Nullable<double>
AnimationTimeline::GetCurrentTime() const
{
Nullable<double> result; // Default ctor initializes to null
nsIPresShell* presShell = mDocument->GetShell();
if (!presShell)
return result;
nsPresContext* presContext = presShell->GetPresContext();
if (!presContext)
return result;
nsRefPtr<nsDOMNavigationTiming> timing = mDocument->GetNavigationTiming();
if (!timing)
return result;
TimeStamp now = presContext->RefreshDriver()->MostRecentRefresh();
result.SetValue(timing->TimeStampToDOMHighRes(now));
return result;
}
} // namespace dom
} // namespace mozilla

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

@ -34,6 +34,8 @@ public:
nsISupports* GetParentObject() const { return mDocument; }
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
Nullable<double> GetCurrentTime() const;
protected:
nsCOMPtr<nsIDocument> mDocument;
};

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

@ -12,7 +12,7 @@
[Pref="dom.animations-api.core.enabled"]
interface AnimationTimeline {
// readonly attribute double? currentTime;
readonly attribute double? currentTime;
// AnimationPlayer play (optional TimedItem? source = null);
// sequence<AnimationPlayer> getAnimationPlayers ();
};