[Web Animations] Ensure we don't update an animation's finished state twice when...
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Dec 2018 17:49:55 +0000 (17:49 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Dec 2018 17:49:55 +0000 (17:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192757

Reviewed by Dean Jackson.

When animations are udpated and DocumentTimeline::updateAnimationsAndSendEvents() is called, we used to update an animation's finished state
twice since we'd do it once when calling tick() and once again when calling resolve() in the ensuing style invalidation. We now keep track of
whether we've already updated an animation's finished state during animation update in the call to tick() and avoid updating in the immediate
next call to resolve(), unless any of the timing properties have changed in the meantime.

No new test since there is no user-observable change.

* animation/WebAnimation.cpp:
(WebCore::WebAnimation::timingDidChange):
(WebCore::WebAnimation::tick):
(WebCore::WebAnimation::resolve):
* animation/WebAnimation.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239269 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/animation/WebAnimation.cpp
Source/WebCore/animation/WebAnimation.h

index be9e4c1..eab78ec 100644 (file)
@@ -1,3 +1,23 @@
+2018-12-17  Antoine Quint  <graouts@apple.com>
+
+        [Web Animations] Ensure we don't update an animation's finished state twice when updating animations
+        https://bugs.webkit.org/show_bug.cgi?id=192757
+
+        Reviewed by Dean Jackson.
+
+        When animations are udpated and DocumentTimeline::updateAnimationsAndSendEvents() is called, we used to update an animation's finished state
+        twice since we'd do it once when calling tick() and once again when calling resolve() in the ensuing style invalidation. We now keep track of
+        whether we've already updated an animation's finished state during animation update in the call to tick() and avoid updating in the immediate
+        next call to resolve(), unless any of the timing properties have changed in the meantime.
+
+        No new test since there is no user-observable change.
+
+        * animation/WebAnimation.cpp:
+        (WebCore::WebAnimation::timingDidChange):
+        (WebCore::WebAnimation::tick):
+        (WebCore::WebAnimation::resolve):
+        * animation/WebAnimation.h:
+
 2018-12-17  Simon Fraser  <simon.fraser@apple.com>
 
         REGRESSION (r233268): Elements animated in from offscreen sometimes don't display
index 850d838..4f2e64f 100644 (file)
@@ -696,6 +696,7 @@ ExceptionOr<void> WebAnimation::finish()
 
 void WebAnimation::timingDidChange(DidSeek didSeek, SynchronouslyNotify synchronouslyNotify)
 {
+    m_shouldSkipUpdatingFinishedStateWhenResolving = false;
     updateFinishedState(didSeek, synchronouslyNotify);
     if (m_timeline)
         m_timeline->animationTimingDidChange(*this);
@@ -1107,6 +1108,7 @@ bool WebAnimation::needsTick() const
 void WebAnimation::tick()
 {
     updateFinishedState(DidSeek::No, SynchronouslyNotify::Yes);
+    m_shouldSkipUpdatingFinishedStateWhenResolving = true;
 
     // Run pending tasks, if any.
     if (hasPendingPauseTask())
@@ -1119,7 +1121,10 @@ void WebAnimation::tick()
 
 void WebAnimation::resolve(RenderStyle& targetStyle)
 {
-    updateFinishedState(DidSeek::No, SynchronouslyNotify::Yes);
+    if (!m_shouldSkipUpdatingFinishedStateWhenResolving)
+        updateFinishedState(DidSeek::No, SynchronouslyNotify::Yes);
+    m_shouldSkipUpdatingFinishedStateWhenResolving = false;
+
     if (m_effect)
         m_effect->apply(targetStyle);
 }
index c99dafa..9c88b30 100644 (file)
@@ -174,6 +174,7 @@ private:
     bool m_finishNotificationStepsMicrotaskPending;
     bool m_scheduledMicrotask;
     bool m_isRelevant;
+    bool m_shouldSkipUpdatingFinishedStateWhenResolving;
     UniqueRef<ReadyPromise> m_readyPromise;
     UniqueRef<FinishedPromise> m_finishedPromise;
     TimeToRunPendingTask m_timeToRunPendingPlayTask { TimeToRunPendingTask::NotScheduled };