diff --git a/dom/animation/DocumentTimeline.cpp b/dom/animation/DocumentTimeline.cpp index a1c3078ea5d9..ffc18e8f3e4a 100644 --- a/dom/animation/DocumentTimeline.cpp +++ b/dom/animation/DocumentTimeline.cpp @@ -46,7 +46,7 @@ DocumentTimeline::WrapObject(JSContext* aCx, JS::Handle aGivenProto) /* static */ already_AddRefed DocumentTimeline::Constructor(const GlobalObject& aGlobal, - const DOMHighResTimeStamp& aOriginTime, + const DocumentTimelineOptions& aOptions, ErrorResult& aRv) { nsIDocument* doc = AnimationUtils::GetCurrentRealmDocument(aGlobal.Context()); @@ -54,12 +54,11 @@ DocumentTimeline::Constructor(const GlobalObject& aGlobal, aRv.Throw(NS_ERROR_FAILURE); return nullptr; } + TimeDuration originTime = + TimeDuration::FromMilliseconds(aOptions.mOriginTime); - TimeDuration originTime = TimeDuration::FromMilliseconds(aOriginTime); if (originTime == TimeDuration::Forever() || originTime == -TimeDuration::Forever()) { - nsAutoString inputOriginTime; - inputOriginTime.AppendFloat(aOriginTime); aRv.ThrowTypeError( NS_LITERAL_STRING("Origin time")); return nullptr; diff --git a/dom/animation/DocumentTimeline.h b/dom/animation/DocumentTimeline.h index a9e250f6d81d..b20f637f55e9 100644 --- a/dom/animation/DocumentTimeline.h +++ b/dom/animation/DocumentTimeline.h @@ -7,6 +7,7 @@ #ifndef mozilla_dom_DocumentTimeline_h #define mozilla_dom_DocumentTimeline_h +#include "mozilla/dom/DocumentTimelineBinding.h" #include "mozilla/TimeStamp.h" #include "AnimationTimeline.h" #include "nsIDocument.h" @@ -54,7 +55,7 @@ public: static already_AddRefed Constructor(const GlobalObject& aGlobal, - const DOMHighResTimeStamp& aOriginTime, + const DocumentTimelineOptions& aOptions, ErrorResult& aRv); // AnimationTimeline methods diff --git a/dom/animation/test/mozilla/file_document-timeline-origin-time-range.html b/dom/animation/test/mozilla/file_document-timeline-origin-time-range.html index 7c8c3f7f3d66..083bf0903b61 100644 --- a/dom/animation/test/mozilla/file_document-timeline-origin-time-range.html +++ b/dom/animation/test/mozilla/file_document-timeline-origin-time-range.html @@ -12,13 +12,17 @@ // inside the allowed range will just mean we overflow elsewhere. test(function(t) { - assert_throws({name: 'TypeError'}, - function() { new DocumentTimeline(Number.MAX_SAFE_INTEGER); }); + assert_throws({ name: 'TypeError'}, + function() { + new DocumentTimeline({ originTime: Number.MAX_SAFE_INTEGER }); + }); }, 'Calculated current time is positive infinity'); test(function(t) { - assert_throws({name: 'TypeError'}, - function() { new DocumentTimeline(-1 * Number.MAX_SAFE_INTEGER); }); + assert_throws({ name: 'TypeError'}, + function() { + new DocumentTimeline({ originTime: -1 * Number.MAX_SAFE_INTEGER }); + }); }, 'Calculated current time is negative infinity'); done(); diff --git a/dom/webidl/DocumentTimeline.webidl b/dom/webidl/DocumentTimeline.webidl index ed30c53414a9..916b1a4911cc 100644 --- a/dom/webidl/DocumentTimeline.webidl +++ b/dom/webidl/DocumentTimeline.webidl @@ -10,7 +10,11 @@ * liability, trademark and document use rules apply. */ +dictionary DocumentTimelineOptions { + DOMHighResTimeStamp originTime = 0; +}; + [Func="nsDocument::IsWebAnimationsEnabled", - Constructor (DOMHighResTimeStamp originTime)] + Constructor (optional DocumentTimelineOptions options)] interface DocumentTimeline : AnimationTimeline { }; diff --git a/testing/web-platform/meta/web-animations/interfaces/DocumentTimeline/constructor.html.ini b/testing/web-platform/meta/web-animations/interfaces/DocumentTimeline/constructor.html.ini deleted file mode 100644 index 0bfee0d2aef9..000000000000 --- a/testing/web-platform/meta/web-animations/interfaces/DocumentTimeline/constructor.html.ini +++ /dev/null @@ -1,17 +0,0 @@ -[constructor.html] - type: testharness - [An origin time of zero is used when none is supplied] - expected: FAIL - bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1302038 - - [A zero origin time produces a document timeline with a current time identical to the default document timeline] - expected: FAIL - bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1302038 - - [A positive origin time makes the document timeline's current time lag behind the default document timeline] - expected: FAIL - bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1302038 - - [A negative origin time makes the document timeline's current time run ahead of the default document timeline] - expected: FAIL - bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1302038 diff --git a/testing/web-platform/tests/web-animations/interfaces/AnimationTimeline/idlharness.html b/testing/web-platform/tests/web-animations/interfaces/AnimationTimeline/idlharness.html index 04afcada07af..29c891407729 100644 --- a/testing/web-platform/tests/web-animations/interfaces/AnimationTimeline/idlharness.html +++ b/testing/web-platform/tests/web-animations/interfaces/AnimationTimeline/idlharness.html @@ -12,7 +12,10 @@ interface AnimationTimeline { };