Changeset 225927 in webkit
- Timestamp:
- Dec 14, 2017 2:12:37 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r225917 r225927 1 2017-12-14 Antoine Quint <graouts@apple.com> 2 3 [Web Animations] Implement the cancel() method on Animation 4 https://bugs.webkit.org/show_bug.cgi?id=180830 5 <rdar://problem/36055816> 6 7 Reviewed by Dean Jackson. 8 9 Rebase some WPT expectations with progressions due to exposing the cancel() method. 10 11 * http/wpt/web-animations/interfaces/Animation/idlharness-expected.txt: 12 1 13 2017-12-14 Antoine Quint <graouts@apple.com> 2 14 -
trunk/LayoutTests/http/wpt/web-animations/interfaces/Animation/idlharness-expected.txt
r225917 r225927 16 16 PASS Animation interface: attribute finished 17 17 PASS Animation interface: attribute onfinish 18 FAIL Animation interface: attribute oncancel assert_true: The prototype object must have a property "oncancel" expected true got false 19 FAIL Animation interface: operation cancel() assert_own_property: interface prototype object missing non-static operation expected property "cancel" missing 18 PASS Animation interface: attribute oncancel 19 PASS Animation interface: operation cancel() 20 20 PASS Animation interface: operation finish() 21 21 PASS Animation interface: operation play() … … 34 34 PASS Animation interface: new Animation() must inherit property "finished" with the proper type 35 35 PASS Animation interface: new Animation() must inherit property "onfinish" with the proper type 36 FAIL Animation interface: new Animation() must inherit property "oncancel" with the proper type assert_inherits: property "oncancel" not found in prototype chain 37 FAIL Animation interface: new Animation() must inherit property "cancel()" with the proper type assert_inherits: property "cancel" not found in prototype chain 36 PASS Animation interface: new Animation() must inherit property "oncancel" with the proper type 37 PASS Animation interface: new Animation() must inherit property "cancel()" with the proper type 38 38 PASS Animation interface: new Animation() must inherit property "finish()" with the proper type 39 39 PASS Animation interface: new Animation() must inherit property "play()" with the proper type -
trunk/Source/WebCore/ChangeLog
r225923 r225927 1 2017-12-14 Antoine Quint <graouts@apple.com> 2 3 [Web Animations] Implement the cancel() method on Animation 4 https://bugs.webkit.org/show_bug.cgi?id=180830 5 <rdar://problem/36055816> 6 7 Reviewed by Dean Jackson. 8 9 We implement the cancel() method on the Animation interface with full spec text defining 10 the normative behavior of those methods and code matching those steps. Implementing the 11 cancel() method required implementing the notion of "resetting pending tasks", 12 which the Web Animations spec defines as well. 13 14 * animation/WebAnimation.cpp: 15 (WebCore::WebAnimation::setEffect): 16 (WebCore::WebAnimation::cancel): 17 (WebCore::WebAnimation::resetPendingTasks): 18 * animation/WebAnimation.h: 19 * animation/WebAnimation.idl: 20 1 21 2017-12-14 Jer Noble <jer.noble@apple.com> 2 22 -
trunk/Source/WebCore/animation/WebAnimation.cpp
r225917 r225927 68 68 void WebAnimation::setEffect(RefPtr<AnimationEffect>&& effect) 69 69 { 70 // 3.4.3. Setting the target effect of an animation 71 // https://drafts.csswg.org/web-animations-1/#setting-the-target-effect 72 73 // 2. If new effect is the same object as old effect, abort this procedure. 70 74 if (effect == m_effect) 71 75 return; 76 77 // 3. If new effect is null and old effect is not null, run the procedure to reset an animation's pending tasks on animation. 78 if (!effect && m_effect) 79 resetPendingTasks(); 72 80 73 81 if (m_effect) { … … 317 325 } 318 326 327 void WebAnimation::cancel() 328 { 329 // 3.4.16. Canceling an animation 330 // https://drafts.csswg.org/web-animations-1/#canceling-an-animation-section 331 // 332 // An animation can be canceled which causes the current time to become unresolved hence removing any effects caused by the target effect. 333 // 334 // The procedure to cancel an animation for animation is as follows: 335 // 336 // 1. If animation's play state is not idle, perform the following steps: 337 if (playState() != PlayState::Idle) { 338 // 1. Run the procedure to reset an animation's pending tasks on animation. 339 resetPendingTasks(); 340 341 // 2. Reject the current finished promise with a DOMException named "AbortError". 342 m_finishedPromise.reject(Exception { AbortError }); 343 344 // 3. Let current finished promise be a new (pending) Promise object. 345 m_finishedPromise.clear(); 346 347 // 4. Create an AnimationPlaybackEvent, cancelEvent. 348 // 5. Set cancelEvent's type attribute to cancel. 349 // 6. Set cancelEvent's currentTime to null. 350 // 7. Let timeline time be the current time of the timeline with which animation is associated. If animation is not associated with an 351 // active timeline, let timeline time be n unresolved time value. 352 // 8. Set cancelEvent's timelineTime to timeline time. If timeline time is unresolved, set it to null. 353 // 9. If animation has a document for timing, then append cancelEvent to its document for timing's pending animation event queue along 354 // with its target, animation. If animation is associated with an active timeline that defines a procedure to convert timeline times 355 // to origin-relative time, let the scheduled event time be the result of applying that procedure to timeline time. Otherwise, the 356 // scheduled event time is an unresolved time value. 357 // Otherwise, queue a task to dispatch cancelEvent at animation. The task source for this task is the DOM manipulation task source. 358 enqueueAnimationPlaybackEvent(eventNames().cancelEvent, std::nullopt, m_timeline ? m_timeline->currentTime() : std::nullopt); 359 } 360 361 // 2. Make animation's hold time unresolved. 362 m_holdTime = std::nullopt; 363 364 // 3. Make animation's start time unresolved. 365 setStartTime(std::nullopt); 366 } 367 319 368 void WebAnimation::enqueueAnimationPlaybackEvent(const AtomicString& type, std::optional<Seconds> currentTime, std::optional<Seconds> timelineTime) 320 369 { … … 335 384 }); 336 385 } 386 } 387 388 void WebAnimation::resetPendingTasks() 389 { 390 // The procedure to reset an animation's pending tasks for animation is as follows: 391 // https://drafts.csswg.org/web-animations-1/#reset-an-animations-pending-tasks 392 // 393 // 1. If animation does not have a pending play task or a pending pause task, abort this procedure. 394 if (!pending()) 395 return; 396 397 // 2. If animation has a pending play task, cancel that task. 398 if (hasPendingPlayTask()) 399 setTimeToRunPendingPlayTask(TimeToRunPendingTask::NotScheduled); 400 401 // 3. If animation has a pending pause task, cancel that task. 402 if (hasPendingPauseTask()) 403 setTimeToRunPendingPauseTask(TimeToRunPendingTask::NotScheduled); 404 405 // 4. Reject animation's current ready promise with a DOMException named "AbortError". 406 m_readyPromise.reject(Exception { AbortError }); 407 408 // 5. Let animation's current ready promise be the result of creating a new resolved Promise object. 409 m_readyPromise.clear(); 410 m_readyPromise.resolve(*this); 337 411 } 338 412 -
trunk/Source/WebCore/animation/WebAnimation.h
r225917 r225927 79 79 FinishedPromise& finished() { return m_finishedPromise; } 80 80 81 void cancel(); 81 82 ExceptionOr<void> finish(); 82 83 ExceptionOr<void> play(); … … 121 122 void runPendingPauseTask(); 122 123 void runPendingPlayTask(); 124 void resetPendingTasks(); 123 125 124 126 RefPtr<AnimationEffect> m_effect; -
trunk/Source/WebCore/animation/WebAnimation.idl
r225917 r225927 47 47 readonly attribute boolean pending; 48 48 attribute EventHandler onfinish; 49 attribute EventHandler oncancel; 49 50 readonly attribute Promise<WebAnimation> ready; 50 51 readonly attribute Promise<WebAnimation> finished; 52 void cancel(); 51 53 [MayThrowException] void finish(); 52 54 [MayThrowException] void play();
Note: See TracChangeset
for help on using the changeset viewer.