[scroll-animations] Handle dynamically changing @scroll-timelines
We are currently able to create new CSSAnimations linked to CSSScrollTimelines, but we can not change the timeline of a CSSAnimation that is already running. There are three types of changes that can trigger a timeline change for a running animation: 1. When a @scroll-timeline rule is inserted, either via DOM mutation, or via a change in @media query evaluation. 2. When the computed value of 'animation-timeline' changes. 3. When the elements referenced by a @scroll-timeline rule changes, for example 'source:selector(#foo)' references an element with #foo, hence we need a new timeline if #foo is reassigned to point to a different element. This CL implements "timeline change detection" in CSSAnimations, which can discover whether a new timeline is needed or not. This detection runs whenever there's a non-animation-style-change, in other words, whenever something is marked for regular style style recalc, we will check if the timeline currently associated with an animation is up-to-date, and create a new one if needed. In this CL, only Item 1 in the above list is fully solved. However, since this adds the general capability to reconsider previous timeline choices upon style recalc, it also lays the groundwork for solving Item 2 & 3. InertEffect makes things a bit awkward, as usual: we basically have to predict the effect setTimeline will have on the current time of the Animation, without actually calling setTimeline. Hence there's a rather complicated if-statement which makes this prediction. We should ideally try to get rid of InertEffect and do the setTimeline call right away. In the WPT I'm also trying to cover both the result produced by InertEffect, _and_ the result produced by setTimeline. Hence each test is run twice: once for the result produced the same frame the style recalc took place, and once again after scrolling a bit. Bug: 1074052 Change-Id: Ida36a00eb91e26b493c1e70c20dc7b23be7c9a75 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2335282 Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Reviewed-by:Kevin Ellis <kevers@chromium.org> Cr-Commit-Position: refs/heads/master@{#821697}
Showing
This diff is collapsed.
Please register or sign in to comment