<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[218998] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/218998">218998</a></dd>
<dt>Author</dt> <dd>wenson_hsieh@apple.com</dd>
<dt>Date</dt> <dd>2017-06-30 09:08:21 -0700 (Fri, 30 Jun 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[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]):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreeditingFrameSelectioncpp">trunk/Source/WebCore/editing/FrameSelection.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingFrameSelectionh">trunk/Source/WebCore/editing/FrameSelection.h</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsiosDataInteractionTestsmm">trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPIiosDataInteractionSimulatorh">trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h</a></li>
<li><a href="#trunkToolsTestWebKitAPIiosDataInteractionSimulatormm">trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoacontenteditableiniframehtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/contenteditable-in-iframe.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (218997 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2017-06-30 15:45:59 UTC (rev 218997)
+++ trunk/Source/WebCore/ChangeLog      2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2017-06-30  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [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.
+
+        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:
+
</ins><span class="cx"> 2017-06-30  Sam Weinig  <sam@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         [WebIDL] Replace use of __is_polymorphic with standard std::is_polymorphic<>::value
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingFrameSelectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (218997 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/FrameSelection.cpp  2017-06-30 15:45:59 UTC (rev 218997)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp     2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -101,6 +101,19 @@
</span><span class="cx">     return isRichlyEditablePosition(m_position.deepEquivalent());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+IntRect DragCaretController::caretRectInRootViewCoordinates() const
+{
+    if (!hasCaret())
+        return { };
+
+    if (auto* document = m_position.deepEquivalent().document()) {
+        if (auto* documentView = document->view())
+            return documentView->contentsToRootView(m_position.absoluteCaretBounds());
+    }
+
+    return { };
+}
+
</ins><span class="cx"> static inline bool shouldAlwaysUseDirectionalSelection(Frame* frame)
</span><span class="cx"> {
</span><span class="cx">     return !frame || frame->editor().behavior().shouldConsiderSelectionAsDirectional();
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingFrameSelectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/FrameSelection.h (218997 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/FrameSelection.h    2017-06-30 15:45:59 UTC (rev 218997)
+++ trunk/Source/WebCore/editing/FrameSelection.h       2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -103,6 +103,7 @@
</span><span class="cx">     const VisiblePosition& caretPosition() { return m_position; }
</span><span class="cx">     void setCaretPosition(const VisiblePosition&);
</span><span class="cx">     void clear() { setCaretPosition(VisiblePosition()); }
</span><ins>+    WEBCORE_EXPORT IntRect caretRectInRootViewCoordinates() const;
</ins><span class="cx"> 
</span><span class="cx">     void nodeWillBeRemoved(Node&);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (218997 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2017-06-30 15:45:59 UTC (rev 218997)
+++ trunk/Source/WebKit/mac/ChangeLog   2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2017-06-30  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [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.
+
+        Use root view coordinates when computing the drag caret rect.
+
+        * WebView/WebView.mm:
+        (-[WebView _dataInteractionCaretRect]):
+
</ins><span class="cx"> 2017-06-28  Simon Fraser  <simon.fraser@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Mark the GraphicsContext as accelerated when the WebHTMLView's layer is drawing asynchronously
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (218997 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm       2017-06-30 15:45:59 UTC (rev 218997)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm  2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -1849,7 +1849,7 @@
</span><span class="cx"> - (CGRect)_dataInteractionCaretRect
</span><span class="cx"> {
</span><span class="cx">     if (auto* page = _private->page)
</span><del>-        return page->dragCaretController().caretPosition().absoluteCaretBounds();
</del><ins>+        return page->dragCaretController().caretRectInRootViewCoordinates();
</ins><span class="cx"> 
</span><span class="cx">     return { };
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (218997 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog   2017-06-30 15:45:59 UTC (rev 218997)
+++ trunk/Source/WebKit2/ChangeLog      2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2017-06-30  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [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.
+
+        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):
+
</ins><span class="cx"> 2017-06-30  Youenn Fablet  <youenn@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Support PeerConnectionStates::BundlePolicy::MaxBundle when setting rtc configuration
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (218997 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm    2017-06-30 15:45:59 UTC (rev 218997)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm       2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -5650,6 +5650,15 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (CGRect)_dragCaretRect
+{
+#if ENABLE(DRAG_SUPPORT)
+    return _page->currentDragCaretRect();
+#else
+    return CGRectZero;
+#endif
+}
+
</ins><span class="cx"> - (void)_simulateLongPressActionAtLocation:(CGPoint)location
</span><span class="cx"> {
</span><span class="cx">     [_contentView _simulateLongPressActionAtLocation:location];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (218997 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h      2017-06-30 15:45:59 UTC (rev 218997)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -358,6 +358,8 @@
</span><span class="cx"> - (void)_simulatePrepareForDataInteractionSession:(id)session completion:(dispatch_block_t)completion WK_API_AVAILABLE(ios(WK_IOS_TBA));
</span><span class="cx"> - (void)_simulateLongPressActionAtLocation:(CGPoint)location;
</span><span class="cx"> 
</span><ins>+@property (nonatomic, readonly) CGRect _dragCaretRect WK_API_AVAILABLE(ios(WK_IOS_TBA));
+
</ins><span class="cx"> - (_WKDraggableElementInfo *)_draggableElementAtPosition:(CGPoint)position WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
</span><span class="cx"> - (void)_requestDraggableElementAtPosition:(CGPoint)position completionBlock:(void (^)(_WKDraggableElementInfo *))block WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (218997 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp      2017-06-30 15:45:59 UTC (rev 218997)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -3590,13 +3590,13 @@
</span><span class="cx">     switch (action) {
</span><span class="cx">     case DragControllerActionEntered: {
</span><span class="cx">         DragOperation resolvedDragOperation = m_page->dragController().dragEntered(dragData);
</span><del>-        send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretPosition().absoluteCaretBounds()));
</del><ins>+        send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretRectInRootViewCoordinates()));
</ins><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     }
</span><span class="cx">     case DragControllerActionUpdated: {
</span><span class="cx">         DragOperation resolvedDragOperation = m_page->dragController().dragUpdated(dragData);
</span><del>-        send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretPosition().absoluteCaretBounds()));
</del><ins>+        send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretRectInRootViewCoordinates()));
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case DragControllerActionExited:
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (218997 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2017-06-30 15:45:59 UTC (rev 218997)
+++ trunk/Tools/ChangeLog       2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2017-06-30  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [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.
+
+        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]):
+
</ins><span class="cx"> 2017-06-30  Jonathan Bedard  <jbedard@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Add support for different versions of iOS when loading test expectations
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (218997 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-06-30 15:45:59 UTC (rev 218997)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj   2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -650,6 +650,7 @@
</span><span class="cx">          F47728991E4AE3C1007ABF6A /* full-page-contenteditable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F47728981E4AE3AD007ABF6A /* full-page-contenteditable.html */; };
</span><span class="cx">          F4856CA31E649EA8009D7EE7 /* attachment-element.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4856CA21E6498A8009D7EE7 /* attachment-element.html */; };
</span><span class="cx">          F4A32EC41F05F3850047C544 /* dragstart-change-selection-offscreen.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4A32EC31F05F3780047C544 /* dragstart-change-selection-offscreen.html */; };
</span><ins>+               F4A32ECB1F0643370047C544 /* contenteditable-in-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4A32ECA1F0642F40047C544 /* contenteditable-in-iframe.html */; };
</ins><span class="cx">           F4B825D81EF4DBFB006E417F /* compressed-files.zip in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4B825D61EF4DBD4006E417F /* compressed-files.zip */; };
</span><span class="cx">          F4BFA68E1E4AD08000154298 /* DragAndDropPasteboardTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */; };
</span><span class="cx">          F4C2AB221DD6D95E00E06D5B /* enormous-video-with-sound.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */; };
</span><span class="lines">@@ -732,6 +733,7 @@
</span><span class="cx">                  dstSubfolderSpec = 7;
</span><span class="cx">                  files = (
</span><span class="cx">                          F4A32EC41F05F3850047C544 /* dragstart-change-selection-offscreen.html in Copy Resources */,
</span><ins>+                               F4A32ECB1F0643370047C544 /* contenteditable-in-iframe.html in Copy Resources */,
</ins><span class="cx">                           F469FB241F01804B00401539 /* contenteditable-and-target.html in Copy Resources */,
</span><span class="cx">                          F4B825D81EF4DBFB006E417F /* compressed-files.zip in Copy Resources */,
</span><span class="cx">                          F41AB99F1EF4696B0083FA08 /* autofocus-contenteditable.html in Copy Resources */,
</span><span class="lines">@@ -1623,6 +1625,7 @@
</span><span class="cx">          F47D30ED1ED28A6C000482E1 /* gif-and-file-input.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "gif-and-file-input.html"; sourceTree = "<group>"; };
</span><span class="cx">          F4856CA21E6498A8009D7EE7 /* attachment-element.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "attachment-element.html"; sourceTree = "<group>"; };
</span><span class="cx">          F4A32EC31F05F3780047C544 /* dragstart-change-selection-offscreen.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "dragstart-change-selection-offscreen.html"; sourceTree = "<group>"; };
</span><ins>+               F4A32ECA1F0642F40047C544 /* contenteditable-in-iframe.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "contenteditable-in-iframe.html"; sourceTree = "<group>"; };
</ins><span class="cx">           F4B825D61EF4DBD4006E417F /* compressed-files.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "compressed-files.zip"; sourceTree = "<group>"; };
</span><span class="cx">          F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropPasteboardTests.mm; sourceTree = "<group>"; };
</span><span class="cx">          F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "enormous-video-with-sound.html"; sourceTree = "<group>"; };
</span><span class="lines">@@ -2022,6 +2025,7 @@
</span><span class="cx">                          F41AB9971EF4692C0083FA08 /* background-image-link-and-input.html */,
</span><span class="cx">                          F469FB231F01803500401539 /* contenteditable-and-target.html */,
</span><span class="cx">                          F41AB99C1EF4692C0083FA08 /* contenteditable-and-textarea.html */,
</span><ins>+                               F4A32ECA1F0642F40047C544 /* contenteditable-in-iframe.html */,
</ins><span class="cx">                           F41AB99E1EF4692C0083FA08 /* div-and-large-image.html */,
</span><span class="cx">                          F4A32EC31F05F3780047C544 /* dragstart-change-selection-offscreen.html */,
</span><span class="cx">                          F41AB99B1EF4692C0083FA08 /* file-uploading.html */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoacontenteditableiniframehtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/contenteditable-in-iframe.html (0 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/contenteditable-in-iframe.html                              (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/contenteditable-in-iframe.html 2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<meta name="viewport" content="width=device-width">
+<style>
+body {
+    width: 100%;
+    height: 100%;
+    margin: 0;
+    position: absolute;
+}
+#container {
+    width: calc(100% - 100px);
+    height: calc(100% - 100px);
+    margin: 50px;
+}
+#editor {
+    width: 100%;
+    height: 100%;
+}
+</style>
+<div id="container"><iframe id="editor" src="data:text/html,<body%20contenteditable%20style='width:%20100%;%20height:%20100%;%20margin:%200;'>"></iframe></div>
+</html>
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsiosDataInteractionTestsmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm (218997 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm      2017-06-30 15:45:59 UTC (rev 218997)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm 2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -132,6 +132,14 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void checkDragCaretRectIsContainedInRect(CGRect caretRect, CGRect containerRect)
+{
+    BOOL contained = CGRectContainsRect(containerRect, caretRect);
+    EXPECT_TRUE(contained);
+    if (!contained)
+        NSLog(@"Expected caret rect: %@ to fit within container rect: %@", NSStringFromCGRect(caretRect), NSStringFromCGRect(containerRect));
+}
+
</ins><span class="cx"> namespace TestWebKitAPI {
</span><span class="cx"> 
</span><span class="cx"> TEST(DataInteractionTests, ImageToContentEditable)
</span><span class="lines">@@ -434,6 +442,25 @@
</span><span class="cx">     checkSelectionRectsWithLogging(@[ ], [dataInteractionSimulator finalSelectionRects]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TEST(DataInteractionTests, ExternalSourcePlainTextToIFrame)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    [webView synchronouslyLoadTestPageNamed:@"contenteditable-in-iframe"];
+
+    auto itemProvider = adoptNS([[UIItemProvider alloc] init]);
+    [itemProvider registerObject:@"Hello world" visibility:UIItemProviderRepresentationOptionsVisibilityAll];
+
+    auto simulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
+    [simulator setExternalItemProviders:@[ itemProvider.get() ]];
+    [simulator runFrom:CGPointMake(0, 0) to:CGPointMake(160, 250)];
+
+    auto containerLeft = [webView stringByEvaluatingJavaScript:@"container.getBoundingClientRect().left"].floatValue;
+    auto containerTop = [webView stringByEvaluatingJavaScript:@"container.getBoundingClientRect().top"].floatValue;
+    auto containerWidth = [webView stringByEvaluatingJavaScript:@"container.getBoundingClientRect().width"].floatValue;
+    auto containerHeight = [webView stringByEvaluatingJavaScript:@"container.getBoundingClientRect().height"].floatValue;
+    checkDragCaretRectIsContainedInRect([simulator lastKnownDragCaretRect], CGRectMake(containerLeft, containerTop, containerWidth, containerHeight));
+}
+
</ins><span class="cx"> TEST(DataInteractionTests, ExternalSourceJSONToFileInput)
</span><span class="cx"> {
</span><span class="cx">     RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIiosDataInteractionSimulatorh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h (218997 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h 2017-06-30 15:45:59 UTC (rev 218997)
+++ trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h    2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -60,6 +60,7 @@
</span><span class="cx">     RetainPtr<NSArray *> _finalSelectionRects;
</span><span class="cx">     CGPoint _startLocation;
</span><span class="cx">     CGPoint _endLocation;
</span><ins>+    CGRect _lastKnownDragCaretRect;
</ins><span class="cx"> 
</span><span class="cx">     bool _isDoneWaitingForInputSession;
</span><span class="cx">     BOOL _shouldPerformOperation;
</span><span class="lines">@@ -85,6 +86,7 @@
</span><span class="cx"> @property (nonatomic, readonly) NSArray *observedEventNames;
</span><span class="cx"> @property (nonatomic, readonly) NSArray *finalSelectionRects;
</span><span class="cx"> @property (nonatomic, readonly) DataInteractionPhase phase;
</span><ins>+@property (nonatomic, readonly) CGRect lastKnownDragCaretRect;
</ins><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIiosDataInteractionSimulatormm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm (218997 => 218998)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm        2017-06-30 15:45:59 UTC (rev 218997)
+++ trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm   2017-06-30 16:08:21 UTC (rev 218998)
</span><span class="lines">@@ -291,6 +291,7 @@
</span><span class="cx">     _dataInteractionSession = nil;
</span><span class="cx">     _dataOperationSession = nil;
</span><span class="cx">     _shouldPerformOperation = NO;
</span><ins>+    _lastKnownDragCaretRect = CGRectZero;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (NSArray *)observedEventNames
</span><span class="lines">@@ -360,6 +361,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_concludeDataInteractionAndPerformOperationIfNecessary
</span><span class="cx"> {
</span><ins>+    _lastKnownDragCaretRect = [_webView _dragCaretRect];
</ins><span class="cx">     if (_shouldPerformOperation) {
</span><span class="cx">         [_webView _simulateDataInteractionPerformOperation:_dataOperationSession.get()];
</span><span class="cx">         _phase = DataInteractionPerforming;
</span><span class="lines">@@ -376,6 +378,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_advanceProgress
</span><span class="cx"> {
</span><ins>+    _lastKnownDragCaretRect = [_webView _dragCaretRect];
</ins><span class="cx">     _currentProgress += progressIncrementStep;
</span><span class="cx">     CGPoint locationInWindow = self._currentLocation;
</span><span class="cx">     [_dataInteractionSession setMockLocationInWindow:locationInWindow];
</span><span class="lines">@@ -468,6 +471,11 @@
</span><span class="cx">     return _phase;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (CGRect)lastKnownDragCaretRect
+{
+    return _lastKnownDragCaretRect;
+}
+
</ins><span class="cx"> - (void)waitForInputSession
</span><span class="cx"> {
</span><span class="cx">     _isDoneWaitingForInputSession = false;
</span></span></pre>
</div>
</div>

</body>
</html>