Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 39fbd5d520cf8db87522a3a24c94ce3561c3d1ea
      
https://github.com/WebKit/WebKit/commit/39fbd5d520cf8db87522a3a24c94ce3561c3d1ea
  Author: Abrar Rahman Protyasha <[email protected]>
  Date:   2026-07-15 (Wed, 15 Jul 2026)

  Changed paths:
    M Source/WTF/wtf/PlatformEnableCocoa.h
    M Source/WebCore/page/DragController.cpp
    M Source/WebCore/platform/DragItem.h
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
    M Source/WebKit/UIProcess/API/mac/WKView.mm
    M Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm
    M Source/WebKit/UIProcess/mac/WebViewImpl.h
    M Source/WebKit/UIProcess/mac/WebViewImpl.mm
    M Tools/TestWebKitAPI/Helpers/cocoa/DragAndDropSimulator.h
    M Tools/TestWebKitAPI/Helpers/mac/DragAndDropSimulatorMac.mm
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/mac/DragAndDropTestsMac.mm

  Log Message:
  -----------
  [macOS] Add a drag-source customization SPI to WKUIDelegatePrivate
https://bugs.webkit.org/show_bug.cgi?id=319458
rdar://176573401

Reviewed by Richard Robinson.

In this patch, we add a macOS-only WKUIDelegatePrivate interface that
lets a client customize a WebKit-initiated drag while WebKit keeps
ownership of the NSDraggingSource, session, and gesture. This is the
macOS analogue for the UIDragSession-based delegate methods on iOS.

WebViewImpl::startDrag() consults the draggingItem: method before
committing to its own item, while dragSourceOperationMask and the
draggingSession* methods simply forward to the namesake delegate methods.

We also teach DragAndDropSimulator about these new delegate methods to
get test coverage.

Tests: DragAndDropTests.DraggingItemsForDraggingItemReplacesDragData
       
DragAndDropTests.DraggingItemsForDraggingItemFallsBackWhenDelegateDeclines
       DragAndDropTests.DraggingItemForDraggingItemUsesDragOriginLocation
       DragAndDropTests.SourceOperationMaskDefaultsWithinApplication
       DragAndDropTests.SourceOperationMaskOutsideApplicationDefaultsToCopy
       DragAndDropTests.SourceOperationMaskDelegateOverride
       DragAndDropTests.DraggingSessionLifecycleIsForwardedToDelegate
       
DragAndDropTests.DraggingItemsForDraggingItemClearsPromisedImageStateAfterSubstitution

* Source/WTF/wtf/PlatformEnableCocoa.h:
* Source/WebCore/page/DragController.cpp:
(WebCore::DragController::startDrag):
* Source/WebCore/platform/DragItem.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
* Source/WebKit/UIProcess/API/mac/WKView.mm:
(-[WKView _web_draggingItemsForDraggingItem:atLocation:completionHandler:]):
(-[WKView _web_dragSourceOperationMaskForDraggingContext:defaultMask:]):
(-[WKView _web_draggingSession:willBeginAtPoint:]):
(-[WKView _web_draggingSession:endedAtPoint:operation:]):
* Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm:
(-[WKWebView draggingSession:willBeginAtPoint:]):
(-[WKWebView _web_draggingItemsForDraggingItem:atLocation:completionHandler:]):
(-[WKWebView _web_dragSourceOperationMaskForDraggingContext:defaultMask:]):
(-[WKWebView _web_draggingSession:willBeginAtPoint:]):
(-[WKWebView _web_draggingSession:endedAtPoint:operation:]):
* Source/WebKit/UIProcess/mac/WebViewImpl.h:
* Source/WebKit/UIProcess/mac/WebViewImpl.mm:
(WebKit::WebViewImpl::dragSourceOperationMask):
(WebKit::WebViewImpl::draggingSessionWillBegin):
(WebKit::WebViewImpl::draggingSessionEnded):
(WebKit::WebViewImpl::startDrag):
* Tools/TestWebKitAPI/Helpers/cocoa/DragAndDropSimulator.h:
* Tools/TestWebKitAPI/Helpers/mac/DragAndDropSimulatorMac.mm:
(-[DragAndDropSimulator initWithWebViewFrame:configuration:]):
(-[DragAndDropSimulator beginDraggingSessionInWebView:withItems:source:]):
(-[DragAndDropSimulator draggingItemsForDraggingItemBlock]):
(-[DragAndDropSimulator setDraggingItemsForDraggingItemBlock:]):
(-[DragAndDropSimulator sourceOperationMaskBlock]):
(-[DragAndDropSimulator setSourceOperationMaskBlock:]):
(-[DragAndDropSimulator 
_webView:draggingItemsForDraggingItem:atLocation:completionHandler:]):
(-[DragAndDropSimulator 
_webView:sourceOperationMaskForDraggingContext:defaultOperationMask:]):
(-[DragAndDropSimulator _webView:draggingSession:willBeginAtPoint:]):
(-[DragAndDropSimulator _webView:draggingSession:endedAtPoint:operation:]):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/mac/DragAndDropTestsMac.mm:
(TEST(DragAndDropTests, DraggingItemsForDraggingItemReplacesDragData)):
(TEST(DragAndDropTests, 
DraggingItemsForDraggingItemFallsBackWhenDelegateDeclines)):
(TEST(DragAndDropTests, DraggingItemForDraggingItemUsesDragOriginLocation)):
(TEST(DragAndDropTests, SourceOperationMaskDefaultsWithinApplication)):
(TEST(DragAndDropTests, SourceOperationMaskOutsideApplicationDefaultsToCopy)):
(TEST(DragAndDropTests, SourceOperationMaskDelegateOverride)):
(TEST(DragAndDropTests, DraggingSessionLifecycleIsForwardedToDelegate)):
(TEST(DragAndDropTests, 
DraggingItemsForDraggingItemClearsPromisedImageStateAfterSubstitution)):

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



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

Reply via email to