Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (227622 => 227623)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2018-01-25 20:21:47 UTC (rev 227622)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2018-01-25 20:23:43 UTC (rev 227623)
@@ -1,5 +1,18 @@
2018-01-25 Antoine Quint <[email protected]>
+ [Web Animations] Expose the reverse() method
+ https://bugs.webkit.org/show_bug.cgi?id=182100
+ <rdar://problem/36867117>
+
+ Reviewed by Dean Jackson.
+
+ Update WPT test output with progressions.
+
+ * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt:
+ * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt:
+
+2018-01-25 Antoine Quint <[email protected]>
+
[Web Animations] Account for provided easings when computing progress and resolving keyframe effect values
https://bugs.webkit.org/show_bug.cgi?id=182098
<rdar://problem/36866149>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt (227622 => 227623)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt 2018-01-25 20:21:47 UTC (rev 227622)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt 2018-01-25 20:23:43 UTC (rev 227623)
@@ -20,7 +20,7 @@
PASS Animation interface: operation finish()
PASS Animation interface: operation play()
PASS Animation interface: operation pause()
-FAIL Animation interface: operation reverse() assert_own_property: interface prototype object missing non-static operation expected property "reverse" missing
+PASS Animation interface: operation reverse()
PASS Animation must be primary interface of new Animation()
PASS Stringification of new Animation()
PASS Animation interface: new Animation() must inherit property "id" with the proper type
@@ -39,5 +39,5 @@
PASS Animation interface: new Animation() must inherit property "finish()" with the proper type
PASS Animation interface: new Animation() must inherit property "play()" with the proper type
PASS Animation interface: new Animation() must inherit property "pause()" with the proper type
-FAIL Animation interface: new Animation() must inherit property "reverse()" with the proper type assert_inherits: property "reverse" not found in prototype chain
+PASS Animation interface: new Animation() must inherit property "reverse()" with the proper type
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt (227622 => 227623)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt 2018-01-25 20:21:47 UTC (rev 227622)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt 2018-01-25 20:23:43 UTC (rev 227623)
@@ -1,17 +1,17 @@
-FAIL Reversing an animation inverts the playback rate promise_test: Unhandled rejection with value: object "TypeError: animation.reverse is not a function. (In 'animation.reverse()', 'animation.reverse' is undefined)"
-FAIL Reversing an animation plays a pausing animation promise_test: Unhandled rejection with value: object "TypeError: animation.reverse is not a function. (In 'animation.reverse()', 'animation.reverse' is undefined)"
-FAIL Reversing an animation maintains the same current time animation.reverse is not a function. (In 'animation.reverse()', 'animation.reverse' is undefined)
+PASS Reversing an animation inverts the playback rate
+PASS Reversing an animation plays a pausing animation
+PASS Reversing an animation maintains the same current time
FAIL Reversing an animation does not cause it to leave the pending state assert_true: The animation is pending before we call reverse expected true got false
-FAIL Reversing an animation does not cause it to resolve the ready promise animation.reverse is not a function. (In 'animation.reverse()', 'animation.reverse' is undefined)
-FAIL Reversing an animation when playbackRate > 0 and currentTime > effect end should make it play from the end animation.reverse is not a function. (In 'animation.reverse()', 'animation.reverse' is undefined)
-FAIL Reversing an animation when playbackRate > 0 and currentTime < 0 should make it play from the end animation.reverse is not a function. (In 'animation.reverse()', 'animation.reverse' is undefined)
-FAIL Reversing an animation when playbackRate < 0 and currentTime < 0 should make it play from the start animation.reverse is not a function. (In 'animation.reverse()', 'animation.reverse' is undefined)
-FAIL Reversing an animation when playbackRate < 0 and currentTime > effect end should make it play from the start animation.reverse is not a function. (In 'animation.reverse()', 'animation.reverse' is undefined)
-FAIL Reversing an animation when playbackRate > 0 and currentTime < 0 and the target effect end is positive infinity should throw an exception assert_throws: reverse() should throw InvalidStateError if the playbackRate > 0 and the currentTime < 0 and the target effect is positive infinity function "() => { animation.reverse(); }" threw object "TypeError: animation.reverse is not a function. (In 'animation.reverse()', 'animation.reverse' is undefined)" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
+PASS Reversing an animation does not cause it to resolve the ready promise
+PASS Reversing an animation when playbackRate > 0 and currentTime > effect end should make it play from the end
+PASS Reversing an animation when playbackRate > 0 and currentTime < 0 should make it play from the end
+PASS Reversing an animation when playbackRate < 0 and currentTime < 0 should make it play from the start
+PASS Reversing an animation when playbackRate < 0 and currentTime > effect end should make it play from the start
+PASS Reversing an animation when playbackRate > 0 and currentTime < 0 and the target effect end is positive infinity should throw an exception
PASS When reversing throws an exception, the playback rate remains unchanged
-FAIL Reversing animation when playbackRate = 0 and currentTime < 0 and the target effect end is positive infinity should NOT throw an exception assert_unreached: Unexpected exception when calling reverse(): TypeError: animation.reverse is not a function. (In 'animation.reverse()', 'animation.reverse' is undefined) Reached unreachable code
-FAIL Reversing an animation when playbackRate < 0 and currentTime < 0 and the target effect end is positive infinity should make it play from the start animation.reverse is not a function. (In 'animation.reverse()', 'animation.reverse' is undefined)
-FAIL Reversing when when playbackRate == 0 should preserve the current time and playback rate animation.reverse is not a function. (In 'animation.reverse()', 'animation.reverse' is undefined)
-FAIL Reversing an animation without an active timeline throws an InvalidStateError assert_throws: function "() => { animation.reverse(); }" threw object "TypeError: animation.reverse is not a function. (In 'animation.reverse()', 'animation.reverse' is undefined)" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
+PASS Reversing animation when playbackRate = 0 and currentTime < 0 and the target effect end is positive infinity should NOT throw an exception
+PASS Reversing an animation when playbackRate < 0 and currentTime < 0 and the target effect end is positive infinity should make it play from the start
+PASS Reversing when when playbackRate == 0 should preserve the current time and playback rate
+FAIL Reversing an animation without an active timeline throws an InvalidStateError assert_throws: function "() => { animation.reverse(); }" did not throw
Modified: trunk/Source/WebCore/ChangeLog (227622 => 227623)
--- trunk/Source/WebCore/ChangeLog 2018-01-25 20:21:47 UTC (rev 227622)
+++ trunk/Source/WebCore/ChangeLog 2018-01-25 20:23:43 UTC (rev 227623)
@@ -1,5 +1,21 @@
2018-01-25 Antoine Quint <[email protected]>
+ [Web Animations] Expose the reverse() method
+ https://bugs.webkit.org/show_bug.cgi?id=182100
+ <rdar://problem/36867117>
+
+ Reviewed by Dean Jackson.
+
+ We expose and implement the reverse() method on Animation as specified.
+
+ * animation/WebAnimation.cpp:
+ (WebCore::WebAnimation::setPlaybackRate):
+ (WebCore::WebAnimation::reverse):
+ * animation/WebAnimation.h:
+ * animation/WebAnimation.idl:
+
+2018-01-25 Antoine Quint <[email protected]>
+
[Web Animations] Account for provided easings when computing progress and resolving keyframe effect values
https://bugs.webkit.org/show_bug.cgi?id=182098
<rdar://problem/36866149>
Modified: trunk/Source/WebCore/animation/WebAnimation.cpp (227622 => 227623)
--- trunk/Source/WebCore/animation/WebAnimation.cpp 2018-01-25 20:21:47 UTC (rev 227622)
+++ trunk/Source/WebCore/animation/WebAnimation.cpp 2018-01-25 20:23:43 UTC (rev 227623)
@@ -288,17 +288,34 @@
return { };
}
-void WebAnimation::setPlaybackRate(double newPlaybackRate)
+void WebAnimation::setPlaybackRate(double newPlaybackRate, Silently silently)
{
+ // 3.4.17.1. Updating the playback rate of an animation
+ // https://drafts.csswg.org/web-animations-1/#updating-the-playback-rate-of-an-animation
+
if (m_playbackRate == newPlaybackRate)
return;
- // 3.5.17.1. Updating the playback rate of an animation
+ // The procedure to set the animation playback rate of an animation, animation to new playback rate is as follows.
+ // The procedure to silently set the animation playback rate of animation, animation to new playback rate is identical
+ // to the above procedure except that rather than invoking the procedure to set the current time in the final step,
+ // the procedure to silently set the current time is invoked instead.
+
+ // 1. Let previous time be the value of the current time of animation before changing the playback rate.
+ auto previousTime = currentTime();
+
+ // 2. Set the playback rate to new playback rate.
+ m_playbackRate = newPlaybackRate;
+
+ // 3. If previous time is resolved, set the current time of animation to previous time.
// Changes to the playback rate trigger a compensatory seek so that that the animation's current time
// is unaffected by the change to the playback rate.
- auto previousTime = currentTime();
- m_playbackRate = newPlaybackRate;
- if (previousTime)
+ if (!previousTime)
+ return;
+
+ if (silently == Silently::Yes)
+ silentlySetCurrentTime(previousTime);
+ else
setCurrentTime(previousTime);
}
@@ -746,6 +763,38 @@
return { };
}
+ExceptionOr<void> WebAnimation::reverse()
+{
+ // 3.4.18. Reversing an animation
+ // https://drafts.csswg.org/web-animations-1/#reverse-an-animation
+
+ // The procedure to reverse an animation of animation animation is as follows:
+
+ // 1. If there is no timeline associated with animation, or the associated timeline is inactive
+ // throw an InvalidStateError and abort these steps.
+ if (!m_timeline || !m_timeline->currentTime())
+ return Exception { InvalidStateError };
+
+ // 2. Silently set the animation playback rate of animation to −animation playback rate.
+ // This must be done silently or else we may end up resolving the current ready promise when
+ // we do the compensatory seek despite the fact that we will most likely still have a pending
+ // task queued at the end of the operation.
+ setPlaybackRate(-m_playbackRate, Silently::Yes);
+
+ // 3. Run the steps to play an animation for animation with the auto-rewind flag set to true.
+ auto playResult = play(AutoRewind::Yes);
+
+ // If the steps to play an animation throw an exception, restore the original animation playback rate
+ // by re-running the procedure to silently set the animation playback rate with the original animation
+ // playback rate.
+ if (playResult.hasException()) {
+ setPlaybackRate(-m_playbackRate, Silently::Yes);
+ return playResult.releaseException();
+ }
+
+ return { };
+}
+
void WebAnimation::setTimeToRunPendingPauseTask(TimeToRunPendingTask timeToRunPendingTask)
{
m_timeToRunPendingPauseTask = timeToRunPendingTask;
Modified: trunk/Source/WebCore/animation/WebAnimation.h (227622 => 227623)
--- trunk/Source/WebCore/animation/WebAnimation.h 2018-01-25 20:21:47 UTC (rev 227622)
+++ trunk/Source/WebCore/animation/WebAnimation.h 2018-01-25 20:23:43 UTC (rev 227623)
@@ -67,8 +67,9 @@
std::optional<Seconds> currentTime() const;
ExceptionOr<void> setCurrentTime(std::optional<Seconds>);
+ enum class Silently { Yes, No };
double playbackRate() const { return m_playbackRate; }
- void setPlaybackRate(double);
+ void setPlaybackRate(double, Silently silently = Silently::No );
enum class PlayState { Idle, Pending, Running, Paused, Finished };
PlayState playState() const;
@@ -85,6 +86,7 @@
ExceptionOr<void> finish();
ExceptionOr<void> play();
ExceptionOr<void> pause();
+ ExceptionOr<void> reverse();
Seconds timeToNextRequiredTick(Seconds) const;
void resolve(RenderStyle&);
Modified: trunk/Source/WebCore/animation/WebAnimation.idl (227622 => 227623)
--- trunk/Source/WebCore/animation/WebAnimation.idl 2018-01-25 20:21:47 UTC (rev 227622)
+++ trunk/Source/WebCore/animation/WebAnimation.idl 2018-01-25 20:23:43 UTC (rev 227623)
@@ -54,4 +54,5 @@
[MayThrowException] void finish();
[MayThrowException] void play();
[MayThrowException] void pause();
+ [MayThrowException] void reverse();
};