⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286642 in webkit


Ignore:
Timestamp:
Dec 7, 2021, 10:28:55 PM (5 years ago)
Author:
graouts@webkit.org
Message:

ActiveDOMObject::suspendIfNeeded() should not be called in the WebAnimation constructor
https://bugs.webkit.org/show_bug.cgi?id=233932

Reviewed by Chris Dumez.

It is not safe to call ActiveDOMObject::suspendIfNeeded() in a constructor. Since WebAnimation has several subclasses
(DeclarativeAnimation, and then CSSTransition and CSSAnimation deriving from DeclarativeAnimation) each with their own
create() methods, we add a new protected initialize() method which refactors code from the WebAnimation constructor
and is called from the two WebAnimation::create() methods.

DeclarativeAnimation already had an initialize method for common setup for the create() methods in CSSTransition and
CSS Animation, so we can simply call WebAnimation::initialize() from DeclarativeAnimation::initialize() and this guarantees
all create() methods for WebAnimation and all of its subclasses are correctly calling ActiveDOMObject::suspendIfNeeded().

  • animation/DeclarativeAnimation.cpp:

(WebCore::DeclarativeAnimation::initialize):

  • animation/DeclarativeAnimation.h:
  • animation/WebAnimation.cpp:

(WebCore::WebAnimation::create):
(WebCore::WebAnimation::initialize):
(WebCore::WebAnimation::WebAnimation):

  • animation/WebAnimation.h:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r286640 r286642  
     12021-12-07  Antoine Quint  <graouts@webkit.org>
     2
     3        ActiveDOMObject::suspendIfNeeded() should not be called in the WebAnimation constructor
     4        https://bugs.webkit.org/show_bug.cgi?id=233932
     5
     6        Reviewed by Chris Dumez.
     7
     8        It is not safe to call ActiveDOMObject::suspendIfNeeded() in a constructor. Since WebAnimation has several subclasses
     9        (DeclarativeAnimation, and then CSSTransition and CSSAnimation deriving from DeclarativeAnimation) each with their own
     10        create() methods, we add a new protected initialize() method which refactors code from the WebAnimation constructor
     11        and is called from the two WebAnimation::create() methods.
     12
     13        DeclarativeAnimation already had an initialize method for common setup for the create() methods in CSSTransition and
     14        CSS Animation, so we can simply call WebAnimation::initialize() from DeclarativeAnimation::initialize() and this guarantees
     15        all create() methods for WebAnimation and all of its subclasses are correctly calling ActiveDOMObject::suspendIfNeeded().
     16
     17        * animation/DeclarativeAnimation.cpp:
     18        (WebCore::DeclarativeAnimation::initialize):
     19        * animation/DeclarativeAnimation.h:
     20        * animation/WebAnimation.cpp:
     21        (WebCore::WebAnimation::create):
     22        (WebCore::WebAnimation::initialize):
     23        (WebCore::WebAnimation::WebAnimation):
     24        * animation/WebAnimation.h:
     25
    1262021-12-07  Wenson Hsieh  <wenson_hsieh@apple.com>
    227
  • trunk/Source/WebCore/animation/DeclarativeAnimation.cpp

    r284693 r286642  
    108108void DeclarativeAnimation::initialize(const RenderStyle* oldStyle, const RenderStyle& newStyle, const Style::ResolutionContext& resolutionContext)
    109109{
     110    WebAnimation::initialize();
     111
    110112    // We need to suspend invalidation of the animation's keyframe effect during its creation
    111113    // as it would otherwise trigger invalidation of the document's style and this would be
  • trunk/Source/WebCore/animation/DeclarativeAnimation.h

    r284693 r286642  
    7676    DeclarativeAnimation(const Styleable&, const Animation&);
    7777
    78     virtual void initialize(const RenderStyle* oldStyle, const RenderStyle& newStyle, const Style::ResolutionContext&);
     78    void initialize(const RenderStyle* oldStyle, const RenderStyle& newStyle, const Style::ResolutionContext&);
    7979    virtual void syncPropertiesWithBackingAnimation();
    8080    // elapsedTime is the animation's current time at the time the event is added and is exposed through the DOM API, timelineTime is the animations'
  • trunk/Source/WebCore/animation/WebAnimation.cpp

    r286544 r286642  
    6767{
    6868    auto result = adoptRef(*new WebAnimation(document));
     69    result->initialize();
    6970    result->setEffect(effect);
    7071    result->setTimeline(&document.timeline());
     
    7879{
    7980    auto result = adoptRef(*new WebAnimation(document));
     81    result->initialize();
    8082    result->setEffect(effect);
    8183    if (timeline)
     
    8587
    8688    return result;
     89}
     90
     91void WebAnimation::initialize()
     92{
     93    suspendIfNeeded();
     94    m_readyPromise->resolve(*this);
    8795}
    8896
     
    92100    , m_finishedPromise(makeUniqueRef<FinishedPromise>(*this, &WebAnimation::finishedPromiseResolve))
    93101{
    94     m_readyPromise->resolve(*this);
    95     suspendIfNeeded();
    96 
    97102    instances().add(this);
    98103}
  • trunk/Source/WebCore/animation/WebAnimation.h

    r284693 r286642  
    156156    explicit WebAnimation(Document&);
    157157
     158    void initialize();
    158159    void enqueueAnimationEvent(Ref<AnimationEventBase>&&);
    159160
Note: See TracChangeset for help on using the changeset viewer.