Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 503f4731c5e749034a4f5502f7729d00944ba82a
      
https://github.com/WebKit/WebKit/commit/503f4731c5e749034a4f5502f7729d00944ba82a
  Author: Jessica Cheung <[email protected]>
  Date:   2026-02-25 (Wed, 25 Feb 2026)

  Changed paths:
    M Source/WebCore/page/EventHandler.cpp
    M Source/WebKit/UIProcess/mac/WebViewImpl.mm
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm
    M Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm

  Log Message:
  -----------
  dragend event has incorrect coordinates in a nested <iframe>
https://bugs.webkit.org/show_bug.cgi?id=308617
rdar://170750013

Reviewed by Aditya Keerthi.

The dragEnd event coordinates are off by a substantial amount while the
dragStart event coordinates are correct. This is because when WebKit
receives the end point in WebViewImpl::sendDragEndToPage from AppKit,
all WebKit does is convert this point from screen to window coordinates.

The coordinates of clientX/clientY are supposed to be in respect to
the content space of the frame that the events are on. Previously, a
frame (content space) was not specified, so after receiving screen to
window coordinates, WebKit just converts to main frame content coordinates.

To fix this issue, first do an additional step and convert from window 
coordinates
to WKWebView coordinates. Since AppKit gives us the end point, the drag offset 
does
not need to be applied in WebPage::dragEnded.

In EventHandler::dispatchEventToDragSourceElement, use the dragged element's 
frame
to call dispatchDragEvent. This is the frame that has the dragStart and dragEnd 
event.
Now, dispatchDragEvent will be on the correct frame's EventHandler.
>From here, it is then converted from WKWebView
coordinates to the correct frame's content coordinates, yielding the
correct clientX/clientY.

Add an API test that checks for dragEnd coordinates when dragging within the 
nested iframe
as well as dragging to outside the iframe.
Update DragAndDropTests.DragSourceEndedAtCoordinateTransformation as the 
expected coordinates
were previously incorrect.

* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::dispatchEventToDragSourceElement):
* Source/WebKit/UIProcess/mac/WebViewImpl.mm:
(WebKit::WebViewImpl::sendDragEndToPage):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::dragEnded):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm:
(TestWebKitAPI::(SiteIsolation, DragSourceEndedAtCoordinateTransformation)):
* Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm:
(TEST(DragAndDropTests, DragEndEventCoordinatesWithNestedIframes)):

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



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

Reply via email to