Title: [229040] trunk
Revision
229040
Author
[email protected]
Date
2018-02-26 13:15:09 -0800 (Mon, 26 Feb 2018)

Log Message

[Web Animations] Implement the procedure to set the start time
https://bugs.webkit.org/show_bug.cgi?id=183137

Reviewed by Dean Jackson.

LayoutTests/imported/w3c:

Update test expectations with progressions.

* web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt:

Source/WebCore:

Implement the procedure to set the start time as setBindingsStartTime() and use the setStartTime() method as
an internal method to set the m_startTime instance variable and invalidate the timing model rather than run
the entire procedure which should only be called when setting the "startTime" property through the JS API.

* animation/WebAnimation.cpp:
(WebCore::WebAnimation::setTimeline):
(WebCore::WebAnimation::setBindingsStartTime):
(WebCore::WebAnimation::setStartTime):
(WebCore::WebAnimation::silentlySetCurrentTime):
(WebCore::WebAnimation::finish):
(WebCore::WebAnimation::updateFinishedState):
(WebCore::WebAnimation::runPendingPlayTask):
(WebCore::WebAnimation::runPendingPauseTask):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (229039 => 229040)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2018-02-26 21:02:18 UTC (rev 229039)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2018-02-26 21:15:09 UTC (rev 229040)
@@ -1,5 +1,16 @@
 2018-02-26  Antoine Quint  <[email protected]>
 
+        [Web Animations] Implement the procedure to set the start time
+        https://bugs.webkit.org/show_bug.cgi?id=183137
+
+        Reviewed by Dean Jackson.
+
+        Update test expectations with progressions.
+
+        * web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt:
+
+2018-02-26  Antoine Quint  <[email protected]>
+
         [Web Animations] Ensure setting the hold time invalidates the timing model
         https://bugs.webkit.org/show_bug.cgi?id=183136
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt (229039 => 229040)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt	2018-02-26 21:02:18 UTC (rev 229039)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt	2018-02-26 21:15:09 UTC (rev 229040)
@@ -1,8 +1,8 @@
 
-FAIL Setting the start time of an animation without an active timeline assert_equals: Setting the start time clears the current time expected (object) null but got (number) 1000
+PASS Setting the start time of an animation without an active timeline 
 PASS Setting an unresolved start time an animation without an active timeline does not clear the current time 
-FAIL Setting the start time clears the hold time assert_approx_equals: The current time is calculated from the start time, not the hold time expected 2000 +/- 0.0005 but got 1000
-FAIL Setting an unresolved start time sets the hold time assert_approx_equals: Hold time is set after start time is made unresolved expected a number but got a "object"
+PASS Setting the start time clears the hold time 
+PASS Setting an unresolved start time sets the hold time 
 FAIL Setting the start time resolves a pending ready promise assert_true: Animation is in play-pending state expected true got false
 FAIL Setting the start time resolves a pending pause task assert_true: Animation is in pause-pending state expected true got false
 PASS Setting the start time updates the finished state 

Modified: trunk/Source/WebCore/ChangeLog (229039 => 229040)


--- trunk/Source/WebCore/ChangeLog	2018-02-26 21:02:18 UTC (rev 229039)
+++ trunk/Source/WebCore/ChangeLog	2018-02-26 21:15:09 UTC (rev 229040)
@@ -1,3 +1,24 @@
+2018-02-26  Antoine Quint  <[email protected]>
+
+        [Web Animations] Implement the procedure to set the start time
+        https://bugs.webkit.org/show_bug.cgi?id=183137
+
+        Reviewed by Dean Jackson.
+
+        Implement the procedure to set the start time as setBindingsStartTime() and use the setStartTime() method as
+        an internal method to set the m_startTime instance variable and invalidate the timing model rather than run
+        the entire procedure which should only be called when setting the "startTime" property through the JS API.
+
+        * animation/WebAnimation.cpp:
+        (WebCore::WebAnimation::setTimeline):
+        (WebCore::WebAnimation::setBindingsStartTime):
+        (WebCore::WebAnimation::setStartTime):
+        (WebCore::WebAnimation::silentlySetCurrentTime):
+        (WebCore::WebAnimation::finish):
+        (WebCore::WebAnimation::updateFinishedState):
+        (WebCore::WebAnimation::runPendingPlayTask):
+        (WebCore::WebAnimation::runPendingPauseTask):
+
 2018-02-26  Christopher Reid  <[email protected]>
 
         [Curl] Cookies are not being added to the Cookie field in Request Headers

Modified: trunk/Source/WebCore/animation/WebAnimation.cpp (229039 => 229040)


--- trunk/Source/WebCore/animation/WebAnimation.cpp	2018-02-26 21:02:18 UTC (rev 229039)
+++ trunk/Source/WebCore/animation/WebAnimation.cpp	2018-02-26 21:15:09 UTC (rev 229040)
@@ -133,7 +133,7 @@
         return;
 
     // 4. If the animation start time of animation is resolved, make animation’s hold time unresolved.
-    if (startTime())
+    if (m_startTime)
         setHoldTime(std::nullopt);
 
     if (m_timeline)
@@ -192,10 +192,53 @@
 
 void WebAnimation::setBindingsStartTime(std::optional<double> startTime)
 {
+    // 3.4.6 The procedure to set the start time of animation, animation, to new start time, is as follows:
+    // https://drafts.csswg.org/web-animations/#setting-the-start-time-of-an-animation
+
+    std::optional<Seconds> newStartTime;
     if (!startTime)
-        setStartTime(std::nullopt);
+        newStartTime = std::nullopt;
     else
-        setStartTime(Seconds::fromMilliseconds(startTime.value()));
+        newStartTime = Seconds::fromMilliseconds(startTime.value());
+
+    // 1. Let timeline time be the current time value of the timeline that animation is associated with. If
+    //    there is no timeline associated with animation or the associated timeline is inactive, let the timeline
+    //    time be unresolved.
+    auto timelineTime = m_timeline ? m_timeline->currentTime() : std::nullopt;
+
+    // 2. If timeline time is unresolved and new start time is resolved, make animation's hold time unresolved.
+    if (!timelineTime && newStartTime)
+        setHoldTime(std::nullopt);
+
+    // 3. Let previous current time be animation's current time.
+    auto previousCurrentTime = currentTime();
+
+    // 4. Set animation's start time to new start time.
+    setStartTime(newStartTime);
+
+    // 5. Update animation's hold time based on the first matching condition from the following,
+    if (newStartTime) {
+        // If new start time is resolved,
+        // If animation’s playback rate is not zero, make animation’s hold time unresolved.
+        if (m_playbackRate)
+            setHoldTime(std::nullopt);
+    } else {
+        // Otherwise (new start time is unresolved),
+        // Set animation's hold time to previous current time even if previous current time is unresolved.
+        setHoldTime(previousCurrentTime);
+    }
+
+    // 6. If animation has a pending play task or a pending pause task, cancel that task and resolve animation's current ready promise with animation.
+    if (pending()) {
+        setTimeToRunPendingPauseTask(TimeToRunPendingTask::NotScheduled);
+        setTimeToRunPendingPlayTask(TimeToRunPendingTask::NotScheduled);
+        m_readyPromise.resolve(*this);
+    }
+
+    // 7. Run the procedure to update an animation’s finished state for animation with the did seek flag set to true, and the synchronously notify flag set to false.
+    updateFinishedState(DidSeek::Yes, SynchronouslyNotify::No);
+
+    timingModelDidChange();
 }
 
 std::optional<Seconds> WebAnimation::startTime() const
@@ -203,12 +246,12 @@
     return m_startTime;
 }
 
-void WebAnimation::setStartTime(std::optional<Seconds> startTime)
+void WebAnimation::setStartTime(std::optional<Seconds> newStartTime)
 {
-    if (startTime == m_startTime)
+    if (m_startTime == newStartTime)
         return;
 
-    m_startTime = startTime;
+    m_startTime = newStartTime;
     timingModelDidChange();
 }
 
@@ -278,7 +321,7 @@
     // Set animation's hold time to seek time.
     // Otherwise, set animation's start time to the result of evaluating timeline time - (seek time / playback rate)
     // where timeline time is the current time value of timeline associated with animation.
-    if (m_holdTime || !startTime() || !m_timeline || !m_timeline->currentTime() || !m_playbackRate)
+    if (m_holdTime || !m_startTime || !m_timeline || !m_timeline->currentTime() || !m_playbackRate)
         setHoldTime(seekTime);
     else
         setStartTime(m_timeline->currentTime().value() - (seekTime.value() / m_playbackRate));
@@ -492,11 +535,11 @@
 
     // 4. If animation's start time is unresolved and animation has an associated active timeline, let the start time be the result of
     //    evaluating timeline time - (limit / playback rate) where timeline time is the current time value of the associated timeline.
-    if (!startTime() && m_timeline && m_timeline->currentTime())
+    if (!m_startTime && m_timeline && m_timeline->currentTime())
         setStartTime(m_timeline->currentTime().value() - (limit / m_playbackRate));
 
     // 5. If there is a pending pause task and start time is resolved,
-    if (hasPendingPauseTask() && startTime()) {
+    if (hasPendingPauseTask() && m_startTime) {
         // 1. Let the hold time be unresolved.
         setHoldTime(std::nullopt);
         // 2. Cancel the pending pause task.
@@ -506,7 +549,7 @@
     }
 
     // 6. If there is a pending play task and start time is resolved, cancel that task and resolve the current ready promise of animation with animation.
-    if (hasPendingPlayTask() && startTime()) {
+    if (hasPendingPlayTask() && m_startTime) {
         setTimeToRunPendingPlayTask(TimeToRunPendingTask::NotScheduled);
         m_readyPromise.resolve(*this);
     }
@@ -531,7 +574,7 @@
     //    - the unconstrained current time is resolved, and
     //    - animation's start time is resolved, and
     //    - animation does not have a pending play task or a pending pause task,
-    if (unconstrainedCurrentTime && startTime() && !pending()) {
+    if (unconstrainedCurrentTime && m_startTime && !pending()) {
         // then update animation's hold time based on the first matching condition for animation from below, if any:
         if (m_playbackRate > 0 && unconstrainedCurrentTime >= endTime) {
             // If animation playback rate > 0 and unconstrained current time is greater than or equal to target effect end,
@@ -724,7 +767,7 @@
     auto readyTime = m_timeline->currentTime();
 
     // 2. If animation's start time is unresolved, perform the following steps:
-    if (!startTime()) {
+    if (!m_startTime) {
         // 1. Let new start time be the result of evaluating ready time - hold time / animation playback rate for animation.
         // If the animation playback rate is zero, let new start time be simply ready time.
         auto newStartTime = readyTime.value();
@@ -844,7 +887,7 @@
     // 1. Let ready time be the time value of the timeline associated with animation at the moment when the user agent
     //    completed processing necessary to suspend playback of animation's target effect.
     auto readyTime = m_timeline->currentTime();
-    auto animationStartTime = startTime();
+    auto animationStartTime = m_startTime;
 
     // 2. If animation's start time is resolved and its hold time is not resolved, let animation's hold time be the result of
     //    evaluating (ready time - start time) × playback rate.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to