12020-04-22 Antoine Quint <graouts@apple.com>
2
3 [Web Animations] Coordinate "update animations and send events" procedure across multiple timelines
4 https://bugs.webkit.org/show_bug.cgi?id=202109
5 <rdar://problem/59470821>
6
7 Reviewed by NOBODY (OOPS!).
8
9 So far, although we did manage multiple animation timelines per document, we mostly operated under the assumption that there really was a single timeline.
10 In this patch we make the "update animations and send events" procedure, which is central to the lifecycle of animations, work with multiple timelines such
11 that a single microtask checkpoint is performed even with multiple timelines, whereas we would perform one per timeline before. To do this, we move much of
12 the logic DocumentTimeline::updateAnimationsAndSendEvents() to DocumentTimelinesController where each step is run across each timeline, rather than running
13 all steps for each timeline one after the other, respecting the single microtask checkpoint in the middle of the process.
14
15 To minimize code churn at this stage, we still keep a fair bit of logic in DocumentTimeline and, while we remove updateAnimationsAndSendEvents(),
16 internalUpdateAnimationsAndSendEvents() and updateCurrentTime(), we expose three methods that allow to run the pre-flight sequence in
17 documentWillUpdateAnimationsAndSendEvents(), collect pending events in prepareForPendingAnimationEventsDispatch() and run the post-flight sequence
18 in documentDidUpdateAnimationsAndSendEvents().
19
20 None of the logic changes, this is just moving code around. In the future, more patches will move code from DocumentTimeline up to DocumentTimelinesController
21 such that events are enqueued there, and animation scheduling as well. But this already lets us pass a new test that used to flakily reject promises in the WPT
22 test web-animations/timing-model/timelines/update-and-send-events.html.
23
24 * animation/AnimationTimeline.h:
25 (WebCore::AnimationTimeline::relevantAnimations const):
26 (WebCore::AnimationTimeline::allAnimations const):
27 * animation/DocumentTimeline.cpp:
28 (WebCore::DocumentTimeline::documentWillUpdateAnimationsAndSendEvents):
29 (WebCore::DocumentTimeline::documentDidUpdateAnimationsAndSendEvents):
30 (WebCore::DocumentTimeline::prepareForPendingAnimationEventsDispatch):
31 (WebCore::DocumentTimeline::updateCurrentTime): Deleted.
32 (WebCore::DocumentTimeline::updateAnimationsAndSendEvents): Deleted.
33 (WebCore::DocumentTimeline::internalUpdateAnimationsAndSendEvents): Deleted.
34 * animation/DocumentTimeline.h:
35 * animation/DocumentTimelinesController.cpp:
36 (WebCore::DocumentTimelinesController::DocumentTimelinesController):
37 (WebCore::DocumentTimelinesController::updateAnimationsAndSendEvents):
38 * animation/DocumentTimelinesController.h:
39 * animation/WebAnimationTypes.h:
40 * dom/Document.cpp:
41 (WebCore::Document::ensureTimelinesController):
42