Changeset 262016 in webkit


Ignore:
Timestamp:
May 21, 2020 11:03:36 AM (4 years ago)
Author:
Chris Dumez
Message:

ASSERTION FAILED: m_wrapper on fast/events/scoped/editing-commands.html
https://bugs.webkit.org/show_bug.cgi?id=209862
<rdar://problem/61164607>

Reviewed by Darin Adler.

Make sure ScopedEventQueue keeps its event targets alive using a GCReachableRef<Node>
so that it keeps alive both the target and its JS wrapper.

No new tests, covered by existing test.

  • dom/ScopedEventQueue.cpp:

(WebCore::ScopedEventQueue::enqueueEvent):
(WebCore::ScopedEventQueue::dispatchEvent const):
(WebCore::ScopedEventQueue::dispatchAllEvents):

  • dom/ScopedEventQueue.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r262015 r262016  
     12020-05-21  Chris Dumez  <cdumez@apple.com>
     2
     3        ASSERTION FAILED: m_wrapper on fast/events/scoped/editing-commands.html
     4        https://bugs.webkit.org/show_bug.cgi?id=209862
     5        <rdar://problem/61164607>
     6
     7        Reviewed by Darin Adler.
     8
     9        Make sure ScopedEventQueue keeps its event targets alive using a GCReachableRef<Node>
     10        so that it keeps alive both the target and its JS wrapper.
     11
     12        No new tests, covered by existing test.
     13
     14        * dom/ScopedEventQueue.cpp:
     15        (WebCore::ScopedEventQueue::enqueueEvent):
     16        (WebCore::ScopedEventQueue::dispatchEvent const):
     17        (WebCore::ScopedEventQueue::dispatchAllEvents):
     18        * dom/ScopedEventQueue.h:
     19
    1202020-05-21  Sihui Liu  <sihui_liu@apple.com>
    221
  • trunk/Source/WebCore/dom/ScopedEventQueue.cpp

    r224740 r262016  
    4747{
    4848    ASSERT(is<Node>(event->target()));
     49    auto& target = downcast<Node>(*event->target());
     50    ScopedEvent scopedEvent = { WTFMove(event), target };
    4951    if (m_scopingLevel)
    50         m_queuedEvents.append(WTFMove(event));
     52        m_queuedEvents.append(WTFMove(scopedEvent));
    5153    else
    52         dispatchEvent(event);
     54        dispatchEvent(scopedEvent);
    5355}
    5456
    55 void ScopedEventQueue::dispatchEvent(Event& event) const
     57void ScopedEventQueue::dispatchEvent(const ScopedEvent& event) const
    5658{
    57     downcast<Node>(*event.target()).dispatchEvent(event);
     59    event.target->dispatchEvent(event.event);
    5860}
    5961
    6062void ScopedEventQueue::dispatchAllEvents()
    6163{
    62     Vector<Ref<Event>> queuedEvents = WTFMove(m_queuedEvents);
     64    auto queuedEvents = std::exchange(m_queuedEvents, { });
    6365    for (auto& queuedEvent : queuedEvents)
    6466        dispatchEvent(queuedEvent);
  • trunk/Source/WebCore/dom/ScopedEventQueue.h

    r219595 r262016  
    3131#pragma once
    3232
     33#include "GCReachableRef.h"
    3334#include <wtf/Forward.h>
    3435#include <wtf/Noncopyable.h>
     
    5152    ~ScopedEventQueue() = delete;
    5253
    53     void dispatchEvent(Event&) const;
     54    struct ScopedEvent {
     55        Ref<Event> event;
     56        GCReachableRef<Node> target;
     57    };
     58
     59    void dispatchEvent(const ScopedEvent&) const;
    5460    void dispatchAllEvents();
    5561    void incrementScopingLevel();
    5662    void decrementScopingLevel();
    5763
    58     Vector<Ref<Event>> m_queuedEvents;
     64    Vector<ScopedEvent> m_queuedEvents;
    5965    unsigned m_scopingLevel { 0 };
    6066
Note: See TracChangeset for help on using the changeset viewer.