+26
−26
+25
−12
Loading
We use a HashMap to keep the ScrollTimeline, and use scroll-direction as the key, so a specific Element and a fixed scroll direction map to a specific ScrollTimeline object. This means a maximum of one ScrollTimeline objects per @scroll-timeline declaration. If @scroll-timeline rule gets updated, we rebuild all the CSS animations, and then re-check their ScrollTimeline objects. If there are any unused old ScrollTimeline objects, their ref-counts will be zero because only Animation object holds the strong reference, so they will be removed from the associated ScrollTimelineSet and be deleted automatically. Note: We may have to update this once we support more descriptors in @scroll-timeline. However, the syntax update is to obsolute @scroll-timeline, so we don't have to address too many cases for now. This should be enough. This is an internal optimization, and we can probably just rely on the existing WPTs to test this without any memory leaks. Differential Revision: https://phabricator.services.mozilla.com/D137236