Changeset 258842 in webkit


Ignore:
Timestamp:
Mar 23, 2020, 7:41:04 AM (5 years ago)
Author:
graouts@webkit.org
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):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r258840 r258842  
     12020-03-23  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Refactor cancelDeclarativeAnimationsForElement and willDestroyRendererForElement on AnimationTimeline
     4        https://bugs.webkit.org/show_bug.cgi?id=209423
     5
     6        Reviewed by Antti Koivisto.
     7
     8        The methods cancelDeclarativeAnimationsForElement and willDestroyRendererForElement on AnimationTimeline did the same
     9        thing save for the argument passed to WebAnimation::cancel(). We now refactor those two methods into a single
     10        cancelDeclarativeAnimationsForElement method with an argument to set whether cancelation should be silent.
     11        As a result, we also change WebAnimation::cancel() to have a single flavor instead of one without an argument and one
     12        with the silent argument.
     13
     14        No test because there is no change in visible behavior.
     15
     16        * animation/AnimationTimeline.cpp:
     17        (WebCore::AnimationTimeline::elementWasRemoved):
     18        (WebCore::AnimationTimeline::cancelDeclarativeAnimationsForElement):
     19        (WebCore::AnimationTimeline::willDestroyRendererForElement): Deleted.
     20        * animation/AnimationTimeline.h:
     21        * animation/DeclarativeAnimation.cpp:
     22        (WebCore::DeclarativeAnimation::cancel):
     23        * animation/DeclarativeAnimation.h:
     24        * animation/WebAnimation.cpp:
     25        * animation/WebAnimation.h:
     26        * rendering/updating/RenderTreeUpdater.cpp:
     27        (WebCore::RenderTreeUpdater::tearDownRenderers):
     28
    1292020-03-23  Youenn Fablet  <youenn@apple.com>
    230
  • trunk/Source/WebCore/animation/AnimationTimeline.cpp

    r258834 r258842  
    189189}
    190190
    191 void AnimationTimeline::willDestroyRendererForElement(Element& element)
     191void AnimationTimeline::elementWasRemoved(Element& element)
     192{
     193    cancelDeclarativeAnimationsForElement(element, WebAnimation::Silently::Yes);
     194}
     195
     196void AnimationTimeline::removeAnimationsForElement(Element& element)
     197{
     198    for (auto& animation : animationsForElement(element))
     199        animation->remove();
     200}
     201
     202void AnimationTimeline::willChangeRendererForElement(Element& element)
     203{
     204    for (auto& animation : animationsForElement(element))
     205        animation->willChangeRenderer();
     206}
     207
     208void AnimationTimeline::cancelDeclarativeAnimationsForElement(Element& element, WebAnimation::Silently silently)
    192209{
    193210    if (auto* transitions = element.transitions()) {
    194211        for (auto& cssTransition : *transitions)
    195             cssTransition->cancel(WebAnimation::Silently::Yes);
     212            cssTransition->cancel(silently);
    196213    }
    197214
     
    200217            if (is<CSSAnimation>(cssAnimation))
    201218                removeCSSAnimationCreatedByMarkup(element, downcast<CSSAnimation>(*cssAnimation));
    202             cssAnimation->cancel(WebAnimation::Silently::Yes);
    203         }
    204     }
    205 }
    206 
    207 void AnimationTimeline::elementWasRemoved(Element& element)
    208 {
    209     willDestroyRendererForElement(element);
    210 }
    211 
    212 void AnimationTimeline::removeAnimationsForElement(Element& element)
    213 {
    214     for (auto& animation : animationsForElement(element))
    215         animation->remove();
    216 }
    217 
    218 void AnimationTimeline::willChangeRendererForElement(Element& element)
    219 {
    220     for (auto& animation : animationsForElement(element))
    221         animation->willChangeRenderer();
    222 }
    223 
    224 void AnimationTimeline::cancelDeclarativeAnimationsForElement(Element& element)
    225 {
    226     if (auto* transitions = element.transitions()) {
    227         for (auto& cssTransition : *transitions)
    228             cssTransition->cancel();
    229     }
    230 
    231     if (auto* cssAnimations = element.cssAnimations()) {
    232         for (auto& cssAnimation : *cssAnimations) {
    233             if (is<CSSAnimation>(cssAnimation))
    234                 removeCSSAnimationCreatedByMarkup(element, downcast<CSSAnimation>(*cssAnimation));
    235             cssAnimation->cancel();
     219            cssAnimation->cancel(silently);
    236220        }
    237221    }
  • trunk/Source/WebCore/animation/AnimationTimeline.h

    r258834 r258842  
    6565
    6666    void willChangeRendererForElement(Element&);
    67     void willDestroyRendererForElement(Element&);
    68     void cancelDeclarativeAnimationsForElement(Element&);
     67    void cancelDeclarativeAnimationsForElement(Element&, WebAnimation::Silently);
    6968
    7069    virtual void animationWasAddedToElement(WebAnimation&, Element&);
  • trunk/Source/WebCore/animation/DeclarativeAnimation.cpp

    r257138 r258842  
    209209}
    210210
    211 void DeclarativeAnimation::cancel()
     211void DeclarativeAnimation::cancel(Silently silently)
    212212{
    213213    auto cancelationTime = 0_s;
     
    217217    }
    218218
    219     WebAnimation::cancel();
     219    WebAnimation::cancel(silently);
    220220
    221221    invalidateDOMEvents(cancelationTime);
  • trunk/Source/WebCore/animation/DeclarativeAnimation.h

    r257138 r258842  
    6464
    6565    void setTimeline(RefPtr<AnimationTimeline>&&) final;
    66     void cancel() final;
     66    void cancel(Silently = Silently::No) final;
    6767
    6868    void tick() override;
  • trunk/Source/WebCore/animation/WebAnimation.cpp

    r258823 r258842  
    603603    // If the animation has no target effect, the target effect end is zero.
    604604    return m_effect ? m_effect->endTime() : 0_s;
    605 }
    606 
    607 void WebAnimation::cancel()
    608 {
    609     cancel(Silently::No);
    610     invalidateEffect();
    611605}
    612606
  • trunk/Source/WebCore/animation/WebAnimation.h

    r258826 r258842  
    9494    FinishedPromise& finished() { return m_finishedPromise.get(); }
    9595
    96     virtual void cancel();
    97     void cancel(Silently);
     96    virtual void cancel(Silently = Silently::No);
    9897    ExceptionOr<void> finish();
    9998    ExceptionOr<void> play();
  • trunk/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp

    r257899 r258842  
    574574                if (timeline) {
    575575                    if (document.renderTreeBeingDestroyed())
    576                         timeline->willDestroyRendererForElement(element);
     576                        timeline->cancelDeclarativeAnimationsForElement(element, WebAnimation::Silently::Yes);
    577577                    else if (teardownType == TeardownType::RendererUpdateCancelingAnimations)
    578                         timeline->cancelDeclarativeAnimationsForElement(element);
     578                        timeline->cancelDeclarativeAnimationsForElement(element, WebAnimation::Silently::No);
    579579                }
    580580                animationController.cancelAnimations(element);
Note: See TracChangeset for help on using the changeset viewer.