[Web Animations] Make WPT test at interfaces/DocumentTimeline/constructor.html pass...
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Jul 2018 23:52:54 +0000 (23:52 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Jul 2018 23:52:54 +0000 (23:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186498
<rdar://problem/41000205>
LayoutTests/imported/w3c:

Reviewed by Dean Jackson.

Mark 4 new WPT progressions.

* web-platform-tests/web-animations/interfaces/DocumentTimeline/constructor-expected.txt:

Source/WebCore:

Reviewed by Dean Jackson.

Add a Constructor to the DocumentTimeline IDL to match the spec and ensure we respect the provided
origin time. To ensure all DocumentTimeline instances report matching current times, we read the
current time from the "main" document timeline, the one created by the Document automatically.

* CMakeLists.txt:
* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::create):
(WebCore::DocumentTimeline::DocumentTimeline):
(WebCore::DocumentTimeline::currentTime):
* animation/DocumentTimeline.h:
* animation/DocumentTimeline.idl:
* animation/DocumentTimelineOptions.h:
* animation/DocumentTimelineOptions.idl:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233667 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/DocumentTimeline/constructor-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/animation/DocumentTimeline.cpp
Source/WebCore/animation/DocumentTimeline.h
Source/WebCore/animation/DocumentTimeline.idl
Source/WebCore/animation/DocumentTimelineOptions.h [new file with mode: 0644]
Source/WebCore/animation/DocumentTimelineOptions.idl [new file with mode: 0644]

index 6bd0bb7..9ec29e0 100644 (file)
@@ -1,5 +1,17 @@
 2018-07-09  Antoine Quint  <graouts@apple.com>
 
+        [Web Animations] Make WPT test at interfaces/DocumentTimeline/constructor.html pass reliably
+        https://bugs.webkit.org/show_bug.cgi?id=186498
+        <rdar://problem/41000205>
+
+        Reviewed by Dean Jackson.
+
+        Mark 4 new WPT progressions.
+
+        * web-platform-tests/web-animations/interfaces/DocumentTimeline/constructor-expected.txt:
+
+2018-07-09  Antoine Quint  <graouts@apple.com>
+
         [Web Animations] Support overlapping keyframes
         https://bugs.webkit.org/show_bug.cgi?id=187481
         <rdar://problem/41988674>
index 3109553..60ddb8e 100644 (file)
@@ -1,6 +1,6 @@
 
-FAIL An origin time of zero is used when none is supplied function is not a constructor (evaluating 'new DocumentTimeline()')
-FAIL A zero origin time produces a document timeline with a current time identical to the default document timeline function is not a constructor (evaluating 'new DocumentTimeline({ originTime: 0 })')
-FAIL A positive origin time makes the document timeline's current time lag behind the default document timeline function is not a constructor (evaluating 'new DocumentTimeline({ originTime: 10 * MS_PER_SEC })')
-FAIL A negative origin time makes the document timeline's current time run ahead of the default document timeline function is not a constructor (evaluating 'new DocumentTimeline({ originTime: -10 * MS_PER_SEC })')
+PASS An origin time of zero is used when none is supplied 
+PASS A zero origin time produces a document timeline with a current time identical to the default document timeline 
+PASS A positive origin time makes the document timeline's current time lag behind the default document timeline 
+PASS A negative origin time makes the document timeline's current time run ahead of the default document timeline 
 
index 7150680..f13bd94 100644 (file)
@@ -454,6 +454,7 @@ set(WebCore_NON_SVG_IDL_FILES
     animation/CompositeOperation.idl
     animation/ComputedTimingProperties.idl
     animation/DocumentTimeline.idl
+    animation/DocumentTimelineOptions.idl
     animation/FillMode.idl
     animation/IterationCompositeOperation.idl
     animation/KeyframeAnimationOptions.idl
index 59c775f..338b82b 100644 (file)
@@ -1,5 +1,30 @@
 2018-07-09  Antoine Quint  <graouts@apple.com>
 
+        [Web Animations] Make WPT test at interfaces/DocumentTimeline/constructor.html pass reliably
+        https://bugs.webkit.org/show_bug.cgi?id=186498
+        <rdar://problem/41000205>
+        
+        Reviewed by Dean Jackson.
+
+        Add a Constructor to the DocumentTimeline IDL to match the spec and ensure we respect the provided
+        origin time. To ensure all DocumentTimeline instances report matching current times, we read the
+        current time from the "main" document timeline, the one created by the Document automatically.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * animation/DocumentTimeline.cpp:
+        (WebCore::DocumentTimeline::create):
+        (WebCore::DocumentTimeline::DocumentTimeline):
+        (WebCore::DocumentTimeline::currentTime):
+        * animation/DocumentTimeline.h:
+        * animation/DocumentTimeline.idl:
+        * animation/DocumentTimelineOptions.h:
+        * animation/DocumentTimelineOptions.idl:
+
+2018-07-09  Antoine Quint  <graouts@apple.com>
+
         [Web Animations] Support overlapping keyframes
         https://bugs.webkit.org/show_bug.cgi?id=187481
         <rdar://problem/41988674>
index 3d3e93c..e379230 100644 (file)
@@ -374,6 +374,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/animation/CSSAnimation.idl \
     $(WebCore)/animation/CSSTransition.idl \
     $(WebCore)/animation/DocumentTimeline.idl \
+    $(WebCore)/animation/DocumentTimelineOptions.idl \
     $(WebCore)/animation/FillMode.idl \
     $(WebCore)/animation/IterationCompositeOperation.idl \
     $(WebCore)/animation/KeyframeAnimationOptions.idl \
index 3391e4b..2861393 100644 (file)
@@ -2496,6 +2496,7 @@ JSCSSTransition.cpp
 JSCustomElementRegistry.cpp
 JSCustomEvent.cpp
 JSDocumentTimeline.cpp
+JSDocumentTimelineOptions.cpp
 JSDOMApplicationCache.cpp
 JSDOMCSSNamespace.cpp
 JSDOMCache.cpp
index f7035bb..d90ea76 100644 (file)
                715AD7202050513200D592DC /* DeclarativeAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 715AD71D2050512400D592DC /* DeclarativeAnimation.h */; settings = {ATTRIBUTES = (Private, ); }; };
                715AD7212050513F00D592DC /* CSSTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 7123C186204739BA00789392 /* CSSTransition.h */; };
                716E55B020DBABF100F0CF29 /* DocumentAnimationScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 716E55AD20DBABDC00F0CF29 /* DocumentAnimationScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               71729F7B20F3BA4900801CE6 /* DocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7A20F3BA3A00801CE6 /* DocumentTimelineOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               71729F7E20F3BB4700801CE6 /* JSDocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7C20F3BAB900801CE6 /* JSDocumentTimelineOptions.h */; };
                71A1B6081DEE5AD70073BCFB /* modern-media-controls-localized-strings.js in Resources */ = {isa = PBXBuildFile; fileRef = 71A1B6061DEE5A820073BCFB /* modern-media-controls-localized-strings.js */; };
                71A57DF2154BE25C0009D120 /* SVGPathUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 71A57DF0154BE25C0009D120 /* SVGPathUtilities.h */; };
                71B28427203CEC4C0036AA5D /* JSCSSAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 71B28426203CEC0D0036AA5D /* JSCSSAnimation.h */; settings = {ATTRIBUTES = (Private, ); }; };
                716FA0FE1DB26591007323CC /* tracks-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "tracks-button.js"; sourceTree = "<group>"; };
                716FA0FF1DB26591007323CC /* volume-slider.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = "volume-slider.css"; sourceTree = "<group>"; };
                716FA1001DB26591007323CC /* volume-slider.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "volume-slider.js"; sourceTree = "<group>"; };
+               71729F7920F3BA3900801CE6 /* DocumentTimelineOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DocumentTimelineOptions.idl; sourceTree = "<group>"; };
+               71729F7A20F3BA3A00801CE6 /* DocumentTimelineOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentTimelineOptions.h; sourceTree = "<group>"; };
+               71729F7C20F3BAB900801CE6 /* JSDocumentTimelineOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDocumentTimelineOptions.h; sourceTree = "<group>"; };
+               71729F7D20F3BABA00801CE6 /* JSDocumentTimelineOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentTimelineOptions.cpp; sourceTree = "<group>"; };
                7177E2461DB80D2F00919A0B /* media-controller-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "media-controller-support.js"; sourceTree = "<group>"; };
                7177E2471DB80D2F00919A0B /* mute-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "mute-support.js"; sourceTree = "<group>"; };
                7177E2481DB80D2F00919A0B /* start-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "start-support.js"; sourceTree = "<group>"; };
                                7123C1842047399300789392 /* JSCSSTransition.h */,
                                71025EDB1F99F1A8004A250C /* JSDocumentTimeline.cpp */,
                                71025EDC1F99F1A8004A250C /* JSDocumentTimeline.h */,
+                               71729F7D20F3BABA00801CE6 /* JSDocumentTimelineOptions.cpp */,
+                               71729F7C20F3BAB900801CE6 /* JSDocumentTimelineOptions.h */,
                                712BE4841FE867C2002031CC /* JSFillMode.cpp */,
                                712BE4851FE86818002031CC /* JSFillMode.h */,
                                71247E281FEA5F61008C08CE /* JSIterationCompositeOperation.cpp */,
                                71025EC41F99F096004A250C /* DocumentTimeline.cpp */,
                                71025EC51F99F096004A250C /* DocumentTimeline.h */,
                                71025ECA1F99F096004A250C /* DocumentTimeline.idl */,
+                               71729F7A20F3BA3A00801CE6 /* DocumentTimelineOptions.h */,
+                               71729F7920F3BA3900801CE6 /* DocumentTimelineOptions.idl */,
                                712BE4811FE865D4002031CC /* FillMode.h */,
                                712BE4821FE865D5002031CC /* FillMode.idl */,
                                71247E331FEA5F80008C08CE /* IterationCompositeOperation.h */,
                                94E839511DFB2A0E007BC6A7 /* CSSNamespaceRule.h in Headers */,
                                A80E6D000A1989CA007FB8C5 /* CSSPageRule.h in Headers */,
                                946D372E1D6CB2940077084F /* CSSParser.h in Headers */,
+                               E4A7995220EE4B1400C19568 /* CSSParserContext.h in Headers */,
                                949C77011D6E1D9800C0DE4F /* CSSParserFastPaths.h in Headers */,
                                946D37441D6CF7B20077084F /* CSSParserIdioms.h in Headers */,
                                94DE5C961D8301BD00164F2A /* CSSParserImpl.h in Headers */,
                                AD6E71AD1668899D00320C13 /* DocumentSharedObjectPool.h in Headers */,
                                0B90561A0F2578BF0095FF6A /* DocumentThreadableLoader.h in Headers */,
                                71025ED01F99F0CE004A250C /* DocumentTimeline.h in Headers */,
+                               71729F7B20F3BA4900801CE6 /* DocumentTimelineOptions.h in Headers */,
                                86D982F7125C154000AD9E3D /* DocumentTiming.h in Headers */,
                                A8185F3909765766005826D9 /* DocumentType.h in Headers */,
                                973889A1116EA9DC00ADF313 /* DocumentWriter.h in Headers */,
                                ADDA94C219687AA500453029 /* JSDocumentCustom.h in Headers */,
                                1A494EDF0A123F4C00FDAFC1 /* JSDocumentFragment.h in Headers */,
                                71025EE01F99F1EC004A250C /* JSDocumentTimeline.h in Headers */,
+                               71729F7E20F3BB4700801CE6 /* JSDocumentTimelineOptions.h in Headers */,
                                65DF31F609D1CC60000BE325 /* JSDocumentType.h in Headers */,
                                7C57BFE71EDE2F6100534A48 /* JSDOMAbstractOperations.h in Headers */,
                                1AC2260D0DB69F190089B669 /* JSDOMApplicationCache.h in Headers */,
                                75793EC90D0CE72D007FC0AC /* JSMessageEvent.h in Headers */,
                                E1ADEDDA0E76BD93004A1A5E /* JSMessagePort.h in Headers */,
                                A86629D109DA2B48009633A5 /* JSMouseEvent.h in Headers */,
-                               E4A7995220EE4B1400C19568 /* CSSParserContext.h in Headers */,
                                830A36BD1DAC5FAD006D7D09 /* JSMouseEventInit.h in Headers */,
                                65DF31FC09D1CC60000BE325 /* JSMutationEvent.h in Headers */,
                                C6F0902D14327D4F00685849 /* JSMutationObserver.h in Headers */,
index 51976af..153064f 100644 (file)
@@ -42,12 +42,18 @@ namespace WebCore {
 
 Ref<DocumentTimeline> DocumentTimeline::create(Document& document)
 {
-    return adoptRef(*new DocumentTimeline(document));
+    return adoptRef(*new DocumentTimeline(document, 0_s));
 }
 
-DocumentTimeline::DocumentTimeline(Document& document)
+Ref<DocumentTimeline> DocumentTimeline::create(Document& document, DocumentTimelineOptions&& options)
+{
+    return adoptRef(*new DocumentTimeline(document, Seconds::fromMilliseconds(options.originTime)));
+}
+
+DocumentTimeline::DocumentTimeline(Document& document, Seconds originTime)
     : AnimationTimeline(DocumentTimelineClass)
     , m_document(&document)
+    , m_originTime(originTime)
     , m_animationScheduleTimer(*this, &DocumentTimeline::animationScheduleTimerFired)
 #if !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
     , m_animationResolutionTimer(*this, &DocumentTimeline::animationResolutionTimerFired)
@@ -134,6 +140,14 @@ std::optional<Seconds> DocumentTimeline::currentTime()
     if (m_paused || m_isSuspended || !m_document || !m_document->domWindow())
         return AnimationTimeline::currentTime();
 
+    if (auto* mainDocumentTimeline = m_document->existingTimeline()) {
+        if (mainDocumentTimeline != this) {
+            if (auto mainDocumentTimelineCurrentTime = mainDocumentTimeline->currentTime())
+                return mainDocumentTimelineCurrentTime.value() - m_originTime;
+            return std::nullopt;
+        }
+    }
+
 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
     // If we're in the middle of firing a frame, either due to a requestAnimationFrame callback
     // or scheduling an animation update, we want to ensure we use the same time we're using as
@@ -165,7 +179,7 @@ std::optional<Seconds> DocumentTimeline::currentTime()
             maybeClearCachedCurrentTime();
         });
     }
-    return m_cachedCurrentTime;
+    return m_cachedCurrentTime.value() - m_originTime;
 }
 
 void DocumentTimeline::pause()
index 940d786..58c9ae9 100644 (file)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "AnimationTimeline.h"
+#include "DocumentTimelineOptions.h"
 #include "GenericTaskQueue.h"
 #include "Timer.h"
 #include <wtf/Ref.h>
@@ -39,6 +40,7 @@ class DocumentTimeline final : public AnimationTimeline
 {
 public:
     static Ref<DocumentTimeline> create(Document&);
+    static Ref<DocumentTimeline> create(Document&, DocumentTimelineOptions&&);
     ~DocumentTimeline();
 
     Document* document() const { return m_document.get(); }
@@ -74,7 +76,7 @@ public:
     WEBCORE_EXPORT unsigned numberOfActiveAnimationsForTesting() const;
 
 private:
-    DocumentTimeline(Document&);
+    DocumentTimeline(Document&, Seconds);
 
     void scheduleInvalidationTaskIfNeeded();
     void performInvalidationTask();
@@ -86,6 +88,7 @@ private:
     void maybeClearCachedCurrentTime();
 
     RefPtr<Document> m_document;
+    Seconds m_originTime;
     bool m_paused { false };
     bool m_isSuspended { false };
     bool m_waitingOnVMIdle { false };
index 2faa242..678448b 100644 (file)
@@ -24,6 +24,9 @@
  */
 
 [
-    EnabledAtRuntime=WebAnimations
+    EnabledAtRuntime=WebAnimations,
+    Exposed=Window,
+    ConstructorCallWith=Document,
+    Constructor (optional DocumentTimelineOptions options)
 ] interface DocumentTimeline : AnimationTimeline {
 };
diff --git a/Source/WebCore/animation/DocumentTimelineOptions.h b/Source/WebCore/animation/DocumentTimelineOptions.h
new file mode 100644 (file)
index 0000000..217b8e7
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "DOMHighResTimeStamp.h"
+
+namespace WebCore {
+
+struct DocumentTimelineOptions {
+    DOMHighResTimeStamp originTime;
+};
+
+} // namespace WebCore
diff --git a/Source/WebCore/animation/DocumentTimelineOptions.idl b/Source/WebCore/animation/DocumentTimelineOptions.idl
new file mode 100644 (file)
index 0000000..7c5536d
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+typedef double DOMHighResTimeStamp;
+
+dictionary DocumentTimelineOptions {
+    DOMHighResTimeStamp originTime = 0;
+};