Title: [258842] trunk/Source/WebCore
Revision
258842
Author
grao...@webkit.org
Date
2020-03-23 07:41:04 -0700 (Mon, 23 Mar 2020)

Log Message

[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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (258841 => 258842)


--- trunk/Source/WebCore/ChangeLog	2020-03-23 14:38:22 UTC (rev 258841)
+++ trunk/Source/WebCore/ChangeLog	2020-03-23 14:41:04 UTC (rev 258842)
@@ -1,3 +1,31 @@
+2020-03-23  Antoine Quint  <grao...@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  <you...@apple.com>
 
         AudioTrackPrivateMediaStream recovers from a muted track very late

Modified: trunk/Source/WebCore/animation/AnimationTimeline.cpp (258841 => 258842)


--- trunk/Source/WebCore/animation/AnimationTimeline.cpp	2020-03-23 14:38:22 UTC (rev 258841)
+++ trunk/Source/WebCore/animation/AnimationTimeline.cpp	2020-03-23 14:41:04 UTC (rev 258842)
@@ -188,25 +188,9 @@
     }
 }
 
-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,11 +205,11 @@
         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()) {
@@ -232,7 +216,7 @@
         for (auto& cssAnimation : *cssAnimations) {
             if (is<CSSAnimation>(cssAnimation))
                 removeCSSAnimationCreatedByMarkup(element, downcast<CSSAnimation>(*cssAnimation));
-            cssAnimation->cancel();
+            cssAnimation->cancel(silently);
         }
     }
 }

Modified: trunk/Source/WebCore/animation/AnimationTimeline.h (258841 => 258842)


--- trunk/Source/WebCore/animation/AnimationTimeline.h	2020-03-23 14:38:22 UTC (rev 258841)
+++ trunk/Source/WebCore/animation/AnimationTimeline.h	2020-03-23 14:41:04 UTC (rev 258842)
@@ -64,8 +64,7 @@
     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&);

Modified: trunk/Source/WebCore/animation/DeclarativeAnimation.cpp (258841 => 258842)


--- trunk/Source/WebCore/animation/DeclarativeAnimation.cpp	2020-03-23 14:38:22 UTC (rev 258841)
+++ trunk/Source/WebCore/animation/DeclarativeAnimation.cpp	2020-03-23 14:41:04 UTC (rev 258842)
@@ -208,7 +208,7 @@
     WebAnimation::setTimeline(WTFMove(newTimeline));
 }
 
-void DeclarativeAnimation::cancel()
+void DeclarativeAnimation::cancel(Silently silently)
 {
     auto cancelationTime = 0_s;
     if (auto* animationEffect = effect()) {
@@ -216,7 +216,7 @@
             cancelationTime = *activeTime;
     }
 
-    WebAnimation::cancel();
+    WebAnimation::cancel(silently);
 
     invalidateDOMEvents(cancelationTime);
 }

Modified: trunk/Source/WebCore/animation/DeclarativeAnimation.h (258841 => 258842)


--- trunk/Source/WebCore/animation/DeclarativeAnimation.h	2020-03-23 14:38:22 UTC (rev 258841)
+++ trunk/Source/WebCore/animation/DeclarativeAnimation.h	2020-03-23 14:41:04 UTC (rev 258842)
@@ -63,7 +63,7 @@
     ExceptionOr<void> bindingsPause() override;
 
     void setTimeline(RefPtr<AnimationTimeline>&&) final;
-    void cancel() final;
+    void cancel(Silently = Silently::No) final;
 
     void tick() override;
 

Modified: trunk/Source/WebCore/animation/WebAnimation.cpp (258841 => 258842)


--- trunk/Source/WebCore/animation/WebAnimation.cpp	2020-03-23 14:38:22 UTC (rev 258841)
+++ trunk/Source/WebCore/animation/WebAnimation.cpp	2020-03-23 14:41:04 UTC (rev 258842)
@@ -604,12 +604,6 @@
     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() << ")");

Modified: trunk/Source/WebCore/animation/WebAnimation.h (258841 => 258842)


--- trunk/Source/WebCore/animation/WebAnimation.h	2020-03-23 14:38:22 UTC (rev 258841)
+++ trunk/Source/WebCore/animation/WebAnimation.h	2020-03-23 14:41:04 UTC (rev 258842)
@@ -93,8 +93,7 @@
     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);

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp (258841 => 258842)


--- trunk/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp	2020-03-23 14:38:22 UTC (rev 258841)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp	2020-03-23 14:41:04 UTC (rev 258842)
@@ -573,9 +573,9 @@
             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;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to