Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: b63501380fd5e5bfec4745f97199a597f4eb1015
https://github.com/WebKit/WebKit/commit/b63501380fd5e5bfec4745f97199a597f4eb1015
Author: Ahmad Saleem <[email protected]>
Date: 2026-10-07 (Wed, 07 Oct 2026)
Changed paths:
A
LayoutTests/fast/events/domactivate-dispatched-once-for-click-on-document-expected.txt
A
LayoutTests/fast/events/domactivate-dispatched-once-for-click-on-document.html
M Source/WebCore/dom/EventDispatcher.cpp
Log Message:
-----------
Document's default event handler runs twice for bubbling events targeted at
the document, firing DOMActivate twice
https://bugs.webkit.org/show_bug.cgi?id=326640
rdar://189379133
Reviewed by Ryosuke Niwa.
This patch aligns WebKit with Blink / Chromium.
When the event target is a Document, EventPath appends a Window context
whose node() is that same Document. callDefaultEventHandlersInBubblingOrder()
runs the target's default event handler first, then walks the rest of the
path. When it reaches the Window context it calls the Document's
defaultEventHandler() a second time. Since event.target() == document,
Node::defaultEventHandler() acts again. For a bubbling click this calls
dispatchDOMActivateEvent() twice. Nothing marks the click as default-handled
in between, so DOMActivate fires twice.
This change skips Window contexts in the bubbling default-handler loop. The
first context is never a Window, so the target's handler still runs once.
For targets other than the Document, the skipped call did nothing anyway:
Node::defaultEventHandler() returns early when target != this.
Test: fast/events/domactivate-dispatched-once-for-click-on-document.html
*
LayoutTests/fast/events/domactivate-dispatched-once-for-click-on-document-expected.txt:
Added.
*
LayoutTests/fast/events/domactivate-dispatched-once-for-click-on-document.html:
Added.
* Source/WebCore/dom/EventDispatcher.cpp:
(WebCore::callDefaultEventHandlersInBubblingOrder):
Canonical link: https://commits.webkit.org/323065@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications