[webkit-changes] [WebKit/WebKit] d25481: Make event handler house keeping in moveNodeToNewD...

Ryosuke Niwa noreply at github.com
Tue Jan 9 18:26:51 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d2548129f1780abac960e3a93eaa547ba11073b6
      https://github.com/WebKit/WebKit/commit/d2548129f1780abac960e3a93eaa547ba11073b6
  Author: Ryosuke Niwa <rniwa at webkit.org>
  Date:   2024-01-09 (Tue, 09 Jan 2024)

  Changed paths:
    M Source/WebCore/accessibility/ios/AccessibilityObjectIOS.mm
    M Source/WebCore/dom/EventListenerMap.h
    M Source/WebCore/dom/EventTarget.h
    M Source/WebCore/dom/Node.cpp
    M Source/WebCore/dom/make-event-names.py

  Log Message:
  -----------
  Make event handler house keeping in moveNodeToNewDocument more efficient
https://bugs.webkit.org/show_bug.cgi?id=267264

Reviewed by Chris Dumez.

Prior to this PR, the code to update the number of wheel, touch, and gesture events in
Node::moveNodeToNewDocument were inefficient because it traversed EventListenerMap for
each distinct wheel, touch, and gesture event type. This is O(kn) where k is the total
number of event types, and n is the total number of event listeners on a given Node.

This PR reimplements the same house keeping in O(n): It enumerates types of event
listeners added on "this" event target and their count, and uses this information to
count the total number of wheel, touch, and gesture events in a single iteration over
EventListenerMap.

* Source/WebCore/accessibility/ios/AccessibilityObjectIOS.mm:
(WebCore::AccessibilityObject::hasTouchEventListener const):
* Source/WebCore/dom/EventListenerMap.h:
(WebCore::EventListenerMap::containsMatchingEventListener):
* Source/WebCore/dom/EventTarget.h:
(WebCore::EventTarget::enumerateEventListenerTypes):
(WebCore::EventTarget::containsMatchingEventListener):
* Source/WebCore/dom/Node.cpp:
(WebCore::Node::moveNodeToNewDocument):
* Source/WebCore/dom/make-event-names.py:

Canonical link: https://commits.webkit.org/272834@main




More information about the webkit-changes mailing list