<!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>[245803] 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/245803">245803</a></dd>
<dt>Author</dt> <dd>wenson_hsieh@apple.com</dd>
<dt>Date</dt> <dd>2019-05-27 18:03:10 -0700 (Mon, 27 May 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS] Dropping in an editable element should result in a ranged selection
https://bugs.webkit.org/show_bug.cgi?id=198267
<rdar://problem/51145977>

Reviewed by Tim Horton.

Source/WebKit:

When drag and drop was first implemented for iOS in iOS 11, selection behavior when dropping into editable
elements matched that of macOS, by leaving the inserted content selected after performing the drop. However, in
other parts of the platform (e.g. Notes), both the keyboard and selection views are not shown after a drop.

Instead of matching macOS behavior, WebKit on iOS should match the rest of the platform. This is a little
tricky, since we use the selection range after a drop to create a TextIndicator snapshot when creating a drag
preview. To resolve this, we refactor some of the logic introduced in <a href="http://trac.webkit.org/projects/webkit/changeset/245778">r245778</a> to remember the DOM range to
snapshot before collapsing the range to the end of the inserted content.

Tested by adjusting some existing API tests.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]):

Remove some logic that currently presents the keyboard while the user is performing a drop that focuses an
editable element.

* WebProcess/WebPage/WebPage.h:

Add a member variable to keep track of which range should be snapshotted when generating a drop preview.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::didConcludeDrop):
(WebKit::WebPage::didConcludeEditDrag):

Collapse the selection range to the end after an edit drag (i.e., a drop in an editable area that inserted
content).

(WebKit::WebPage::computeAndSendEditDragSnapshot):

Tools:

Adjust some existing API tests that currently check for selection rects after a drop. Instead of checking for
visible selection rects, simply check for the start caret rect, as determined by WKContentView's
-selectionRange.

* TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm:
(TestWebKitAPI::TEST):
(makeCGRectValue): Deleted.
(checkSelectionRectsWithLogging): Deleted.
* TestWebKitAPI/cocoa/DragAndDropSimulator.h:

Replace finalSelectionRects with finalSelectionStartRect.

* TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm:
(-[DragAndDropSimulator _resetSimulatedState]):
(-[DragAndDropSimulator runFrom:to:additionalItemRequestLocations:]):
(-[DragAndDropSimulator finalSelectionRects]): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPageh">trunk/Source/WebKit/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsiosDragAndDropTestsIOSmm">trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPIcocoaDragAndDropSimulatorh">trunk/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h</a></li>
<li><a href="#trunkToolsTestWebKitAPIiosDragAndDropSimulatorIOSmm">trunk/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (245802 => 245803)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-05-28 00:10:41 UTC (rev 245802)
+++ trunk/Source/WebKit/ChangeLog       2019-05-28 01:03:10 UTC (rev 245803)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2019-05-27  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS] Dropping in an editable element should result in a ranged selection
+        https://bugs.webkit.org/show_bug.cgi?id=198267
+        <rdar://problem/51145977>
+
+        Reviewed by Tim Horton.
+
+        When drag and drop was first implemented for iOS in iOS 11, selection behavior when dropping into editable
+        elements matched that of macOS, by leaving the inserted content selected after performing the drop. However, in
+        other parts of the platform (e.g. Notes), both the keyboard and selection views are not shown after a drop.
+
+        Instead of matching macOS behavior, WebKit on iOS should match the rest of the platform. This is a little
+        tricky, since we use the selection range after a drop to create a TextIndicator snapshot when creating a drag
+        preview. To resolve this, we refactor some of the logic introduced in r245778 to remember the DOM range to
+        snapshot before collapsing the range to the end of the inserted content.
+
+        Tested by adjusting some existing API tests.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]):
+
+        Remove some logic that currently presents the keyboard while the user is performing a drop that focuses an
+        editable element.
+
+        * WebProcess/WebPage/WebPage.h:
+
+        Add a member variable to keep track of which range should be snapshotted when generating a drop preview.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::didConcludeDrop):
+        (WebKit::WebPage::didConcludeEditDrag):
+
+        Collapse the selection range to the end after an edit drag (i.e., a drop in an editable area that inserted
+        content).
+
+        (WebKit::WebPage::computeAndSendEditDragSnapshot):
+
</ins><span class="cx"> 2019-05-27  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed Win Cairo build fix after r245796.
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (245802 => 245803)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm    2019-05-28 00:10:41 UTC (rev 245802)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm       2019-05-28 01:03:10 UTC (rev 245803)
</span><span class="lines">@@ -5074,11 +5074,6 @@
</span><span class="cx">             if (userIsInteracting)
</span><span class="cx">                 return YES;
</span><span class="cx"> 
</span><del>-#if ENABLE(DRAG_SUPPORT)
-            if (_dragDropInteractionState.isPerformingDrop())
-                return YES;
-#endif
-
</del><span class="cx">             if (self.isFirstResponder || _becomingFirstResponder) {
</span><span class="cx">                 // When the software keyboard is being used to enter an url, only the focus activity state is changing.
</span><span class="cx">                 // In this case, auto focus on the page being navigated to should be disabled, unless a hardware
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (245802 => 245803)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-05-28 00:10:41 UTC (rev 245802)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h    2019-05-28 01:03:10 UTC (rev 245803)
</span><span class="lines">@@ -1780,6 +1780,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT) && PLATFORM(IOS_FAMILY)
</span><span class="cx">     HashSet<RefPtr<WebCore::HTMLImageElement>> m_pendingImageElementsForDropSnapshot;
</span><ins>+    RefPtr<WebCore::Range> m_rangeForDropSnapshot;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     bool m_cachedMainFrameIsPinnedToLeftSide { true };
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (245802 => 245803)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2019-05-28 00:10:41 UTC (rev 245802)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm    2019-05-28 01:03:10 UTC (rev 245803)
</span><span class="lines">@@ -827,6 +827,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPage::didConcludeDrop()
</span><span class="cx"> {
</span><ins>+    m_rangeForDropSnapshot = nullptr;
</ins><span class="cx">     m_pendingImageElementsForDropSnapshot.clear();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -839,9 +840,9 @@
</span><span class="cx">     m_pendingImageElementsForDropSnapshot.clear();
</span><span class="cx"> 
</span><span class="cx">     bool waitingForAnyImageToLoad = false;
</span><del>-    auto& frame = m_page->focusController().focusedOrMainFrame();
-    if (auto range = frame.selection().selection().toNormalizedRange()) {
-        for (TextIterator iterator(range.get()); !iterator.atEnd(); iterator.advance()) {
</del><ins>+    auto frame = makeRef(m_page->focusController().focusedOrMainFrame());
+    if (auto selectionRange = frame->selection().selection().toNormalizedRange()) {
+        for (TextIterator iterator(selectionRange.get()); !iterator.atEnd(); iterator.advance()) {
</ins><span class="cx">             auto* node = iterator.node();
</span><span class="cx">             if (!is<HTMLImageElement>(node))
</span><span class="cx">                 continue;
</span><span class="lines">@@ -853,6 +854,10 @@
</span><span class="cx">                 waitingForAnyImageToLoad = true;
</span><span class="cx">             }
</span><span class="cx">         }
</span><ins>+        auto collapsedRange = Range::create(selectionRange->ownerDocument(), selectionRange->endPosition(), selectionRange->endPosition());
+        frame->selection().setSelectedRange(collapsedRange.ptr(), DOWNSTREAM, FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
+
+        m_rangeForDropSnapshot = WTFMove(selectionRange);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!waitingForAnyImageToLoad)
</span><span class="lines">@@ -874,8 +879,7 @@
</span><span class="cx"> {
</span><span class="cx">     Optional<TextIndicatorData> textIndicatorData;
</span><span class="cx">     static auto defaultTextIndicatorOptionsForEditDrag = TextIndicatorOptionIncludeSnapshotOfAllVisibleContentWithoutSelection | TextIndicatorOptionExpandClipBeyondVisibleRect | TextIndicatorOptionPaintAllContent | TextIndicatorOptionIncludeMarginIfRangeMatchesSelection | TextIndicatorOptionPaintBackgrounds | TextIndicatorOptionComputeEstimatedBackgroundColor| TextIndicatorOptionUseSelectionRectForSizing | TextIndicatorOptionIncludeSnapshotWithSelectionHighlight;
</span><del>-    auto& frame = m_page->focusController().focusedOrMainFrame();
-    if (auto range = frame.selection().selection().toNormalizedRange()) {
</del><ins>+    if (auto range = std::exchange(m_rangeForDropSnapshot, nullptr)) {
</ins><span class="cx">         if (auto textIndicator = TextIndicator::createWithRange(*range, defaultTextIndicatorOptionsForEditDrag, TextIndicatorPresentationTransition::None, { }))
</span><span class="cx">             textIndicatorData = textIndicator->data();
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (245802 => 245803)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2019-05-28 00:10:41 UTC (rev 245802)
+++ trunk/Tools/ChangeLog       2019-05-28 01:03:10 UTC (rev 245803)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2019-05-27  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS] Dropping in an editable element should result in a ranged selection
+        https://bugs.webkit.org/show_bug.cgi?id=198267
+        <rdar://problem/51145977>
+
+        Reviewed by Tim Horton.
+
+        Adjust some existing API tests that currently check for selection rects after a drop. Instead of checking for
+        visible selection rects, simply check for the start caret rect, as determined by WKContentView's
+        -selectionRange.
+
+        * TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm:
+        (TestWebKitAPI::TEST):
+        (makeCGRectValue): Deleted.
+        (checkSelectionRectsWithLogging): Deleted.
+        * TestWebKitAPI/cocoa/DragAndDropSimulator.h:
+
+        Replace finalSelectionRects with finalSelectionStartRect.
+
+        * TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm:
+        (-[DragAndDropSimulator _resetSimulatedState]):
+        (-[DragAndDropSimulator runFrom:to:additionalItemRequestLocations:]):
+        (-[DragAndDropSimulator finalSelectionRects]): Deleted.
+
</ins><span class="cx"> 2019-05-27  Oriol Brufau  <obrufau@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         [css-grid] Preserve repeat() notation when serializing declared values
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsiosDragAndDropTestsIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm (245802 => 245803)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm       2019-05-28 00:10:41 UTC (rev 245802)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm  2019-05-28 01:03:10 UTC (rev 245803)
</span><span class="lines">@@ -117,11 +117,6 @@
</span><span class="cx">     [simulator ensureInputSession];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static NSValue *makeCGRectValue(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
-{
-    return [NSValue valueWithCGRect:CGRectMake(x, y, width, height)];
-}
-
</del><span class="cx"> static void checkCGRectIsEqualToCGRectWithLogging(CGRect expected, CGRect observed)
</span><span class="cx"> {
</span><span class="cx">     BOOL isEqual = CGRectEqualToRect(expected, observed);
</span><span class="lines">@@ -130,13 +125,6 @@
</span><span class="cx">         NSLog(@"Expected: %@ but observed: %@", NSStringFromCGRect(expected), NSStringFromCGRect(observed));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void checkSelectionRectsWithLogging(NSArray *expected, NSArray *observed)
-{
-    if (![expected isEqualToArray:observed])
-        NSLog(@"Expected selection rects: %@ but observed: %@", expected, observed);
-    EXPECT_TRUE([expected isEqualToArray:observed]);
-}
-
</del><span class="cx"> static void checkRichTextTypePrecedesPlainTextType(DragAndDropSimulator *simulator)
</span><span class="cx"> {
</span><span class="cx">     // At least one of "com.apple.flat-rtfd" or "public.rtf" is expected to have higher precedence than "public.utf8-plain-text".
</span><span class="lines">@@ -275,7 +263,7 @@
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"dragenter"]);
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"dragover"]);
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"drop"]);
</span><del>-    checkSelectionRectsWithLogging(@[ makeCGRectValue(1, 201, 215, 174) ], [simulator finalSelectionRects]);
</del><ins>+    checkCGRectIsEqualToCGRectWithLogging(CGRectMake(214, 201, 2, 174), [simulator finalSelectionStartRect]);
</ins><span class="cx">     checkFirstTypeIsPresentAndSecondTypeIsMissing(simulator.get(), kUTTypePNG, kUTTypeFileURL);
</span><span class="cx">     checkEstimatedSize(simulator.get(), { 215, 174 });
</span><span class="cx">     EXPECT_TRUE([simulator lastKnownDropProposal].precise);
</span><span class="lines">@@ -320,7 +308,7 @@
</span><span class="cx">     [simulator runFrom:CGPointMake(100, 50) to:CGPointMake(100, 300)];
</span><span class="cx"> 
</span><span class="cx">     EXPECT_WK_STREQ("https://www.apple.com/", [webView editorValue].UTF8String);
</span><del>-    checkSelectionRectsWithLogging(@[ makeCGRectValue(101, 241, 2057, 232) ], [simulator finalSelectionRects]);
</del><ins>+    checkCGRectIsEqualToCGRectWithLogging(CGRectMake(2156, 241, 2, 232), [simulator finalSelectionStartRect]);
</ins><span class="cx">     checkSuggestedNameAndEstimatedSize(simulator.get(), @"icon.png", { 215, 174 });
</span><span class="cx">     checkTypeIdentifierIsRegisteredAtIndex(simulator.get(), (__bridge NSString *)kUTTypePNG, 0);
</span><span class="cx">     EXPECT_TRUE([simulator lastKnownDropProposal].precise);
</span><span class="lines">@@ -390,7 +378,7 @@
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"dragenter"]);
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"dragover"]);
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"drop"]);
</span><del>-    checkSelectionRectsWithLogging(@[ makeCGRectValue(1, 201, 961, 227) ], [simulator finalSelectionRects]);
</del><ins>+    checkCGRectIsEqualToCGRectWithLogging(CGRectMake(960, 201, 2, 227), [simulator finalSelectionStartRect]);
</ins><span class="cx">     checkRichTextTypePrecedesPlainTextType(simulator.get());
</span><span class="cx">     EXPECT_TRUE([simulator lastKnownDropProposal].precise);
</span><span class="cx"> 
</span><span class="lines">@@ -414,7 +402,7 @@
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"dragenter"]);
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"dragover"]);
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"drop"]);
</span><del>-    checkSelectionRectsWithLogging(@[ makeCGRectValue(101, 203, 990, 232) ], [simulator finalSelectionRects]);
</del><ins>+    checkCGRectIsEqualToCGRectWithLogging(CGRectMake(1089, 203, 2, 232), [simulator finalSelectionStartRect]);
</ins><span class="cx">     checkRichTextTypePrecedesPlainTextType(simulator.get());
</span><span class="cx">     EXPECT_TRUE([simulator lastKnownDropProposal].precise);
</span><span class="cx"> }
</span><span class="lines">@@ -471,7 +459,7 @@
</span><span class="cx">     EXPECT_FALSE(firstParagraphOffset == NSNotFound);
</span><span class="cx">     EXPECT_FALSE(secondParagraphOffset == NSNotFound);
</span><span class="cx">     EXPECT_GT(firstParagraphOffset, secondParagraphOffset);
</span><del>-    checkSelectionRectsWithLogging(@[ makeCGRectValue(190, 100, 130, 20), makeCGRectValue(0, 120, 320, 100), makeCGRectValue(0, 220, 252, 20) ], [simulator finalSelectionRects]);
</del><ins>+    checkCGRectIsEqualToCGRectWithLogging(CGRectMake(251, 220, 2, 20), [simulator finalSelectionStartRect]);
</ins><span class="cx">     EXPECT_TRUE([simulator lastKnownDropProposal].precise);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -497,7 +485,7 @@
</span><span class="cx">     EXPECT_TRUE([simulator suppressedSelectionCommandsDuringDrop]);
</span><span class="cx">     EXPECT_EQ([webView stringByEvaluatingJavaScript:@"source.value"].length, 0UL);
</span><span class="cx">     EXPECT_WK_STREQ("Hello world", [webView editorValue].UTF8String);
</span><del>-    checkSelectionRectsWithLogging(@[ makeCGRectValue(101, 241, 990, 232) ], [simulator finalSelectionRects]);
</del><ins>+    checkCGRectIsEqualToCGRectWithLogging(CGRectMake(1089, 241, 2, 232), [simulator finalSelectionStartRect]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(DragAndDropTests, SinglePlainTextWordTypeIdentifiers)
</span><span class="lines">@@ -568,7 +556,7 @@
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"dragenter"]);
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"dragover"]);
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"drop"]);
</span><del>-    checkSelectionRectsWithLogging(@[ makeCGRectValue(101, 273, 2057, 232) ], [simulator finalSelectionRects]);
</del><ins>+    checkCGRectIsEqualToCGRectWithLogging(CGRectMake(2156, 273, 2, 232), [simulator finalSelectionStartRect]);
</ins><span class="cx">     checkTypeIdentifierIsRegisteredAtIndex(simulator.get(), (__bridge NSString *)kUTTypeURL, 0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -586,7 +574,7 @@
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"dragenter"]);
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"dragover"]);
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"drop"]);
</span><del>-    checkSelectionRectsWithLogging(@[ makeCGRectValue(101, 241, 2057, 232) ], [simulator finalSelectionRects]);
</del><ins>+    checkCGRectIsEqualToCGRectWithLogging(CGRectMake(2156, 241, 2, 232), [simulator finalSelectionStartRect]);
</ins><span class="cx">     checkTypeIdentifierIsRegisteredAtIndex(simulator.get(), (__bridge NSString *)kUTTypeURL, 0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -604,7 +592,7 @@
</span><span class="cx">     NSArray *observedEventNames = [simulator observedEventNames];
</span><span class="cx">     EXPECT_FALSE([observedEventNames containsObject:@"dragenter"]);
</span><span class="cx">     EXPECT_FALSE([observedEventNames containsObject:@"dragover"]);
</span><del>-    checkSelectionRectsWithLogging(@[ ], [simulator finalSelectionRects]);
</del><ins>+    checkCGRectIsEqualToCGRectWithLogging(CGRectMake(0, 0, 0, 0), [simulator finalSelectionStartRect]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(DragAndDropTests, CanPreventOperation)
</span><span class="lines">@@ -620,7 +608,7 @@
</span><span class="cx">     NSArray *observedEventNames = [simulator observedEventNames];
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"dragenter"]);
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"dragover"]);
</span><del>-    checkSelectionRectsWithLogging(@[ ], [simulator finalSelectionRects]);
</del><ins>+    checkCGRectIsEqualToCGRectWithLogging(CGRectMake(0, 0, 0, 0), [simulator finalSelectionStartRect]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(DragAndDropTests, EnterAndLeaveEvents)
</span><span class="lines">@@ -638,7 +626,7 @@
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"dragover"]);
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:@"dragleave"]);
</span><span class="cx">     EXPECT_FALSE([observedEventNames containsObject:@"drop"]);
</span><del>-    checkSelectionRectsWithLogging(@[ ], [simulator finalSelectionRects]);
</del><ins>+    checkCGRectIsEqualToCGRectWithLogging(CGRectMake(0, 0, 0, 0), [simulator finalSelectionStartRect]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(DragAndDropTests, CanStartDragOnDivWithDraggableAttribute)
</span><span class="lines">@@ -1025,7 +1013,7 @@
</span><span class="cx">     [simulator setExternalItemProviders:@[ simulatedItemProvider.get() ]];
</span><span class="cx">     [simulator runFrom:CGPointMake(300, 400) to:CGPointMake(100, 300)];
</span><span class="cx">     EXPECT_WK_STREQ(textPayload.UTF8String, [webView stringByEvaluatingJavaScript:@"editor.textContent"].UTF8String);
</span><del>-    checkSelectionRectsWithLogging(@[ makeCGRectValue(1, 201, 1936, 227) ], [simulator finalSelectionRects]);
</del><ins>+    checkCGRectIsEqualToCGRectWithLogging(CGRectMake(1935, 201, 2, 227), [simulator finalSelectionStartRect]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(DragAndDropTests, ExternalSourceJPEGOnly)
</span><span class="lines">@@ -1045,7 +1033,7 @@
</span><span class="cx">     [simulator setExternalItemProviders:@[ simulatedItemProvider.get() ]];
</span><span class="cx">     [simulator runFrom:CGPointMake(300, 400) to:CGPointMake(100, 300)];
</span><span class="cx">     EXPECT_TRUE([webView editorContainsImageElement]);
</span><del>-    checkSelectionRectsWithLogging(@[ makeCGRectValue(1, 201, 215, 174) ], [simulator finalSelectionRects]);
</del><ins>+    checkCGRectIsEqualToCGRectWithLogging(CGRectMake(214, 201, 2, 223), [simulator finalSelectionStartRect]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(DragAndDropTests, ExternalSourceTitledNSURL)
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIcocoaDragAndDropSimulatorh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h (245802 => 245803)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h   2019-05-28 00:10:41 UTC (rev 245802)
+++ trunk/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h      2019-05-28 01:03:10 UTC (rev 245803)
</span><span class="lines">@@ -108,7 +108,7 @@
</span><span class="cx"> 
</span><span class="cx"> @property (nonatomic, readonly) NSArray *sourceItemProviders;
</span><span class="cx"> @property (nonatomic, readonly) NSArray *observedEventNames;
</span><del>-@property (nonatomic, readonly) NSArray *finalSelectionRects;
</del><ins>+@property (nonatomic, readonly) CGRect finalSelectionStartRect;
</ins><span class="cx"> @property (nonatomic, readonly) CGRect lastKnownDragCaretRect;
</span><span class="cx"> @property (nonatomic, readonly) NSArray<UITargetedDragPreview *> *liftPreviews;
</span><span class="cx"> @property (nonatomic, readonly) NSArray *dropPreviews;
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIiosDragAndDropSimulatorIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm (245802 => 245803)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm 2019-05-28 00:10:41 UTC (rev 245802)
+++ trunk/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm    2019-05-28 01:03:10 UTC (rev 245803)
</span><span class="lines">@@ -303,7 +303,7 @@
</span><span class="cx">     RetainPtr<NSMutableArray> _observedEventNames;
</span><span class="cx">     RetainPtr<NSArray> _externalItemProviders;
</span><span class="cx">     RetainPtr<NSArray> _sourceItemProviders;
</span><del>-    RetainPtr<NSArray> _finalSelectionRects;
</del><ins>+    CGRect _finalSelectionStartRect;
</ins><span class="cx">     CGPoint _startLocation;
</span><span class="cx">     CGPoint _endLocation;
</span><span class="cx">     CGRect _lastKnownDragCaretRect;
</span><span class="lines">@@ -381,7 +381,7 @@
</span><span class="cx">     _observedEventNames = adoptNS([[NSMutableArray alloc] init]);
</span><span class="cx">     _insertedAttachments = adoptNS([[NSMutableArray alloc] init]);
</span><span class="cx">     _removedAttachments = adoptNS([[NSMutableArray alloc] init]);
</span><del>-    _finalSelectionRects = @[ ];
</del><ins>+    _finalSelectionStartRect = CGRectNull;
</ins><span class="cx">     _dragSession = nil;
</span><span class="cx">     _dropSession = nil;
</span><span class="cx">     _lastKnownDropProposal = nil;
</span><span class="lines">@@ -463,16 +463,14 @@
</span><span class="cx">     Util::run(&_isDoneWithCurrentRun);
</span><span class="cx">     Util::run(&_isDoneWaitingForDelayedDropPreviews);
</span><span class="cx">     [_webView clearMessageHandlers:dragAndDropEventNames()];
</span><del>-    _finalSelectionRects = [_webView selectionRectsAfterPresentationUpdate];
</del><ins>+    [_webView waitForNextPresentationUpdate];
</ins><span class="cx"> 
</span><ins>+    auto contentView = [_webView textInputContentView];
+    _finalSelectionStartRect = [contentView caretRectForPosition:contentView.selectedTextRange.start];
+
</ins><span class="cx">     [defaultCenter removeObserver:self];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (NSArray *)finalSelectionRects
-{
-    return _finalSelectionRects.get();
-}
-
</del><span class="cx"> - (void)_concludeDropAndPerformOperationIfNecessary
</span><span class="cx"> {
</span><span class="cx">     _lastKnownDragCaretRect = [_webView _dragCaretRect];
</span></span></pre>
</div>
</div>

</body>
</html>