Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 877e4daa3bc718be3371dc74a756a6801b4d564f
      
https://github.com/WebKit/WebKit/commit/877e4daa3bc718be3371dc74a756a6801b4d564f
  Author: Wenson Hsieh <[email protected]>
  Date:   2026-01-06 (Tue, 06 Jan 2026)

  Changed paths:
    M Source/WebCore/page/DragController.cpp
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/mac/WebViewImpl.mm
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    A Tools/TestWebKitAPI/Tests/WebKitCocoa/image-in-scrolled-subframe.html
    M Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm

  Log Message:
  -----------
  REGRESSION (301306@main): Drag image location is incorrect when dragging 
images in non-remote subframes
https://bugs.webkit.org/show_bug.cgi?id=305012
rdar://165119210

Reviewed by Abrar Rahman Protyasha.

After the changes in 301306@main, dragging an image in a subframe fails in the 
case where either
site isolation is disabled, or site isolation is enabled but the image is in a 
same-origin frame.
This is due to multiple bugs, regarding how the drag image location is 
determined:

1.  The `rootFrameID` passed into `doSystemDrag` is currently the source 
`Frame` where the drag is
    initiated, as opposed to being the root frame of the drag initator.

2.  `dragLocationInWindowCoordinates` is being passed into 
`convertPointToMainFrameCoordinates`.
    The former is in window coordinates (which is incorrectly computed in the 
site isolation remote
    frame case), and the latter expects coordinates in the content coordinate 
space of the frame
    corresponding to the frame ID.

3.  `convertPointToMainFrameCoordinates` itself returns a point in different 
coordinate spaces,
    depending on whether site isolation is enabled or disabled. When disabled, 
the resulting
    coordinates are in main frame content coordinates. When enabled, the 
resulting coordinates
    appear to be in root view coordinates (relative to the mainframe). It's 
unclear in the first
    place whether "mainframe coordinates" here was intended to refer to content 
coordinates in the
    main frame, or root view coordinates in the main frame.

To limit risk for now, this patch only fixes (1), which is sufficient to ensure 
that the drag image
location is correct in the following 3 scenarios:

a. Site isolation disabled: dragging an image in any subframe.
b. Site isolation enabled: dragging an image in a remote subframe under the 
main frame.
c. Site isolation enabled: dragging an image in a local subframe under the main 
frame.

We leave (2) and (3) as FIXMEs for now.

Tests: DragAndDropTests.DragLocationForImageInScrolledSubframe

* Source/WebCore/page/DragController.cpp:
(WebCore::DragController::doImageDrag):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::convertPointToMainFrameCoordinates):
* Source/WebKit/UIProcess/mac/WebViewImpl.mm:
(WebKit::WebViewImpl::startDrag):
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/image-in-scrolled-subframe.html: Added.
* Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm:
(TEST(DragAndDropTests, DragLocationForImageInScrolledSubframe)):

Add a test to exercise this fix. The drag location is (incorrectly) far outside 
the bounds of the
view without these changes.

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



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

Reply via email to