Title: [224128] trunk
Revision
224128
Author
[email protected]
Date
2017-10-27 13:29:59 -0700 (Fri, 27 Oct 2017)

Log Message

[Web Animations] Expose the currentTime property on AnimationTimeline
https://bugs.webkit.org/show_bug.cgi?id=178928

Reviewed by Dean Jackson.

Source/WebCore:

We add the currentTime property on AnimationTimeline and add an internals method
to set it in a test which will allow us to validate the timing model state for
a given time.

Test: webanimations/timeline-current-time.html

* animation/AnimationTimeline.cpp:
(WebCore::AnimationTimeline::bindingsCurrentTime const):
(WebCore::AnimationTimeline::setCurrentTime):
* animation/AnimationTimeline.h:
(WebCore::AnimationTimeline::currentTime const):
* animation/AnimationTimeline.idl:
* testing/Internals.cpp:
(WebCore::Internals::setTimelineCurrentTime):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Add a new test that checks we can read the document's timeline currentTime
property and set it via the internals method.

* webanimations/timeline-current-time-expected.txt: Added.
* webanimations/timeline-current-time.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (224127 => 224128)


--- trunk/LayoutTests/ChangeLog	2017-10-27 20:17:53 UTC (rev 224127)
+++ trunk/LayoutTests/ChangeLog	2017-10-27 20:29:59 UTC (rev 224128)
@@ -1,3 +1,16 @@
+2017-10-27  Antoine Quint  <[email protected]>
+
+        [Web Animations] Expose the currentTime property on AnimationTimeline
+        https://bugs.webkit.org/show_bug.cgi?id=178928
+
+        Reviewed by Dean Jackson.
+
+        Add a new test that checks we can read the document's timeline currentTime
+        property and set it via the internals method.
+
+        * webanimations/timeline-current-time-expected.txt: Added.
+        * webanimations/timeline-current-time.html: Added.
+
 2017-10-27  Ryan Haddad  <[email protected]>
 
         Skip two tests that are flaky crashes.

Added: trunk/LayoutTests/webanimations/timeline-current-time-expected.txt (0 => 224128)


--- trunk/LayoutTests/webanimations/timeline-current-time-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webanimations/timeline-current-time-expected.txt	2017-10-27 20:29:59 UTC (rev 224128)
@@ -0,0 +1,18 @@
+Check that the AnimationTimeline currentTime property is defined and can be set via internals.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+The document timeline currentTime is null by default.
+PASS document.timeline.currentTime is null
+
+Using internals.setTimelineCurrentTime() can set the document timeline currentTime.
+PASS document.timeline.currentTime is 1
+
+Using internals.setTimelineCurrentTime() can set the document timeline currentTime to a negative value.
+PASS document.timeline.currentTime is -1
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/webanimations/timeline-current-time.html (0 => 224128)


--- trunk/LayoutTests/webanimations/timeline-current-time.html	                        (rev 0)
+++ trunk/LayoutTests/webanimations/timeline-current-time.html	2017-10-27 20:29:59 UTC (rev 224128)
@@ -0,0 +1,22 @@
+<script src=""
+<script>
+
+description("Check that the AnimationTimeline currentTime property is defined and can be set via internals.");
+
+debug("The document timeline currentTime is null by default.");
+shouldBeNull("document.timeline.currentTime");
+
+debug("");
+debug("Using internals.setTimelineCurrentTime() can set the document timeline currentTime.");
+internals.setTimelineCurrentTime(document.timeline, 1);
+shouldBe("document.timeline.currentTime", "1");
+
+debug("");
+debug("Using internals.setTimelineCurrentTime() can set the document timeline currentTime to a negative value.");
+internals.setTimelineCurrentTime(document.timeline, -1);
+shouldBe("document.timeline.currentTime", "-1");
+
+debug("");
+
+</script>
+<script src=""
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (224127 => 224128)


--- trunk/Source/WebCore/ChangeLog	2017-10-27 20:17:53 UTC (rev 224127)
+++ trunk/Source/WebCore/ChangeLog	2017-10-27 20:29:59 UTC (rev 224128)
@@ -1,5 +1,29 @@
 2017-10-27  Antoine Quint  <[email protected]>
 
+        [Web Animations] Expose the currentTime property on AnimationTimeline
+        https://bugs.webkit.org/show_bug.cgi?id=178928
+
+        Reviewed by Dean Jackson.
+
+        We add the currentTime property on AnimationTimeline and add an internals method
+        to set it in a test which will allow us to validate the timing model state for
+        a given time.
+
+        Test: webanimations/timeline-current-time.html
+
+        * animation/AnimationTimeline.cpp:
+        (WebCore::AnimationTimeline::bindingsCurrentTime const):
+        (WebCore::AnimationTimeline::setCurrentTime):
+        * animation/AnimationTimeline.h:
+        (WebCore::AnimationTimeline::currentTime const):
+        * animation/AnimationTimeline.idl:
+        * testing/Internals.cpp:
+        (WebCore::Internals::setTimelineCurrentTime):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
+2017-10-27  Antoine Quint  <[email protected]>
+
         [Web Animations] Use Seconds vs. MonotonicTime to represent times
         https://bugs.webkit.org/show_bug.cgi?id=178950
 

Modified: trunk/Source/WebCore/animation/AnimationTimeline.cpp (224127 => 224128)


--- trunk/Source/WebCore/animation/AnimationTimeline.cpp	2017-10-27 20:17:53 UTC (rev 224127)
+++ trunk/Source/WebCore/animation/AnimationTimeline.cpp	2017-10-27 20:29:59 UTC (rev 224128)
@@ -52,6 +52,18 @@
     m_animations.remove(WTFMove(animation));
 }
 
+std::optional<double> AnimationTimeline::bindingsCurrentTime() const
+{
+    if (!m_currentTime)
+        return std::nullopt;
+    return m_currentTime->value();
+}
+
+void AnimationTimeline::setCurrentTime(Seconds currentTime)
+{
+    m_currentTime = currentTime;
+}
+
 String AnimationTimeline::description()
 {
     TextStream stream;

Modified: trunk/Source/WebCore/animation/AnimationTimeline.h (224127 => 224128)


--- trunk/Source/WebCore/animation/AnimationTimeline.h	2017-10-27 20:17:53 UTC (rev 224127)
+++ trunk/Source/WebCore/animation/AnimationTimeline.h	2017-10-27 20:29:59 UTC (rev 224128)
@@ -29,8 +29,10 @@
 #include "WebAnimation.h"
 #include <wtf/Forward.h>
 #include <wtf/HashSet.h>
+#include <wtf/Optional.h>
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
+#include <wtf/Seconds.h>
 
 namespace WebCore {
 
@@ -41,6 +43,9 @@
     bool isDocumentTimeline() const { return m_classType == DocumentTimelineClass; }
     void addAnimation(Ref<WebAnimation>&&);
     void removeAnimation(Ref<WebAnimation>&&);
+    std::optional<double> bindingsCurrentTime() const;
+    std::optional<Seconds> currentTime() const { return m_currentTime; }
+    WEBCORE_EXPORT void setCurrentTime(Seconds);
     WEBCORE_EXPORT String description();
 
     virtual ~AnimationTimeline();
@@ -56,6 +61,7 @@
 
 private:
     ClassType m_classType;
+    std::optional<Seconds> m_currentTime;
     HashSet<RefPtr<WebAnimation>> m_animations;
 };
 

Modified: trunk/Source/WebCore/animation/AnimationTimeline.idl (224127 => 224128)


--- trunk/Source/WebCore/animation/AnimationTimeline.idl	2017-10-27 20:17:53 UTC (rev 224127)
+++ trunk/Source/WebCore/animation/AnimationTimeline.idl	2017-10-27 20:29:59 UTC (rev 224128)
@@ -28,4 +28,5 @@
     ExportMacro=WEBCORE_EXPORT,
     CustomToJSObject
 ] interface AnimationTimeline {
+    [ImplementedAs=bindingsCurrentTime] readonly attribute double? currentTime;
 };

Modified: trunk/Source/WebCore/testing/Internals.cpp (224127 => 224128)


--- trunk/Source/WebCore/testing/Internals.cpp	2017-10-27 20:17:53 UTC (rev 224127)
+++ trunk/Source/WebCore/testing/Internals.cpp	2017-10-27 20:29:59 UTC (rev 224128)
@@ -4261,6 +4261,11 @@
     return timeline.description();
 }
 
+void Internals::setTimelineCurrentTime(AnimationTimeline& timeline, double currentTime)
+{
+    timeline.setCurrentTime(Seconds(currentTime));
+}
+
 #if ENABLE(APPLE_PAY)
 MockPaymentCoordinator& Internals::mockPaymentCoordinator() const
 {

Modified: trunk/Source/WebCore/testing/Internals.h (224127 => 224128)


--- trunk/Source/WebCore/testing/Internals.h	2017-10-27 20:17:53 UTC (rev 224127)
+++ trunk/Source/WebCore/testing/Internals.h	2017-10-27 20:29:59 UTC (rev 224128)
@@ -625,6 +625,7 @@
 #endif
 
     String timelineDescription(AnimationTimeline&);
+    void setTimelineCurrentTime(AnimationTimeline&, double);
 
 private:
     explicit Internals(Document&);

Modified: trunk/Source/WebCore/testing/Internals.idl (224127 => 224128)


--- trunk/Source/WebCore/testing/Internals.idl	2017-10-27 20:17:53 UTC (rev 224127)
+++ trunk/Source/WebCore/testing/Internals.idl	2017-10-27 20:29:59 UTC (rev 224128)
@@ -563,5 +563,6 @@
     boolean hasServiceWorkerRegisteredForOrigin(DOMString origin);
 
     [EnabledAtRuntime=WebAnimations] DOMString timelineDescription(AnimationTimeline timeline);
+    [EnabledAtRuntime=WebAnimations] void setTimelineCurrentTime(AnimationTimeline timeline, double currentTime);
     [Conditional=APPLE_PAY] readonly attribute MockPaymentCoordinator mockPaymentCoordinator;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to