Changeset 260705 in webkit


Ignore:
Timestamp:
Apr 25, 2020 9:08:46 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

[Web Animations] KeyframeEffect should ensure its target remains alive
https://bugs.webkit.org/show_bug.cgi?id=211019

Patch by Antoine Quint <Antoine Quint> on 2020-04-25
Reviewed by Daniel Bates.

Source/WebCore:

Test: webanimations/keyframe-effect-target-kept-alive.html

Make KeyframeEffect::m_target a RefPtr so that assigning an element to effect.target guarantees that element
is kept alive even if there are no other references to that element.

  • animation/KeyframeEffect.cpp:

(WebCore::KeyframeEffect::KeyframeEffect):
(WebCore::KeyframeEffect::setTarget):

  • animation/KeyframeEffect.h:

LayoutTests:

Add a test that creates a KeyframeEffect targeting an element with no other reference and trigger
garbage collection to check that the effect's target exists. This test would have failed prior to
this patch's code changes.

  • webanimations/keyframe-effect-target-kept-alive-expected.txt: Added.
  • webanimations/keyframe-effect-target-kept-alive.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r260701 r260705  
     12020-04-25  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] KeyframeEffect should ensure its target remains alive
     4        https://bugs.webkit.org/show_bug.cgi?id=211019
     5
     6        Reviewed by Daniel Bates.
     7
     8        Add a test that creates a KeyframeEffect targeting an element with no other reference and trigger
     9        garbage collection to check that the effect's target exists. This test would have failed prior to
     10        this patch's code changes.
     11
     12        * webanimations/keyframe-effect-target-kept-alive-expected.txt: Added.
     13        * webanimations/keyframe-effect-target-kept-alive.html: Added.
     14
    1152020-04-25  Diego Pino Garcia  <dpino@igalia.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r260703 r260705  
     12020-04-25  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] KeyframeEffect should ensure its target remains alive
     4        https://bugs.webkit.org/show_bug.cgi?id=211019
     5
     6        Reviewed by Daniel Bates.
     7
     8        Test: webanimations/keyframe-effect-target-kept-alive.html
     9
     10        Make KeyframeEffect::m_target a RefPtr so that assigning an element to effect.target guarantees that element
     11        is kept alive even if there are no other references to that element.
     12
     13        * animation/KeyframeEffect.cpp:
     14        (WebCore::KeyframeEffect::KeyframeEffect):
     15        (WebCore::KeyframeEffect::setTarget):
     16        * animation/KeyframeEffect.h:
     17
    1182020-04-25  Zalan Bujtas  <zalan@apple.com>
    219
  • trunk/Source/WebCore/animation/KeyframeEffect.cpp

    r260671 r260705  
    529529
    530530KeyframeEffect::KeyframeEffect(Element* target, PseudoId pseudoId)
    531     : m_target(makeWeakPtr(target))
     531    : m_target(target)
    532532    , m_pseudoId(pseudoId)
    533533{
     
    11221122void KeyframeEffect::setTarget(RefPtr<Element>&& newTarget)
    11231123{
    1124     if (m_target.get() == newTarget.get())
     1124    if (m_target == newTarget)
    11251125        return;
    11261126
    11271127    auto* previousTargetElementOrPseudoElement = targetElementOrPseudoElement();
    1128     m_target = makeWeakPtr(newTarget.get());
     1128    m_target = WTFMove(newTarget);
    11291129    didChangeTargetElementOrPseudoElement(previousTargetElementOrPseudoElement);
    11301130}
  • trunk/Source/WebCore/animation/KeyframeEffect.h

    r260671 r260705  
    203203    Vector<ParsedKeyframe> m_parsedKeyframes;
    204204    Vector<AcceleratedAction> m_pendingAcceleratedActions;
    205     WeakPtr<Element> m_target;
     205    RefPtr<Element> m_target;
    206206    PseudoId m_pseudoId { PseudoId::None };
    207207    std::unique_ptr<const RenderStyle> m_unanimatedStyle;
Note: See TracChangeset for help on using the changeset viewer.