Title: [255260] trunk/Source/WebCore
Revision
255260
Author
[email protected]
Date
2020-01-28 10:59:42 -0800 (Tue, 28 Jan 2020)

Log Message

[Web Animations] Separate setting a timeline's current time from updating its animations
https://bugs.webkit.org/show_bug.cgi?id=206880

Reviewed by Dean Jackson.

While we must always update the current time of all timelines if a new animation frame has been requested,
regardless of the reason (rAF callback, animation servicing, etc.), we should only update timelines' animations
if at least one timeline has requested an update. We used to decide this at the DocumentTimeline level, but
this needs to be coordinated at the Document level to consider all timelines at once.

This is required for an upcoming patch where we make changes to the way we schedule animations to correctly
support mixed accelerated and non-accelerated properties.

No new tests since this shouldn't yield any visible behavior change.

* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::updateCurrentTime):
(WebCore::DocumentTimeline::updateAnimationsAndSendEvents):
* animation/DocumentTimeline.h:
* dom/Document.cpp:
(WebCore::Document::updateAnimationsAndSendEvents):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (255259 => 255260)


--- trunk/Source/WebCore/ChangeLog	2020-01-28 18:48:42 UTC (rev 255259)
+++ trunk/Source/WebCore/ChangeLog	2020-01-28 18:59:42 UTC (rev 255260)
@@ -1,3 +1,27 @@
+2020-01-28  Antoine Quint  <[email protected]>
+
+        [Web Animations] Separate setting a timeline's current time from updating its animations
+        https://bugs.webkit.org/show_bug.cgi?id=206880
+
+        Reviewed by Dean Jackson.
+
+        While we must always update the current time of all timelines if a new animation frame has been requested,
+        regardless of the reason (rAF callback, animation servicing, etc.), we should only update timelines' animations
+        if at least one timeline has requested an update. We used to decide this at the DocumentTimeline level, but
+        this needs to be coordinated at the Document level to consider all timelines at once.
+
+        This is required for an upcoming patch where we make changes to the way we schedule animations to correctly
+        support mixed accelerated and non-accelerated properties.
+
+        No new tests since this shouldn't yield any visible behavior change.
+
+        * animation/DocumentTimeline.cpp:
+        (WebCore::DocumentTimeline::updateCurrentTime):
+        (WebCore::DocumentTimeline::updateAnimationsAndSendEvents):
+        * animation/DocumentTimeline.h:
+        * dom/Document.cpp:
+        (WebCore::Document::updateAnimationsAndSendEvents):
+
 2020-01-28  Zalan Bujtas  <[email protected]>
 
         [LFC][IFC] Decouple Display::LineBox and Layout::LineBoxBuilder

Modified: trunk/Source/WebCore/animation/DocumentTimeline.cpp (255259 => 255260)


--- trunk/Source/WebCore/animation/DocumentTimeline.cpp	2020-01-28 18:48:42 UTC (rev 255259)
+++ trunk/Source/WebCore/animation/DocumentTimeline.cpp	2020-01-28 18:59:42 UTC (rev 255260)
@@ -335,7 +335,7 @@
     return !m_animations.isEmpty() || !m_acceleratedAnimationsPendingRunningStateChange.isEmpty();
 }
 
-void DocumentTimeline::updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp)
+void DocumentTimeline::updateCurrentTime(DOMHighResTimeStamp timestamp)
 {
     // We need to freeze the current time even if no animation is running.
     // document.timeline.currentTime may be called from a rAF callback and
@@ -342,8 +342,11 @@
     // it has to match the rAF timestamp.
     if (!m_isSuspended)
         cacheCurrentTime(timestamp);
+}
 
-    if (m_isSuspended || !m_animationResolutionScheduled || !shouldRunUpdateAnimationsAndSendEventsIgnoringSuspensionState())
+void DocumentTimeline::updateAnimationsAndSendEvents()
+{
+    if (m_isSuspended || !shouldRunUpdateAnimationsAndSendEventsIgnoringSuspensionState())
         return;
 
     // Updating animations and sending events may invalidate the timing of some animations, so we must set the m_animationResolutionScheduled

Modified: trunk/Source/WebCore/animation/DocumentTimeline.h (255259 => 255260)


--- trunk/Source/WebCore/animation/DocumentTimeline.h	2020-01-28 18:48:42 UTC (rev 255259)
+++ trunk/Source/WebCore/animation/DocumentTimeline.h	2020-01-28 18:59:42 UTC (rev 255260)
@@ -72,7 +72,9 @@
 
     void enqueueAnimationPlaybackEvent(AnimationPlaybackEvent&);
     
-    void updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp);
+    bool scheduledUpdate() const { return m_animationResolutionScheduled; }
+    void updateCurrentTime(DOMHighResTimeStamp timestamp);
+    void updateAnimationsAndSendEvents();
 
     WEBCORE_EXPORT Seconds animationInterval() const;
     WEBCORE_EXPORT void suspendAnimations();

Modified: trunk/Source/WebCore/dom/Document.cpp (255259 => 255260)


--- trunk/Source/WebCore/dom/Document.cpp	2020-01-28 18:48:42 UTC (rev 255259)
+++ trunk/Source/WebCore/dom/Document.cpp	2020-01-28 18:59:42 UTC (rev 255260)
@@ -6353,12 +6353,21 @@
 void Document::updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp)
 {
     ASSERT(!m_timelines.hasNullReferences());
+
     // We need to copy m_timelines before iterating over its members since calling updateAnimationsAndSendEvents() may mutate m_timelines.
     Vector<RefPtr<DocumentTimeline>> timelines;
-    for (auto& timeline : m_timelines)
+    bool shouldUpdateAnimations = false;
+    for (auto& timeline : m_timelines) {
+        if (!shouldUpdateAnimations && timeline.scheduledUpdate())
+            shouldUpdateAnimations = true;
         timelines.append(&timeline);
-    for (auto& timeline : timelines)
-        timeline->updateAnimationsAndSendEvents(timestamp);
+    }
+
+    for (auto& timeline : timelines) {
+        timeline->updateCurrentTime(timestamp);
+        if (shouldUpdateAnimations)
+            timeline->updateAnimationsAndSendEvents();
+    }
 }
 
 void Document::serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to