Changeset 222554 in webkit


Ignore:
Timestamp:
Sep 27, 2017 8:32:55 AM (7 years ago)
Author:
Antti Koivisto
Message:

REGRESSION (r222040): Crash navigating out of gfycat.com url
https://bugs.webkit.org/show_bug.cgi?id=177531
Source/WebCore:

<rdar://problem/34602601>

Reviewed by Geoff Garen.

Animation structures are normally removed when the render tree is torn down.
However there are cases where we can instantiate animation without creating a renderer
and we need to make sure animations are canceled in these cases too.

CompositeAnimations should also ref the element but that can be done separately.

Test: fast/animation/animation-element-removal.html

  • dom/Element.cpp:

(WebCore::Element::removedFrom):

Ensure animations are canceled when element is removed from the tree.

(WebCore::Element::clearHasPendingResources):
(WebCore::Element::hasCSSAnimation const):
(WebCore::Element::setHasCSSAnimation):
(WebCore::Element::clearHasCSSAnimation):

Add a bit so we don't need to do hash lookups for every removal.

  • dom/Element.h:
  • dom/ElementRareData.h:

(WebCore::ElementRareData::hasCSSAnimation const):
(WebCore::ElementRareData::setHasCSSAnimation):
(WebCore::ElementRareData::ElementRareData):

  • page/animation/CSSAnimationController.cpp:

(WebCore::CSSAnimationControllerPrivate::ensureCompositeAnimation):

Test for the bit.

(WebCore::CSSAnimationControllerPrivate::clear):
(WebCore::CSSAnimationController::cancelAnimations):

LayoutTests:

Reviewed by Geoff Garen.

  • fast/animation/animation-element-removal-expected.txt: Added.
  • fast/animation/animation-element-removal.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r222553 r222554  
     12017-09-27  Antti Koivisto  <antti@apple.com>
     2
     3        REGRESSION (r222040): Crash navigating out of gfycat.com url
     4        https://bugs.webkit.org/show_bug.cgi?id=177531
     5
     6        Reviewed by Geoff Garen.
     7
     8        * fast/animation/animation-element-removal-expected.txt: Added.
     9        * fast/animation/animation-element-removal.html: Added.
     10
    1112017-09-27  Per Arne Vollan  <pvollan@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r222551 r222554  
     12017-09-27  Antti Koivisto  <antti@apple.com>
     2
     3        REGRESSION (r222040): Crash navigating out of gfycat.com url
     4        https://bugs.webkit.org/show_bug.cgi?id=177531
     5        <rdar://problem/34602601>
     6
     7        Reviewed by Geoff Garen.
     8
     9        Animation structures are normally removed when the render tree is torn down.
     10        However there are cases where we can instantiate animation without creating a renderer
     11        and we need to make sure animations are canceled in these cases too.
     12
     13        CompositeAnimations should also ref the element but that can be done separately.
     14
     15        Test: fast/animation/animation-element-removal.html
     16
     17        * dom/Element.cpp:
     18        (WebCore::Element::removedFrom):
     19
     20            Ensure animations are canceled when element is removed from the tree.
     21
     22        (WebCore::Element::clearHasPendingResources):
     23        (WebCore::Element::hasCSSAnimation const):
     24        (WebCore::Element::setHasCSSAnimation):
     25        (WebCore::Element::clearHasCSSAnimation):
     26
     27            Add a bit so we don't need to do hash lookups for every removal.
     28
     29        * dom/Element.h:
     30        * dom/ElementRareData.h:
     31        (WebCore::ElementRareData::hasCSSAnimation const):
     32        (WebCore::ElementRareData::setHasCSSAnimation):
     33        (WebCore::ElementRareData::ElementRareData):
     34        * page/animation/CSSAnimationController.cpp:
     35        (WebCore::CSSAnimationControllerPrivate::ensureCompositeAnimation):
     36
     37            Test for the bit.
     38
     39        (WebCore::CSSAnimationControllerPrivate::clear):
     40        (WebCore::CSSAnimationController::cancelAnimations):
     41
    1422017-09-27  Joanmarie Diggs  <jdiggs@igalia.com>
    243
  • trunk/Source/WebCore/dom/Element.cpp

    r222392 r222554  
    3030#include "Attr.h"
    3131#include "AttributeChangeInvalidation.h"
     32#include "CSSAnimationController.h"
    3233#include "CSSParser.h"
    3334#include "Chrome.h"
     
    17651766        document().accessSVGExtensions().removeElementFromPendingResources(this);
    17661767
     1768    Frame* frame = document().frame();
     1769    if (frame)
     1770        frame->animation().cancelAnimations(*this);
    17671771
    17681772#if PLATFORM(MAC)
    1769     if (Frame* frame = document().frame())
     1773    if (frame)
    17701774        frame->mainFrame().removeLatchingStateForTarget(*this);
    17711775#endif
     
    35323536void Element::clearHasPendingResources()
    35333537{
    3534     ensureElementRareData().setHasPendingResources(false);
     3538    if (!hasRareData())
     3539        return;
     3540    elementRareData()->setHasPendingResources(false);
     3541}
     3542
     3543bool Element::hasCSSAnimation() const
     3544{
     3545    return hasRareData() && elementRareData()->hasCSSAnimation();
     3546}
     3547
     3548void Element::setHasCSSAnimation()
     3549{
     3550    ensureElementRareData().setHasCSSAnimation(true);
     3551}
     3552
     3553void Element::clearHasCSSAnimation()
     3554{
     3555    if (!hasRareData())
     3556        return;
     3557    elementRareData()->setHasCSSAnimation(false);
    35353558}
    35363559
  • trunk/Source/WebCore/dom/Element.h

    r222259 r222554  
    450450    virtual void buildPendingResource() { };
    451451
     452    bool hasCSSAnimation() const;
     453    void setHasCSSAnimation();
     454    void clearHasCSSAnimation();
     455
    452456#if ENABLE(FULLSCREEN_API)
    453457    WEBCORE_EXPORT bool containsFullScreenElement() const;
  • trunk/Source/WebCore/dom/ElementRareData.h

    r222259 r222554  
    107107    bool hasPendingResources() const { return m_hasPendingResources; }
    108108    void setHasPendingResources(bool has) { m_hasPendingResources = has; }
     109
     110    bool hasCSSAnimation() const { return m_hasCSSAnimation; }
     111    void setHasCSSAnimation(bool value) { m_hasCSSAnimation = value; }
    109112
    110113private:
     
    119122#endif
    120123    unsigned m_hasPendingResources : 1;
     124    unsigned m_hasCSSAnimation : 1;
    121125    unsigned m_childrenAffectedByHover : 1;
    122126    unsigned m_childrenAffectedByDrag : 1;
     
    161165#endif
    162166    , m_hasPendingResources(false)
     167    , m_hasCSSAnimation(false)
    163168    , m_childrenAffectedByHover(false)
    164169    , m_childrenAffectedByDrag(false)
  • trunk/Source/WebCore/page/animation/CSSAnimationController.cpp

    r222129 r222554  
    8686CompositeAnimation& CSSAnimationControllerPrivate::ensureCompositeAnimation(Element& element)
    8787{
     88    element.setHasCSSAnimation();
     89
    8890    auto result = m_compositeAnimations.ensure(&element, [&] {
    8991        return CompositeAnimation::create(*this);
     
    98100bool CSSAnimationControllerPrivate::clear(Element& element)
    99101{
     102    ASSERT(element.hasCSSAnimation() == m_compositeAnimations.contains(&element));
     103
     104    if (!element.hasCSSAnimation())
     105        return false;
     106    element.clearHasCSSAnimation();
     107
    100108    auto it = m_compositeAnimations.find(&element);
    101109    if (it == m_compositeAnimations.end())
Note: See TracChangeset for help on using the changeset viewer.