Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 61d3e0bbf908e112ce727d84fb266a6c534c13eb
https://github.com/WebKit/WebKit/commit/61d3e0bbf908e112ce727d84fb266a6c534c13eb
Author: Jessica Cheung <[email protected]>
Date: 2026-02-26 (Thu, 26 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:
-----------
Re-land dragend event has incorrect coordinates in a nested <iframe>
https://bugs.webkit.org/show_bug.cgi?id=308617
rdar://170750013
Reviewed by Aditya Keerthi.
Re-land the work reverted in 308240@main with fix. The original commit
accessed draggedElement() before checking
shouldDispatchEventsToDragSourceElement(), resulting in crashes.
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.
Canonical link: https://commits.webkit.org/308287@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications