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
parent d34164be16
commit 8343e66e73
3 changed files with 30 additions and 1 deletions

View File

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

View File

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

View File

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