[iOS DnD] Drag caret rect is incorrectly computed when dropping in editable content...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2017 16:08:21 +0000 (16:08 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2017 16:08:21 +0000 (16:08 +0000)
commit89f193dae2188185dd9e53dc3134a3ca4d233220
tree65b8149fb094b8cfdb8223f479c03651d883498b
parente3c1babe88239d59851de0ec1f246bd17bc57e56
[iOS DnD] Drag caret rect is incorrectly computed when dropping in editable content in iframes
https://bugs.webkit.org/show_bug.cgi?id=174017
<rdar://problem/32959782>

Reviewed by Simon Fraser.

Source/WebCore:

We're currenly computing the drag caret rect (for the purposes of presentation at the client layers)
incorrectly, in per-frame document coordinates instead of root view coordinates in the mainframe. This means
drag caret geometry from embedded iframes in the document will show up in the content view with a rect in the
coordinate space of the iframe.

To fix this, we need to convert the drag caret rect to root view coordinates. This patch teaches
DragCaretController to do this, and tweaks WebKit/WebKit2 to use caretRectInRootViewCoordinates.

Test: DataInteractionTests.ExternalSourcePlainTextToIFrame

* editing/FrameSelection.cpp:
(WebCore::DragCaretController::caretRectInRootViewCoordinates):
* editing/FrameSelection.h:

Source/WebKit/mac:

Use root view coordinates when computing the drag caret rect.

* WebView/WebView.mm:
(-[WebView _dataInteractionCaretRect]):

Source/WebKit2:

Send the drag caret rect in root view coordinates over to the UI process.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _dragCaretRect]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

Add basic test plumbing to fetch the current drag caret rect.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::performDragControllerAction):

Tools:

Add a new test verifying that the drag caret is visually contained within the bounds of an iframe. Before these
changes, the caret would appear outside of the iframe.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/contenteditable-in-iframe.html: Added.
* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(checkDragCaretRectIsContainedInRect):
(TestWebKitAPI::TEST):
* TestWebKitAPI/ios/DataInteractionSimulator.h:
* TestWebKitAPI/ios/DataInteractionSimulator.mm:
(-[DataInteractionSimulator _resetSimulatedState]):
(-[DataInteractionSimulator _concludeDataInteractionAndPerformOperationIfNecessary]):
(-[DataInteractionSimulator _advanceProgress]):
(-[DataInteractionSimulator lastKnownDragCaretRect]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218998 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/editing/FrameSelection.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/contenteditable-in-iframe.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm
Tools/TestWebKitAPI/ios/DataInteractionSimulator.h
Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm