Changeset 148072 in webkit


Ignore:
Timestamp:
Apr 9, 2013 6:11:50 PM (11 years ago)
Author:
adamk@chromium.org
Message:

Update Document's event listener type bitfield when adopting a Node
https://bugs.webkit.org/show_bug.cgi?id=114322

Reviewed by Darin Adler.

Source/WebCore:

Without this, moving a Node between documents can silently deactivate
an event listener, if it's one of the types that whose creation is
optimized away by Document::hasListenerType.

An alternate approach would be to simply copy the old document's
bitfield over. It's a tradeoff between making adoption fast and making
the operation of any operation depending on these event types fast.
The latter seems like the right optimization given that adoption
doesn't happen very often.

Test: fast/events/event-listener-moving-documents.html

  • dom/Node.cpp:

(WebCore::Node::didMoveToNewDocument): For each event listener type on the adopted node, update the new document's list of listener types.

LayoutTests:

  • fast/events/event-listener-moving-documents-expected.txt: Added.
  • fast/events/event-listener-moving-documents.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r148070 r148072  
     12013-04-09  Adam Klein  <adamk@chromium.org>
     2
     3        Update Document's event listener type bitfield when adopting a Node
     4        https://bugs.webkit.org/show_bug.cgi?id=114322
     5
     6        Reviewed by Darin Adler.
     7
     8        * fast/events/event-listener-moving-documents-expected.txt: Added.
     9        * fast/events/event-listener-moving-documents.html: Added.
     10
    1112013-04-09  Dongwoo Joshua Im  <dw.im@samsung.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r148071 r148072  
     12013-04-09  Adam Klein  <adamk@chromium.org>
     2
     3        Update Document's event listener type bitfield when adopting a Node
     4        https://bugs.webkit.org/show_bug.cgi?id=114322
     5
     6        Reviewed by Darin Adler.
     7
     8        Without this, moving a Node between documents can silently deactivate
     9        an event listener, if it's one of the types that whose creation is
     10        optimized away by Document::hasListenerType.
     11
     12        An alternate approach would be to simply copy the old document's
     13        bitfield over. It's a tradeoff between making adoption fast and making
     14        the operation of any operation depending on these event types fast.
     15        The latter seems like the right optimization given that adoption
     16        doesn't happen very often.
     17
     18        Test: fast/events/event-listener-moving-documents.html
     19
     20        * dom/Node.cpp:
     21        (WebCore::Node::didMoveToNewDocument): For each event listener type on the adopted node, update the new document's list of listener types.
     22
    1232013-04-09  Dean Jackson  <dino@apple.com>
    224
  • trunk/Source/WebCore/dom/Node.cpp

    r148026 r148072  
    21532153    TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(oldDocument);
    21542154
     2155    if (const EventTargetData* eventTargetData = this->eventTargetData()) {
     2156        const EventListenerMap& listenerMap = eventTargetData->eventListenerMap;
     2157        if (!listenerMap.isEmpty()) {
     2158            Vector<AtomicString> types = listenerMap.eventTypes();
     2159            for (unsigned i = 0; i < types.size(); ++i)
     2160                document()->addListenerTypeIfNeeded(types[i]);
     2161        }
     2162    }
     2163
    21552164    if (AXObjectCache::accessibilityEnabled() && oldDocument)
    21562165        if (AXObjectCache* cache = oldDocument->existingAXObjectCache())
    21572166            cache->remove(this);
    2158 
    2159     // FIXME: Event listener types for this node should be set on the new owner document here.
    21602167
    21612168    const EventListenerVector& wheelListeners = getEventListeners(eventNames().mousewheelEvent);
Note: See TracChangeset for help on using the changeset viewer.