Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5e608f7de576d40578115982983ba1b9d4177f67
      
https://github.com/WebKit/WebKit/commit/5e608f7de576d40578115982983ba1b9d4177f67
  Author: Richard Robinson <[email protected]>
  Date:   2026-02-09 (Mon, 09 Feb 2026)

  Changed paths:
    M Source/WebCore/PAL/pal/spi/cocoa/AudioToolboxSPI.h
    M Source/WebCore/page/EventHandler.cpp
    A Source/WebKit/Platform/cocoa/FloatRectCG.swift
    A Source/WebKit/Platform/cocoa/IntRectCG.swift
    M Source/WebKit/Shared/NativeWebMouseEvent.h
    M Source/WebKit/Shared/mac/NativeWebMouseEventMac.mm
    M Source/WebKit/Shared/mac/WebEventFactory.h
    M Source/WebKit/Shared/mac/WebEventFactory.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
    M Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h
    M Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm
    M Source/WebKit/UIProcess/Cocoa/Foundation+Extras.swift
    M Source/WebKit/UIProcess/WebProcessProxy.h
    M Source/WebKit/UIProcess/mac/WKAppKitGestureController.mm
    M Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm
    M Source/WebKit/UIProcess/mac/WKTextSelectionController.swift
    M Source/WebKit/UIProcess/mac/WebViewImpl.h
    M Source/WebKit/UIProcess/mac/WebViewImpl.mm
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj

  Log Message:
  -----------
  [AppKit Gestures] Add support for handling right clicks during text selection
https://bugs.webkit.org/show_bug.cgi?id=307217
rdar://169853467

Reviewed by Aditya Keerthi and Abrar Rahman Protyasha.

Implement the following behavior:
- Click within a selection -> a context menu is presented, and the selection 
remains as a range
- Click and hold on a word -> a context menu is presented, and the selection 
becomes a range
- Click on a word, then click near the same location as the first one -> a 
context menu is presented, and the selection remains a caret
- Click on a word, then click at the location of the caret -> a context menu is 
presented, and the selection remains a caret

* Source/WebCore/PAL/pal/spi/cocoa/AudioToolboxSPI.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _impl]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h:
* Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h:

Additional infrastructure support for Swift-Cxx interop

* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::EventHandler::sendContextMenuEvent):

- Like iOS, disallow a click from changing the selection when it's input source 
is `Automation`, since
the platform will handle changing the selection in this case.
- Also like iOS, don't let right-clicking result in the selection changing to 
select the word that is being right-clicked.

* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/platform/graphics/cg/FloatRectCG.swift: Copied from 
Source/WebKit/UIProcess/Cocoa/Foundation+Extras.swift.
* Source/WebCore/platform/graphics/cg/IntRectCG.swift: Copied from 
Source/WebKit/UIProcess/Cocoa/Foundation+Extras.swift.
* Source/WebKit/UIProcess/Cocoa/Foundation+Extras.swift:
(Comparable.clamped(to:)):
(CGPoint.distance(to:)):
(CGRect.distance(to:)):

- Add convenience extension functions for CGRects and CGPoints.

* Source/WebKit/Shared/NativeWebMouseEvent.h:
* Source/WebKit/Shared/mac/NativeWebMouseEventMac.mm:
(WebKit::NativeWebMouseEvent::NativeWebMouseEvent):
* Source/WebKit/Shared/mac/WebEventFactory.h:
* Source/WebKit/Shared/mac/WebEventFactory.mm:
(WebKit::WebEventFactory::createWebMouseEvent):
* Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm:
(-[WKWebView mouseDown:]):
(-[WKWebView mouseUp:]):
* Source/WebKit/UIProcess/mac/WKAppKitGestureController.mm:
(-[WKAppKitGestureController singleClickGestureRecognized:]):
* Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]):
* Source/WebKit/UIProcess/mac/WebViewImpl.h:
* Source/WebKit/UIProcess/mac/WebViewImpl.mm:
(WebKit::WebViewImpl::acceptsFirstMouse):
(WebKit::WebViewImpl::shouldDelayWindowOrderingForEvent):
(WebKit::WebViewImpl::scheduleMouseDidMoveOverElement):
(WebKit::WebViewImpl::pressureChangeWithEvent):
(WebKit::WebViewImpl::nativeMouseEventHandler):
(WebKit::WebViewImpl::nativeMouseEventHandlerInternal):
(WebKit::WebViewImpl::mouseEntered):
(WebKit::WebViewImpl::mouseExited):
(WebKit::WebViewImpl::otherMouseDown):
(WebKit::WebViewImpl::otherMouseDragged):
(WebKit::WebViewImpl::otherMouseUp):
(WebKit::WebViewImpl::rightMouseDown):
(WebKit::WebViewImpl::rightMouseDragged):
(WebKit::WebViewImpl::rightMouseUp):
(WebKit::WebViewImpl::mouseMovedInternal):
(WebKit::WebViewImpl::mouseDownInternal):
(WebKit::WebViewImpl::mouseUpInternal):
(WebKit::WebViewImpl::mouseDraggedInternal):
(WebKit::WebViewImpl::mouseDown):
(WebKit::WebViewImpl::mouseUp):

- Add more support for propagating the mouse input source throughout event 
handling.

* Source/WebKit/UIProcess/mac/WKTextSelectionController.swift:
(WKTextSelectionController.isTextSelected(at:)):
(WKTextSelectionController.handleClick(at:)):
(WKTextSelectionController.handleClickInternal(at:)):
(WKTextSelectionController.showContextMenu(at:)):

- Implement the context menu behaviors.

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



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

Reply via email to