Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0e3ecbee7ab1e0aac1be7f61b27174787a049722
      
https://github.com/WebKit/WebKit/commit/0e3ecbee7ab1e0aac1be7f61b27174787a049722
  Author: Simon Fraser <[email protected]>
  Date:   2026-06-29 (Mon, 29 Jun 2026)

  Changed paths:
    M Source/WebCore/inspector/agents/InspectorPageAgent.cpp
    M Source/WebCore/page/ContextMenuController.cpp
    M Source/WebCore/page/EventHandler.cpp
    M Source/WebCore/page/FrameSnapshotting.cpp
    M Source/WebCore/page/FrameSnapshotting.h
    M Source/WebCore/platform/DragImage.cpp
    M Source/WebCore/rendering/RenderObject.cpp
    M Source/WebCore/rendering/RenderObject.h
    M Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp
    M Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp
    M Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Tools/TestWebKitAPI/Resources/cocoa/DataTransfer-setDragImage.html
    M Tools/TestWebKitAPI/Resources/cocoa/node-snapshotting.html
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebViewSnapshot.mm
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/ios/DragAndDropTestsIOS.mm
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/mac/DragAndDropTestsMac.mm

  Log Message:
  -----------
  Drag image of DOM elements with CSS transforms aren't rendered correctly
https://bugs.webkit.org/show_bug.cgi?id=318055
rdar://99614217

Reviewed by Wenson Hsieh and Abrar Rahman Protyasha.

Fix node snapshots to work correctly for elements affected by CSS transforms.

`RenderObject::subtreePaintRootRect()` (renamed from `paintingRootRect`) takes
an argument specifying whether to respect transforms, and uses that to compute
absolute rects as appropriate.

`snapshotNode()` then calls `subtreePaintRootRect(..., RespectTransforms::Yes)`,
but also now returns the paintingRect and elementRect computed taking transforms
into account. This means that `createDragImageForImage()` no longer needs to
compute the rects itself.

The final part of the fix in `EventHandler::handleDrag()` ensures that the 
offset
of the drag image from the cursor is correct; `absoluteBoundingBoxRect()` 
respects
transforms.

Tests: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebViewSnapshot.mm
       Tools/TestWebKitAPI/Tests/WebKit/WKWebView/ios/DragAndDropTestsIOS.mm
       Tools/TestWebKitAPI/Tests/WebKit/WKWebView/mac/DragAndDropTestsMac.mm

* Source/WebCore/inspector/agents/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::snapshotNode):
(WebCore::InspectorPageAgent::snapshotRect):
* Source/WebCore/page/ContextMenuController.cpp:
(WebCore::prepareContextForQRCode):
* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::handleDrag):
* Source/WebCore/page/FrameSnapshotting.cpp:
(WebCore::snapshotNode):
* Source/WebCore/page/FrameSnapshotting.h:
* Source/WebCore/platform/DragImage.cpp:
(WebCore::createDragImageForImage):
* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::RenderObject::addAbsoluteRectForLayer):
(WebCore::RenderObject::subtreePaintRootRect):
(WebCore::RenderObject::paintingRootRect): Deleted.
* Source/WebCore/rendering/RenderObject.h:
* Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::snapshotElementRectForScreenshot):
* Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp:
(WebKit::screenRectOfContents):
* Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
(WebKit::InjectedBundleNodeHandle::renderedImage):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::shareableBitmapSnapshotForNode):
(WebKit::WebPage::snapshotNode):
* Tools/TestWebKitAPI/Resources/cocoa/DataTransfer-setDragImage.html:
* Tools/TestWebKitAPI/Resources/cocoa/node-snapshotting.html:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebViewSnapshot.mm:
(TestWebKitAPI::TEST(WKWebView, SnapshotNodeWithTransform)):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/ios/DragAndDropTestsIOS.mm:
(TestWebKitAPI::TEST(DragAndDropTests, 
DragLiftPreviewDataTransferSetDragImage)):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/mac/DragAndDropTestsMac.mm:
(TEST(DragAndDropTests, DragPreviewOriginForTransformedElement)):

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



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

Reply via email to