Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: fe4dd1d95f8cdda17bfc2152e3e2228f11e9a358
https://github.com/WebKit/WebKit/commit/fe4dd1d95f8cdda17bfc2152e3e2228f11e9a358
Author: Richard Robinson <[email protected]>
Date: 2026-02-25 (Wed, 25 Feb 2026)
Changed paths:
M Source/WebCore/dom/DragEvent.cpp
M Source/WebCore/dom/MouseEvent.cpp
M Source/WebCore/dom/MouseEvent.h
M Source/WebCore/dom/PointerEvent.cpp
M Source/WebCore/dom/SimulatedClick.cpp
M Source/WebCore/dom/WheelEvent.cpp
M Source/WebCore/dom/glib/PointerEventGLib.cpp
M Source/WebCore/dom/ios/MouseEventIOS.cpp
M Source/WebCore/dom/ios/PointerEventIOS.cpp
M Source/WebKit/Shared/ContextMenuContextData.cpp
M Source/WebKit/Shared/ContextMenuContextData.h
M Source/WebKit/Shared/ContextMenuContextData.serialization.in
M Source/WebKit/Shared/WebEventConversion.cpp
M Source/WebKit/Shared/WebEventConversion.h
M Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm
M Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm
M Source/WebKitLegacy/mac/WebView/WebPDFView.mm
Log Message:
-----------
[AppKit Gestures] Propagate the input source from an event when presenting a
context menu
https://bugs.webkit.org/show_bug.cgi?id=308621
rdar://171142968
Reviewed by Aditya Keerthi.
When presenting a context menu, include the event's input source when needed.
Since the flow of context menus are somewhat confusing, here is the path of
information travel:
1. An NSEvent is created inside `WKTextSelectionController`, which is then sent
to WebViewImpl
2. A `WebKit::WebMouseEvent` event is created from that NSEvent
3. `WebFrame::handleMouseEvent` is invoked with that WebMouseEvent
4. A `WebCore::PlatformMouseEvent` event is created from the
`WebKit::WebMouseEvent` event.
5. The PlatformMouseEvent then goes through `WebFrame::handleContextMenuEvent`
to `EventHandler::sendContextMenuEvent`
6. `EventHandler::dispatchMouseEvent` is invoked with the an event name of
`contextmenuEvent`, which then invokes `Element::dispatchMouseEvent`
7. In `Element::dispatchMouseEvent`, a `WebCore::MouseEvent` is created from
the PlatformMouseEvent, and stores the platform event within itself, so that it
then can still access the input source.
8. `dispatchPointerEventIfNeeded` is then called, which creates a PointerEvent
from the MouseEvent, discards the MouseEvent, and the pointer event is then
dispatched. The input source is still propogated to the pointer event now.
9. In `Node::defaultEventHandler`, the
`ContextMenuController::handleContextMenuEvent` method is called, which sets
`m_contextMenu` using the event passed into it.
10. A `ContextMenuContextData` is created from the `WebCore::ContextMenuContext`
11. In `WebContextMenuProxyMac::showContextMenuWithItems`, the input source of
`m_context` (which is a `WebKit::ContextMenuContextData`) is accessed.
12. An NSMenu is then presented using AppKit.
* Source/WebCore/dom/DragEvent.cpp:
(WebCore::DragEvent::create):
(WebCore::DragEvent::DragEvent):
* Source/WebCore/dom/MouseEvent.cpp:
(WebCore::MouseEvent::create):
(WebCore::MouseEvent::MouseEvent):
* Source/WebCore/dom/MouseEvent.h:
(WebCore::MouseEvent::create):
(WebCore::MouseEvent::underlyingPlatformEvent const):
* Source/WebCore/dom/PointerEvent.cpp:
(WebCore::PointerEvent::PointerEvent):
* Source/WebCore/dom/SimulatedClick.cpp:
(WebCore::SimulatedMouseEvent::SimulatedMouseEvent):
* Source/WebCore/dom/WheelEvent.cpp:
(WebCore::WheelEvent::WheelEvent):
* Source/WebKit/Shared/ContextMenuContextData.cpp:
(WebKit::m_selectionIsEditable):
(WebKit::ContextMenuContextData::ContextMenuContextData):
* Source/WebKit/Shared/ContextMenuContextData.h:
(WebKit::ContextMenuContextData::inputSource const):
* Source/WebKit/Shared/ContextMenuContextData.serialization.in:
* Source/WebKit/Shared/WebEventConversion.cpp:
(WebKit::kit):
* Source/WebKit/Shared/WebEventConversion.h:
* Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::WebContextMenuProxyMac::showContextMenuWithItems):
* Source/WebKitLegacy/mac/WebView/WebPDFView.mm:
(-[WebPDFView PDFViewWillClickOnLink:withURL:]):
Canonical link: https://commits.webkit.org/308229@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications