зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1267510 part 3 - Add DocumentTimeline constructor. r=birtles
MozReview-Commit-ID: CqqDlHQsm0p --HG-- extra : rebase_source : 6f6f4583ffa57a4375af62c64a76081902b1f361
This commit is contained in:
Родитель
a9ead4dd43
Коммит
5b4de2dcff
|
@ -36,6 +36,31 @@ DocumentTimeline::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|||
return DocumentTimelineBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DocumentTimeline>
|
||||
DocumentTimeline::Constructor(const GlobalObject& aGlobal,
|
||||
const DOMHighResTimeStamp& aOriginTime,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsIDocument* doc = AnimationUtils::GetCurrentRealmDocument(aGlobal.Context());
|
||||
if (!doc) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TimeDuration originTime = TimeDuration::FromMilliseconds(aOriginTime);
|
||||
if (originTime == TimeDuration::Forever() ||
|
||||
originTime == -TimeDuration::Forever()) {
|
||||
nsAutoString inputOriginTime;
|
||||
inputOriginTime.AppendFloat(aOriginTime);
|
||||
aRv.ThrowTypeError<dom::MSG_TIME_VALUE_OUT_OF_RANGE>(
|
||||
NS_LITERAL_STRING("Origin time"));
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<DocumentTimeline> timeline = new DocumentTimeline(doc, originTime);
|
||||
|
||||
return timeline.forget();
|
||||
}
|
||||
|
||||
Nullable<TimeDuration>
|
||||
DocumentTimeline::GetCurrentTime() const
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "mozilla/TimeStamp.h"
|
||||
#include "AnimationTimeline.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsDOMNavigationTiming.h" // for DOMHighResTimeStamp
|
||||
#include "nsRefreshDriver.h"
|
||||
|
||||
struct JSContext;
|
||||
|
@ -51,6 +52,11 @@ public:
|
|||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
static already_AddRefed<DocumentTimeline>
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
const DOMHighResTimeStamp& aOriginTime,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// AnimationTimeline methods
|
||||
virtual Nullable<TimeDuration> GetCurrentTime() const override;
|
||||
|
||||
|
|
|
@ -98,4 +98,5 @@ MSG_DEF(MSG_INVALID_EASING_ERROR, 1, JSEXN_TYPEERR, "Invalid easing '{0}'.")
|
|||
MSG_DEF(MSG_USELESS_SETTIMEOUT, 1, JSEXN_TYPEERR, "Useless {0} call (missing quotes around argument?)")
|
||||
MSG_DEF(MSG_TOKENLIST_NO_SUPPORTED_TOKENS, 2, JSEXN_TYPEERR, "{0} attribute of <{1}> does not define any supported tokens")
|
||||
MSG_DEF(MSG_CACHE_STREAM_CLOSED, 0, JSEXN_TYPEERR, "Response body is a cache file stream that has already been closed.")
|
||||
MSG_DEF(MSG_TIME_VALUE_OUT_OF_RANGE, 1, JSEXN_TYPEERR, "{0} is outside the supported range for time values.")
|
||||
MSG_DEF(MSG_ONLY_IF_CACHED_WITHOUT_SAME_ORIGIN, 1, JSEXN_TYPEERR, "Request mode '{0}' was used, but request cache mode 'only-if-cached' can only be used with request mode 'same-origin'.")
|
||||
|
|
Загрузка…
Ссылка в новой задаче