[Web Animations] Refactor cancelDeclarativeAnimationsForElement and willDestroyRender...
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Mar 2020 14:41:04 +0000 (14:41 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Mar 2020 14:41:04 +0000 (14:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=209423

Reviewed by Antti Koivisto.

The methods cancelDeclarativeAnimationsForElement and willDestroyRendererForElement on AnimationTimeline did the same
thing save for the argument passed to WebAnimation::cancel(). We now refactor those two methods into a single
cancelDeclarativeAnimationsForElement method with an argument to set whether cancelation should be silent.
As a result, we also change WebAnimation::cancel() to have a single flavor instead of one without an argument and one
with the silent argument.

No test because there is no change in visible behavior.

* animation/AnimationTimeline.cpp:
(WebCore::AnimationTimeline::elementWasRemoved):
(WebCore::AnimationTimeline::cancelDeclarativeAnimationsForElement):
(WebCore::AnimationTimeline::willDestroyRendererForElement): Deleted.
* animation/AnimationTimeline.h:
* animation/DeclarativeAnimation.cpp:
(WebCore::DeclarativeAnimation::cancel):
* animation/DeclarativeAnimation.h:
* animation/WebAnimation.cpp:
* animation/WebAnimation.h:
* rendering/updating/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::tearDownRenderers):

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

Source/WebCore/ChangeLog
Source/WebCore/animation/AnimationTimeline.cpp
Source/WebCore/animation/AnimationTimeline.h
Source/WebCore/animation/DeclarativeAnimation.cpp
Source/WebCore/animation/DeclarativeAnimation.h
Source/WebCore/animation/WebAnimation.cpp
Source/WebCore/animation/WebAnimation.h
Source/WebCore/rendering/updating/RenderTreeUpdater.cpp

index 9cea0d7..31d4ad5 100644 (file)
@@ -1,3 +1,31 @@
+2020-03-23  Antoine Quint  <graouts@apple.com>
+
+        [Web Animations] Refactor cancelDeclarativeAnimationsForElement and willDestroyRendererForElement on AnimationTimeline
+        https://bugs.webkit.org/show_bug.cgi?id=209423
+
+        Reviewed by Antti Koivisto.
+
+        The methods cancelDeclarativeAnimationsForElement and willDestroyRendererForElement on AnimationTimeline did the same
+        thing save for the argument passed to WebAnimation::cancel(). We now refactor those two methods into a single
+        cancelDeclarativeAnimationsForElement method with an argument to set whether cancelation should be silent.
+        As a result, we also change WebAnimation::cancel() to have a single flavor instead of one without an argument and one
+        with the silent argument.
+
+        No test because there is no change in visible behavior.
+
+        * animation/AnimationTimeline.cpp:
+        (WebCore::AnimationTimeline::elementWasRemoved):
+        (WebCore::AnimationTimeline::cancelDeclarativeAnimationsForElement):
+        (WebCore::AnimationTimeline::willDestroyRendererForElement): Deleted.
+        * animation/AnimationTimeline.h:
+        * animation/DeclarativeAnimation.cpp:
+        (WebCore::DeclarativeAnimation::cancel):
+        * animation/DeclarativeAnimation.h:
+        * animation/WebAnimation.cpp:
+        * animation/WebAnimation.h:
+        * rendering/updating/RenderTreeUpdater.cpp:
+        (WebCore::RenderTreeUpdater::tearDownRenderers):
+
 2020-03-23  Youenn Fablet  <youenn@apple.com>
 
         AudioTrackPrivateMediaStream recovers from a muted track very late
index 12a880c..6540dda 100644 (file)
@@ -188,25 +188,9 @@ void AnimationTimeline::removeCSSAnimationCreatedByMarkup(Element& element, CSSA
     }
 }
 
-void AnimationTimeline::willDestroyRendererForElement(Element& element)
-{
-    if (auto* transitions = element.transitions()) {
-        for (auto& cssTransition : *transitions)
-            cssTransition->cancel(WebAnimation::Silently::Yes);
-    }
-
-    if (auto* cssAnimations = element.cssAnimations()) {
-        for (auto& cssAnimation : *cssAnimations) {
-            if (is<CSSAnimation>(cssAnimation))
-                removeCSSAnimationCreatedByMarkup(element, downcast<CSSAnimation>(*cssAnimation));
-            cssAnimation->cancel(WebAnimation::Silently::Yes);
-        }
-    }
-}
-
 void AnimationTimeline::elementWasRemoved(Element& element)
 {
-    willDestroyRendererForElement(element);
+    cancelDeclarativeAnimationsForElement(element, WebAnimation::Silently::Yes);
 }
 
 void AnimationTimeline::removeAnimationsForElement(Element& element)
@@ -221,18 +205,18 @@ void AnimationTimeline::willChangeRendererForElement(Element& element)
         animation->willChangeRenderer();
 }
 
-void AnimationTimeline::cancelDeclarativeAnimationsForElement(Element& element)
+void AnimationTimeline::cancelDeclarativeAnimationsForElement(Element& element, WebAnimation::Silently silently)
 {
     if (auto* transitions = element.transitions()) {
         for (auto& cssTransition : *transitions)
-            cssTransition->cancel();
+            cssTransition->cancel(silently);
     }
 
     if (auto* cssAnimations = element.cssAnimations()) {
         for (auto& cssAnimation : *cssAnimations) {
             if (is<CSSAnimation>(cssAnimation))
                 removeCSSAnimationCreatedByMarkup(element, downcast<CSSAnimation>(*cssAnimation));
-            cssAnimation->cancel();
+            cssAnimation->cancel(silently);
         }
     }
 }
index ce9fba2..df1ae1e 100644 (file)
@@ -64,8 +64,7 @@ public:
     void removeAnimationsForElement(Element&);
 
     void willChangeRendererForElement(Element&);
-    void willDestroyRendererForElement(Element&);
-    void cancelDeclarativeAnimationsForElement(Element&);
+    void cancelDeclarativeAnimationsForElement(Element&, WebAnimation::Silently);
 
     virtual void animationWasAddedToElement(WebAnimation&, Element&);
     virtual void animationWasRemovedFromElement(WebAnimation&, Element&);
index 72c6cf2..420f769 100644 (file)
@@ -208,7 +208,7 @@ void DeclarativeAnimation::setTimeline(RefPtr<AnimationTimeline>&& newTimeline)
     WebAnimation::setTimeline(WTFMove(newTimeline));
 }
 
-void DeclarativeAnimation::cancel()
+void DeclarativeAnimation::cancel(Silently silently)
 {
     auto cancelationTime = 0_s;
     if (auto* animationEffect = effect()) {
@@ -216,7 +216,7 @@ void DeclarativeAnimation::cancel()
             cancelationTime = *activeTime;
     }
 
-    WebAnimation::cancel();
+    WebAnimation::cancel(silently);
 
     invalidateDOMEvents(cancelationTime);
 }
index baaf925..98e78aa 100644 (file)
@@ -63,7 +63,7 @@ public:
     ExceptionOr<void> bindingsPause() override;
 
     void setTimeline(RefPtr<AnimationTimeline>&&) final;
-    void cancel() final;
+    void cancel(Silently = Silently::No) final;
 
     void tick() override;
 
index 78b333a..65219ac 100644 (file)
@@ -604,12 +604,6 @@ Seconds WebAnimation::effectEndTime() const
     return m_effect ? m_effect->endTime() : 0_s;
 }
 
-void WebAnimation::cancel()
-{
-    cancel(Silently::No);
-    invalidateEffect();
-}
-
 void WebAnimation::cancel(Silently silently)
 {
     LOG_WITH_STREAM(Animations, stream << "WebAnimation " << this << " cancel(silently " << (silently == Silently::Yes) << ") (current time is " << currentTime() << ")");
index b14005a..d70c2f2 100644 (file)
@@ -93,8 +93,7 @@ public:
     using FinishedPromise = DOMPromiseProxyWithResolveCallback<IDLInterface<WebAnimation>>;
     FinishedPromise& finished() { return m_finishedPromise.get(); }
 
-    virtual void cancel();
-    void cancel(Silently);
+    virtual void cancel(Silently = Silently::No);
     ExceptionOr<void> finish();
     ExceptionOr<void> play();
     void updatePlaybackRate(double);
index 195491a..a5b7fbc 100644 (file)
@@ -573,9 +573,9 @@ void RenderTreeUpdater::tearDownRenderers(Element& root, TeardownType teardownTy
             case TeardownType::RendererUpdateCancelingAnimations:
                 if (timeline) {
                     if (document.renderTreeBeingDestroyed())
-                        timeline->willDestroyRendererForElement(element);
+                        timeline->cancelDeclarativeAnimationsForElement(element, WebAnimation::Silently::Yes);
                     else if (teardownType == TeardownType::RendererUpdateCancelingAnimations)
-                        timeline->cancelDeclarativeAnimationsForElement(element);
+                        timeline->cancelDeclarativeAnimationsForElement(element, WebAnimation::Silently::No);
                 }
                 animationController.cancelAnimations(element);
                 break;