Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a4ef371d3c8076fb1c795567e23acb60f70bb670
      
https://github.com/WebKit/WebKit/commit/a4ef371d3c8076fb1c795567e23acb60f70bb670
  Author: Richard Robinson <[email protected]>
  Date:   2026-09-18 (Fri, 18 Sep 2026)

  Changed paths:
    M Source/WebCore/page/EventHandler.cpp
    M Source/WebCore/page/EventHandler.h
    M Source/WebKit/UIProcess/mac/AppKitGestures/WKAppKitGestureController.mm
    M Source/WebKit/UIProcess/mac/AppKitGestures/WKAppKitGestureController.swift
    M Tools/TestWebKitAPI/Tests/WebKit/WebPage/AppKit Gesture 
Tests/BasicAppKitGesturesTests.swift

  Log Message:
  -----------
  [AppKit Gestures] Context menu on link doesn't appear until a click is 
released
https://bugs.webkit.org/show_bug.cgi?id=324215
rdar://183536630

Reviewed by Wenson Hsieh.

- Start the right click synthesis on Began instead of Ended, so the menu comes 
up while the button is
still held rather than waiting for the release.

- Keep the pending drag intact across that synthesized right click. The press 
that raised the menu may
still become a drag, but `EventHandler::sendContextMenuEvent` clears 
`m_mousePressed` unconditionally,
which drops every `mouseDragged` that follows. Usually AppKit replays the event 
when it dismisses the
menu in favor of drag and drop and that works around it, but when no menu is 
shown at all, like when a page
that cancels `contextmenu`, nothing is replayed and the press ends up doing 
nothing at all.

- Opt-out the pan GR from being allowed during drag-and-drop to prevent it from 
winning over the drag gesture and to
stop it from getting "replayed".

- Adjust the image analysis deferral logic so that it works properly even in 
the case where the gestures
are "replayed", by storing the outcome of the most recent completed analysis 
alongside the element it
was for and acting accordingly.

Test: Tools/TestWebKitAPI/Tests/WebKit/WebPage/AppKit Gesture 
Tests/BasicAppKitGesturesTests.swift

* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::EventHandler::isSynthesizedContextMenuPressDuringPendingDrag const):
(WebCore::EventHandler::pendingDragStateToPreserveAcross const):
(WebCore::EventHandler::restorePendingDragState):
(WebCore::EventHandler::sendContextMenuEvent):
* Source/WebCore/page/EventHandler.h:
* Source/WebKit/UIProcess/mac/AppKitGestures/WKAppKitGestureController.mm:
(WebKit::CompletedImageAnalysis::outcomeFor const):
(-[WKAppKitGestureController secondaryClickGestureRecognized:]):
(-[WKAppKitGestureController imageAnalysisGestureRecognized:]):
(-[WKAppKitGestureController _outcome:preventsGesturesDeferredBy:]):
(-[WKAppKitGestureController _resolveImageAnalysisDeferralsWithOutcome:]):
(-[WKAppKitGestureController 
deferringGestureRecognizer:shouldDeferGesturesForEventThatWillBeginAction:]):
(-[WKAppKitGestureController didCommitLoadForMainFrame]):
(-[WKAppKitGestureController reset]):
* Source/WebKit/UIProcess/mac/AppKitGestures/WKAppKitGestureController.swift:
(WKPanGestureRecognizer.wk_allowedDuringDnDRestrictions):
* Tools/TestWebKitAPI/Tests/WebKit/WebPage/AppKit Gesture 
Tests/BasicAppKitGesturesTests.swift:
(AppKitGesturesTests.pressAndHoldOnLinkOpensContextMenuWithoutReleasingClick):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to