Title: [224939] trunk
Revision
224939
Author
commit-qu...@webkit.org
Date
2017-11-16 15:56:13 -0800 (Thu, 16 Nov 2017)

Log Message

[Web Animations] Express time in milliseconds through the API
https://bugs.webkit.org/show_bug.cgi?id=179799

Patch by Antoine Quint <grao...@apple.com> on 2017-11-16
Reviewed by Simon Fraser.

Source/WebCore:

While internally we use seconds to specify times and durations, the Web Animations API
uses milliseconds, so we have to convert times and durations from and to milliseconds.

* animation/AnimationEffectTiming.h:
* animation/AnimationTimeline.cpp:
(WebCore::AnimationTimeline::bindingsCurrentTime):
* animation/WebAnimation.cpp:
(WebCore::WebAnimation::bindingsStartTime const):
(WebCore::WebAnimation::setBindingsStartTime):
(WebCore::WebAnimation::bindingsCurrentTime const):
(WebCore::WebAnimation::setBindingsCurrentTime):
* testing/Internals.cpp:
(WebCore::Internals::setTimelineCurrentTime):

LayoutTests:

Update tests to use milliseconds rather than seconds.

* http/wpt/wk-web-animations/timing-model/animation-current-time.html:
* http/wpt/wk-web-animations/timing-model/animation-interface-start-time-property.html:
* http/wpt/wk-web-animations/timing-model/animation-playback-rate.html:
* http/wpt/wk-web-animations/timing-model/keyframe-effect-interface-timing-duration.html:
* http/wpt/wk-web-animations/timing-model/timeline-current-time.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (224938 => 224939)


--- trunk/LayoutTests/ChangeLog	2017-11-16 23:44:12 UTC (rev 224938)
+++ trunk/LayoutTests/ChangeLog	2017-11-16 23:56:13 UTC (rev 224939)
@@ -1,3 +1,18 @@
+2017-11-16  Antoine Quint  <grao...@apple.com>
+
+        [Web Animations] Express time in milliseconds through the API
+        https://bugs.webkit.org/show_bug.cgi?id=179799
+
+        Reviewed by Simon Fraser.
+
+        Update tests to use milliseconds rather than seconds.
+
+        * http/wpt/wk-web-animations/timing-model/animation-current-time.html:
+        * http/wpt/wk-web-animations/timing-model/animation-interface-start-time-property.html:
+        * http/wpt/wk-web-animations/timing-model/animation-playback-rate.html:
+        * http/wpt/wk-web-animations/timing-model/keyframe-effect-interface-timing-duration.html:
+        * http/wpt/wk-web-animations/timing-model/timeline-current-time.html:
+
 2017-11-16  Matt Lewis  <jlew...@apple.com>
 
         Marked multiple http/tests/cache/disk-cache/ tests as flaky.

Modified: trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/animation-current-time.html (224938 => 224939)


--- trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/animation-current-time.html	2017-11-16 23:44:12 UTC (rev 224938)
+++ trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/animation-current-time.html	2017-11-16 23:56:13 UTC (rev 224939)
@@ -17,23 +17,23 @@
 
 test(t => {
     const animation = new Animation;
-    animation.startTime = 2;
+    animation.startTime = 2000;
     internals.setTimelineCurrentTime(document.timeline, 0);
-    assert_equals(animation.currentTime, -2);
-    internals.setTimelineCurrentTime(document.timeline, 3);
-    assert_equals(animation.currentTime, 1);
-    animation.startTime = 1;
-    assert_equals(animation.currentTime, 2);
+    assert_equals(animation.currentTime, -2000);
+    internals.setTimelineCurrentTime(document.timeline, 3000);
+    assert_equals(animation.currentTime, 1000);
+    animation.startTime = 1000;
+    assert_equals(animation.currentTime, 2000);
 }, "An animation accounts for its start time and document current time when computing its current time.");
 
 test(t => {
     const animation = new Animation;
-    animation.startTime = 1;
-    internals.setTimelineCurrentTime(document.timeline, 3);
-    assert_equals(animation.currentTime, 2);
+    animation.startTime = 1000;
+    internals.setTimelineCurrentTime(document.timeline, 3000);
+    assert_equals(animation.currentTime, 2000);
 
-    animation.currentTime = 1;
-    assert_equals(animation.startTime, 2);
+    animation.currentTime = 1000;
+    assert_equals(animation.startTime, 2000);
 }, "Setting the current time should adjust the start time.");
 
 test(t => {

Modified: trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/animation-interface-start-time-property.html (224938 => 224939)


--- trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/animation-interface-start-time-property.html	2017-11-16 23:44:12 UTC (rev 224938)
+++ trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/animation-interface-start-time-property.html	2017-11-16 23:56:13 UTC (rev 224939)
@@ -17,14 +17,14 @@
 
 test(t => {
     const animation = new Animation;
-    animation.startTime = 2;
-    assert_equals(animation.startTime, 2);
+    animation.startTime = 2000;
+    assert_equals(animation.startTime, 2000);
 }, "The animation.startTime property can be set to a number.");
 
 test(t => {
     const animation = new Animation;
-    animation.startTime = 2;
-    assert_equals(animation.startTime, 2);
+    animation.startTime = 2000;
+    assert_equals(animation.startTime, 2000);
     animation.startTime = null;
     assert_equals(animation.startTime, null);
 }, "The animation.effect property can be set back to null.");

Modified: trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/animation-playback-rate.html (224938 => 224939)


--- trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/animation-playback-rate.html	2017-11-16 23:44:12 UTC (rev 224938)
+++ trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/animation-playback-rate.html	2017-11-16 23:56:13 UTC (rev 224939)
@@ -19,49 +19,49 @@
 
 test(t => {
   const animation = new Animation;
-  animation.startTime = 1;
+  animation.startTime = 1000;
   animation.playbackRate = 2;
-  internals.setTimelineCurrentTime(document.timeline, 3);
+  internals.setTimelineCurrentTime(document.timeline, 3000);
 
-  assert_equals(animation.startTime, 1);
-  assert_equals(animation.currentTime, 4);
+  assert_equals(animation.startTime, 1000);
+  assert_equals(animation.currentTime, 4000);
   assert_equals(animation.playbackRate, 2);
 }, 'Correctly compute the current time based on the playback rate');
 
 test(t => {
   const animation = new Animation;
-  animation.startTime = 2;
+  animation.startTime = 2000;
   animation.playbackRate = 2;
-  internals.setTimelineCurrentTime(document.timeline, 4);
+  internals.setTimelineCurrentTime(document.timeline, 4000);
 
-  animation.currentTime = 3;
+  animation.currentTime = 3000;
 
-  assert_equals(animation.startTime, 2.5);
-  assert_equals(animation.currentTime, 3);
+  assert_equals(animation.startTime, 2500);
+  assert_equals(animation.currentTime, 3000);
   assert_equals(animation.playbackRate, 2);
 }, 'Correctly compute the start time based on the playback rate when setting current time');
 
 test(t => {
   const animation = new Animation;
-  animation.startTime = 2;
+  animation.startTime = 2000;
   animation.playbackRate = 0.5;
-  internals.setTimelineCurrentTime(document.timeline, 4);
+  internals.setTimelineCurrentTime(document.timeline, 4000);
 
-  animation.currentTime = 1;
+  animation.currentTime = 1000;
 
-  assert_equals(animation.startTime, 2);
-  assert_equals(animation.currentTime, 1);
+  assert_equals(animation.startTime, 2000);
+  assert_equals(animation.currentTime, 1000);
   assert_equals(animation.playbackRate, 0.5);
 }, 'Correctly compute the start time based on a playback rate < 1 when setting current time');
 
 test(t => {
   const animation = new Animation;
-  animation.currentTime = 1;
+  animation.currentTime = 1000;
   animation.playbackRate = -1;
-  internals.setTimelineCurrentTime(document.timeline, 4);
+  internals.setTimelineCurrentTime(document.timeline, 4000);
 
-  assert_equals(animation.startTime, 5);
-  assert_equals(animation.currentTime, 1);
+  assert_equals(animation.startTime, 5000);
+  assert_equals(animation.currentTime, 1000);
   assert_equals(animation.playbackRate, -1);
 }, 'Correctly compute the start time based on a playback rate < 0');
 
@@ -69,7 +69,7 @@
   const animation = new Animation;
   animation.playbackRate = 0;
   animation.startTime = 0;
-  internals.setTimelineCurrentTime(document.timeline, 1);
+  internals.setTimelineCurrentTime(document.timeline, 1000);
 
   assert_equals(animation.startTime, 0);
   assert_equals(animation.currentTime, 0);

Modified: trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/keyframe-effect-interface-timing-duration.html (224938 => 224939)


--- trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/keyframe-effect-interface-timing-duration.html	2017-11-16 23:44:12 UTC (rev 224938)
+++ trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/keyframe-effect-interface-timing-duration.html	2017-11-16 23:56:13 UTC (rev 224939)
@@ -19,8 +19,8 @@
 
 test(t => {
     const keyframeEffect = new KeyframeEffect(document.body, null);
-    keyframeEffect.timing.duration = 2;
-    assert_equals(keyframeEffect.timing.duration, 2);
+    keyframeEffect.timing.duration = 2000;
+    assert_equals(keyframeEffect.timing.duration, 2000);
 }, "Check that we can update the timing duration.");
 
 </script>

Modified: trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/timeline-current-time.html (224938 => 224939)


--- trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/timeline-current-time.html	2017-11-16 23:44:12 UTC (rev 224938)
+++ trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/timeline-current-time.html	2017-11-16 23:56:13 UTC (rev 224939)
@@ -15,13 +15,13 @@
 }, 'The document timeline currentTime is null by default.');
 
 test(t => {
-    internals.setTimelineCurrentTime(document.timeline, 1);
-    assert_equals(document.timeline.currentTime, 1);
+    internals.setTimelineCurrentTime(document.timeline, 1000);
+    assert_equals(document.timeline.currentTime, 1000);
 }, 'Using internals.setTimelineCurrentTime() can set the document timeline currentTime.');
 
 test(t => {
-    internals.setTimelineCurrentTime(document.timeline, -1);
-    assert_equals(document.timeline.currentTime, -1);
+    internals.setTimelineCurrentTime(document.timeline, -1000);
+    assert_equals(document.timeline.currentTime, -1000);
 }, 'Using internals.setTimelineCurrentTime() can set the document timeline currentTime to a negative value.');
 
 </script>

Modified: trunk/Source/WebCore/ChangeLog (224938 => 224939)


--- trunk/Source/WebCore/ChangeLog	2017-11-16 23:44:12 UTC (rev 224938)
+++ trunk/Source/WebCore/ChangeLog	2017-11-16 23:56:13 UTC (rev 224939)
@@ -1,3 +1,24 @@
+2017-11-16  Antoine Quint  <grao...@apple.com>
+
+        [Web Animations] Express time in milliseconds through the API
+        https://bugs.webkit.org/show_bug.cgi?id=179799
+
+        Reviewed by Simon Fraser.
+
+        While internally we use seconds to specify times and durations, the Web Animations API
+        uses milliseconds, so we have to convert times and durations from and to milliseconds.
+
+        * animation/AnimationEffectTiming.h:
+        * animation/AnimationTimeline.cpp:
+        (WebCore::AnimationTimeline::bindingsCurrentTime):
+        * animation/WebAnimation.cpp:
+        (WebCore::WebAnimation::bindingsStartTime const):
+        (WebCore::WebAnimation::setBindingsStartTime):
+        (WebCore::WebAnimation::bindingsCurrentTime const):
+        (WebCore::WebAnimation::setBindingsCurrentTime):
+        * testing/Internals.cpp:
+        (WebCore::Internals::setTimelineCurrentTime):
+
 2017-11-16  Michael Catanzaro  <mcatanz...@igalia.com>
 
         REGRESSION(r224887): GCC 5 build broken

Modified: trunk/Source/WebCore/animation/AnimationEffectTiming.h (224938 => 224939)


--- trunk/Source/WebCore/animation/AnimationEffectTiming.h	2017-11-16 23:44:12 UTC (rev 224938)
+++ trunk/Source/WebCore/animation/AnimationEffectTiming.h	2017-11-16 23:56:13 UTC (rev 224939)
@@ -38,8 +38,8 @@
     static Ref<AnimationEffectTiming> create();
     ~AnimationEffectTiming();
 
-    double bindingsDuration() const { return m_duration.value(); }
-    void setBindingsDuration(double duration) { m_duration = Seconds(duration); }
+    double bindingsDuration() const { return m_duration.milliseconds(); }
+    void setBindingsDuration(double duration) { m_duration = Seconds::fromMilliseconds(duration); }
     Seconds duration() const { return m_duration; }
     void setDuration(Seconds& duration) { m_duration = duration; }
 

Modified: trunk/Source/WebCore/animation/AnimationTimeline.cpp (224938 => 224939)


--- trunk/Source/WebCore/animation/AnimationTimeline.cpp	2017-11-16 23:44:12 UTC (rev 224938)
+++ trunk/Source/WebCore/animation/AnimationTimeline.cpp	2017-11-16 23:56:13 UTC (rev 224939)
@@ -59,7 +59,7 @@
     auto time = currentTime();
     if (!time)
         return std::nullopt;
-    return time->value();
+    return time->milliseconds();
 }
 
 void AnimationTimeline::setCurrentTime(Seconds currentTime)

Modified: trunk/Source/WebCore/animation/WebAnimation.cpp (224938 => 224939)


--- trunk/Source/WebCore/animation/WebAnimation.cpp	2017-11-16 23:44:12 UTC (rev 224938)
+++ trunk/Source/WebCore/animation/WebAnimation.cpp	2017-11-16 23:56:13 UTC (rev 224939)
@@ -123,7 +123,7 @@
 std::optional<double> WebAnimation::bindingsStartTime() const
 {
     if (m_startTime)
-        return m_startTime->value();
+        return m_startTime->milliseconds();
     return std::nullopt;
 }
 
@@ -132,7 +132,7 @@
     if (startTime == std::nullopt)
         setStartTime(std::nullopt);
     else
-        setStartTime(Seconds(startTime.value()));
+        setStartTime(Seconds::fromMilliseconds(startTime.value()));
 }
 
 std::optional<Seconds> WebAnimation::startTime() const
@@ -156,7 +156,7 @@
     auto time = currentTime();
     if (!time)
         return std::nullopt;
-    return time->value();
+    return time->milliseconds();
 }
 
 ExceptionOr<void> WebAnimation::setBindingsCurrentTime(std::optional<double> currentTime)
@@ -163,7 +163,7 @@
 {
     if (!currentTime)
         return Exception { TypeError };
-    setCurrentTime(Seconds(currentTime.value()));
+    setCurrentTime(Seconds::fromMilliseconds(currentTime.value()));
     return { };
 }
 

Modified: trunk/Source/WebCore/testing/Internals.cpp (224938 => 224939)


--- trunk/Source/WebCore/testing/Internals.cpp	2017-11-16 23:44:12 UTC (rev 224938)
+++ trunk/Source/WebCore/testing/Internals.cpp	2017-11-16 23:56:13 UTC (rev 224939)
@@ -4285,7 +4285,7 @@
 
 void Internals::setTimelineCurrentTime(AnimationTimeline& timeline, double currentTime)
 {
-    timeline.setCurrentTime(Seconds(currentTime));
+    timeline.setCurrentTime(Seconds::fromMilliseconds(currentTime));
 }
 
 #if ENABLE(APPLE_PAY)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to