Bug 1302038 part 2 - Add DocumentTimelineOptions dictionary. r?birtles
MozReview-Commit-ID: 6i0PafTmFFo
--- a/dom/animation/DocumentTimeline.cpp
+++ b/dom/animation/DocumentTimeline.cpp
@@ -41,30 +41,29 @@ NS_IMPL_RELEASE_INHERITED(DocumentTimeli
JSObject*
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,
+ const DocumentTimelineOptions& aOptions,
ErrorResult& aRv)
{
nsIDocument* doc = AnimationUtils::GetCurrentRealmDocument(aGlobal.Context());
if (!doc) {
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<dom::MSG_TIME_VALUE_OUT_OF_RANGE>(
NS_LITERAL_STRING("Origin time"));
return nullptr;
}
RefPtr<DocumentTimeline> timeline = new DocumentTimeline(doc, originTime);
return timeline.forget();
}
--- a/dom/animation/DocumentTimeline.h
+++ b/dom/animation/DocumentTimeline.h
@@ -2,16 +2,17 @@
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#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"
#include "nsDOMNavigationTiming.h" // for DOMHighResTimeStamp
#include "nsRefreshDriver.h"
struct JSContext;
@@ -49,17 +50,17 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DocumentTimeline,
AnimationTimeline)
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
static already_AddRefed<DocumentTimeline>
Constructor(const GlobalObject& aGlobal,
- const DOMHighResTimeStamp& aOriginTime,
+ const DocumentTimelineOptions& aOptions,
ErrorResult& aRv);
// AnimationTimeline methods
virtual Nullable<TimeDuration> GetCurrentTime() const override;
bool TracksWallclockTime() const override
{
nsRefreshDriver* refreshDriver = GetRefreshDriver();
--- a/dom/animation/test/mozilla/file_document-timeline-origin-time-range.html
+++ b/dom/animation/test/mozilla/file_document-timeline-origin-time-range.html
@@ -7,20 +7,24 @@
// If the originTime parameter passed to the DocumentTimeline exceeds
// the range of the internal storage type (a signed 64-bit integer number
// of ticks--a platform-dependent unit) then we should throw.
// Infinity isn't allowed as an origin time value and clamping to just
// 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();
</script>
</body>
--- a/dom/webidl/DocumentTimeline.webidl
+++ b/dom/webidl/DocumentTimeline.webidl
@@ -5,12 +5,16 @@
*
* The origin of this IDL file is
* https://w3c.github.io/web-animations/#documenttimeline
*
* Copyright © 2015 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* 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 {
};
deleted file mode 100644
--- 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
--- a/testing/web-platform/tests/web-animations/interfaces/AnimationTimeline/idlharness.html
+++ b/testing/web-platform/tests/web-animations/interfaces/AnimationTimeline/idlharness.html
@@ -7,17 +7,20 @@
<script src="/resources/idlharness.js"></script>
<div id="log"></div>
<script type="text/plain" id="AnimationTimeline-IDL">
interface AnimationTimeline {
readonly attribute double? currentTime;
};
</script>
<script type="text/plain" id="DocumentTimeline-IDL">
-[Constructor (DOMHighResTimeStamp originTime)]
+dictionary DocumentTimelineOptions {
+ DOMHighResTimeStamp originTime = 0;
+};
+[Constructor (optional DocumentTimelineOptions options)]
interface DocumentTimeline : AnimationTimeline {
};
</script>
<script>
'use strict';
var idlArray;
test(function() {