<!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>[247490] 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/247490">247490</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2019-07-16 12:46:32 -0700 (Tue, 16 Jul 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>NSTextFinder holes don't scroll with the page
https://bugs.webkit.org/show_bug.cgi?id=199815
<rdar://problem/52280514>

Reviewed by Simon Fraser.

Source/WebCore:

* rendering/ScrollAlignment.h:

Source/WebKit:

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _usePlatformFindUI]):
(-[WKWebView _setUsePlatformFindUI:]):
(-[WKWebView _ensureTextFinderClient]):
Add a bit so that clients can choose whether they want our find UI,
which respects scrolling, or the system find UI, which works when
doing multi-document searches. Right now you can't have both.

(-[WKWebView scrollFindMatchToVisible:]):
Implement and plumb scrollFindMatchToVisible.

* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::indicateFindMatch):
* UIProcess/WebPageProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::indicateFindMatch):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
Plumb indicateFindMatch to FindController.

* UIProcess/mac/WKTextFinderClient.h:
* UIProcess/mac/WKTextFinderClient.mm:
(-[WKTextFinderClient initWithPage:view:usePlatformFindUI:]):
Store whether or not we are using the platform find UI.

(-[WKTextFinderClient findMatchesForString:relativeToMatch:findOptions:maxResults:resultCollector:]):
If using WebKit find UI, turn on our UI in the options passed to findString[Matches].

(-[WKTextFinderClient scrollFindMatchToVisible:]):
If using WebKit find UI, when the platform tells us to reveal a find match, indicate it.

(-[WKTextFinderClient didFindStringMatchesWithRects:didWrapAround:]):
If using WebKit find UI, lie to the platform and return no rects so that it doesn't paint a yellow rectangle.

(-[WKTextFinderClient getImageForMatchResult:completionHandler:]):
If using WebKit find UI, lie to the platform and return no image so that it doesn't paint a yellow rectangle.

(-[WKTextFinderClient initWithPage:view:]): Deleted.

* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::updateFindUIAfterPageScroll):
Make it possible to use our find UI with 'findStringMatches'; since the platform
find infrastrucutre depends on knowing about all matches up front, we need
to use 'findStringMatches' instead of 'findString', but we had never combined
that with our UI. Don't throw away the other matches when we indicate one, and
don't send DidFindString in the case we are coming from 'findStringMatches'.
This all needs a bit of cleanup in the future.

(WebKit::FindController::findString):
Tell updateFindUIAfterPageScroll that we are 'findString' so that it uses its normal behavior.

(WebKit::FindController::findStringMatches):
Tell updateFindUIAfterPageScroll that we are 'findStringMatches' so that it uses the adjusted behavior.

(WebKit::FindController::indicateFindMatch):
Add 'indicateFindMatch', which both selects the match and moves the indicator there.

* WebProcess/WebPage/FindController.h:

Tools:

* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[MiniBrowserNSTextFinder performAction:]):
(-[WK2BrowserWindowController awakeFromNib]):
Adopt the WebKit UI in MiniBrowser. Also, override NSTextFinder's
-performAction: so that we can intercept the close action and
hide our own find UI, since there is no delegate for that action yet.

* TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm:
(TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePALpalspimacNSTextFinderSPIh">trunk/Source/WebCore/PAL/pal/spi/mac/NSTextFinderSPI.h</a></li>
<li><a href="#trunkSourceWebCorerenderingScrollAlignmenth">trunk/Source/WebCore/rendering/ScrollAlignment.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebViewPrivateh">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxycpp">trunk/Source/WebKit/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxyh">trunk/Source/WebKit/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessmacWKTextFinderClienth">trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessmacWKTextFinderClientmm">trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageFindControllercpp">trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageFindControllerh">trunk/Source/WebKit/WebProcess/WebPage/FindController.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagecpp">trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPageh">trunk/Source/WebKit/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagemessagesin">trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsMiniBrowsermacWK2BrowserWindowControllerm">trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaFindInPagemm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebCore/ChangeLog      2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2019-07-16  Tim Horton  <timothy_horton@apple.com>
+
+        NSTextFinder holes don't scroll with the page
+        https://bugs.webkit.org/show_bug.cgi?id=199815
+        <rdar://problem/52280514>
+
+        Reviewed by Simon Fraser.
+
+        * rendering/ScrollAlignment.h:
+
</ins><span class="cx"> 2019-07-16  Youenn Fablet  <youenn@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [iOS] Make sure the first camera device in the list is the front camera
</span></span></pre></div>
<a id="trunkSourceWebCorePALpalspimacNSTextFinderSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PAL/pal/spi/mac/NSTextFinderSPI.h (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PAL/pal/spi/mac/NSTextFinderSPI.h   2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/NSTextFinderSPI.h      2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -52,6 +52,7 @@
</span><span class="cx"> - (void)getSelectedText:(void (^)(NSString *selectedTextString))completionHandler;
</span><span class="cx"> - (void)selectFindMatch:(id <NSTextFinderAsynchronousDocumentFindMatch>)findMatch completionHandler:(void (^)(void))completionHandler;
</span><span class="cx"> - (void)replaceMatches:(NSArray *)matches withString:(NSString *)replacementString inSelectionOnly:(BOOL)selectionOnly resultCollector:(void (^)(NSUInteger replacementCount))resultCollector;
</span><ins>+- (void)scrollFindMatchToVisible:(id <NSTextFinderAsynchronousDocumentFindMatch>)findMatch;
</ins><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingScrollAlignmenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/ScrollAlignment.h (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/ScrollAlignment.h 2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebCore/rendering/ScrollAlignment.h    2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx"> 
</span><span class="cx">     static const ScrollAlignment alignCenterIfNotVisible;
</span><span class="cx">     static const ScrollAlignment alignToEdgeIfNotVisible;
</span><del>-    static const ScrollAlignment alignCenterIfNeeded;
</del><ins>+    WEBCORE_EXPORT static const ScrollAlignment alignCenterIfNeeded;
</ins><span class="cx">     WEBCORE_EXPORT static const ScrollAlignment alignToEdgeIfNeeded;
</span><span class="cx">     WEBCORE_EXPORT static const ScrollAlignment alignCenterAlways;
</span><span class="cx">     static const ScrollAlignment alignTopAlways;
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebKit/ChangeLog       2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -1,3 +1,71 @@
</span><ins>+2019-07-16  Tim Horton  <timothy_horton@apple.com>
+
+        NSTextFinder holes don't scroll with the page
+        https://bugs.webkit.org/show_bug.cgi?id=199815
+        <rdar://problem/52280514>
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _usePlatformFindUI]):
+        (-[WKWebView _setUsePlatformFindUI:]):
+        (-[WKWebView _ensureTextFinderClient]):
+        Add a bit so that clients can choose whether they want our find UI,
+        which respects scrolling, or the system find UI, which works when
+        doing multi-document searches. Right now you can't have both.
+
+        (-[WKWebView scrollFindMatchToVisible:]):
+        Implement and plumb scrollFindMatchToVisible.
+
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::indicateFindMatch):
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::indicateFindMatch):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        Plumb indicateFindMatch to FindController.
+
+        * UIProcess/mac/WKTextFinderClient.h:
+        * UIProcess/mac/WKTextFinderClient.mm:
+        (-[WKTextFinderClient initWithPage:view:usePlatformFindUI:]):
+        Store whether or not we are using the platform find UI.
+
+        (-[WKTextFinderClient findMatchesForString:relativeToMatch:findOptions:maxResults:resultCollector:]):
+        If using WebKit find UI, turn on our UI in the options passed to findString[Matches].
+
+        (-[WKTextFinderClient scrollFindMatchToVisible:]):
+        If using WebKit find UI, when the platform tells us to reveal a find match, indicate it.
+
+        (-[WKTextFinderClient didFindStringMatchesWithRects:didWrapAround:]):
+        If using WebKit find UI, lie to the platform and return no rects so that it doesn't paint a yellow rectangle.
+
+        (-[WKTextFinderClient getImageForMatchResult:completionHandler:]):
+        If using WebKit find UI, lie to the platform and return no image so that it doesn't paint a yellow rectangle.
+
+        (-[WKTextFinderClient initWithPage:view:]): Deleted.
+
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::FindController::updateFindUIAfterPageScroll):
+        Make it possible to use our find UI with 'findStringMatches'; since the platform
+        find infrastrucutre depends on knowing about all matches up front, we need
+        to use 'findStringMatches' instead of 'findString', but we had never combined
+        that with our UI. Don't throw away the other matches when we indicate one, and
+        don't send DidFindString in the case we are coming from 'findStringMatches'.
+        This all needs a bit of cleanup in the future.
+
+        (WebKit::FindController::findString):
+        Tell updateFindUIAfterPageScroll that we are 'findString' so that it uses its normal behavior.
+
+        (WebKit::FindController::findStringMatches):
+        Tell updateFindUIAfterPageScroll that we are 'findStringMatches' so that it uses the adjusted behavior.
+
+        (WebKit::FindController::indicateFindMatch):
+        Add 'indicateFindMatch', which both selects the match and moves the indicator there.
+
+        * WebProcess/WebPage/FindController.h:
+
</ins><span class="cx"> 2019-07-16  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Speed up StorageManager::getValues()
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm     2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm        2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -273,6 +273,8 @@
</span><span class="cx">     Optional<BOOL> _resolutionForShareSheetImmediateCompletionForTesting;
</span><span class="cx">     RetainPtr<WKSafeBrowsingWarning> _safeBrowsingWarning;
</span><span class="cx"> 
</span><ins>+    BOOL _usePlatformFindUI;
+
</ins><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx">     RetainPtr<_WKRemoteObjectRegistry> _remoteObjectRegistry;
</span><span class="cx"> 
</span><span class="lines">@@ -770,6 +772,8 @@
</span><span class="cx"> 
</span><span class="cx">     _iconLoadingDelegate = std::make_unique<WebKit::IconLoadingDelegate>(self);
</span><span class="cx"> 
</span><ins>+    _usePlatformFindUI = YES;
+
</ins><span class="cx">     [self _setUpSQLiteDatabaseTrackerClient];
</span><span class="cx"> 
</span><span class="cx">     for (auto& pair : pageConfiguration->urlSchemeHandlers())
</span><span class="lines">@@ -4319,10 +4323,24 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+- (BOOL)_usePlatformFindUI
+{
+    return _usePlatformFindUI;
+}
+
+- (void)_setUsePlatformFindUI:(BOOL)usePlatformFindUI
+{
+    _usePlatformFindUI = usePlatformFindUI;
+
+    if (_textFinderClient)
+        [self _hideFindUI];
+    _textFinderClient = nil;
+}
+
</ins><span class="cx"> - (WKTextFinderClient *)_ensureTextFinderClient
</span><span class="cx"> {
</span><span class="cx">     if (!_textFinderClient)
</span><del>-        _textFinderClient = adoptNS([[WKTextFinderClient alloc] initWithPage:*_page view:self]);
</del><ins>+        _textFinderClient = adoptNS([[WKTextFinderClient alloc] initWithPage:*_page view:self usePlatformFindUI:_usePlatformFindUI]);
</ins><span class="cx">     return _textFinderClient.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -4336,6 +4354,11 @@
</span><span class="cx">     [[self _ensureTextFinderClient] replaceMatches:matches withString:replacementString inSelectionOnly:selectionOnly resultCollector:resultCollector];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)scrollFindMatchToVisible:(id<NSTextFinderAsynchronousDocumentFindMatch>)match
+{
+    [[self _ensureTextFinderClient] scrollFindMatchToVisible:match];
+}
+
</ins><span class="cx"> - (NSView *)documentContainerView
</span><span class="cx"> {
</span><span class="cx">     return self;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h       2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h  2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -359,6 +359,9 @@
</span><span class="cx"> @property (nonatomic, setter=_setThumbnailView:) _WKThumbnailView *_thumbnailView WK_API_AVAILABLE(macos(10.13.4));
</span><span class="cx"> @property (nonatomic, setter=_setIgnoresAllEvents:) BOOL _ignoresAllEvents WK_API_AVAILABLE(macos(10.13.4));
</span><span class="cx"> 
</span><ins>+// Defaults to YES; if set to NO, WebKit will draw the grey wash and highlights itself.
+@property (nonatomic, setter=_setUsePlatformFindUI:) BOOL _usePlatformFindUI WK_API_AVAILABLE(macos(WK_MAC_TBA));
+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)_reloadWithoutContentBlockers WK_API_AVAILABLE(macos(10.12), ios(10.0));
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp   2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp      2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -3574,6 +3574,11 @@
</span><span class="cx">     m_process->send(Messages::WebPage::SelectFindMatch(matchIndex), m_pageID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::indicateFindMatch(int32_t matchIndex)
+{
+    m_process->send(Messages::WebPage::IndicateFindMatch(matchIndex), m_pageID);
+}
+
</ins><span class="cx"> void WebPageProxy::hideFindUI()
</span><span class="cx"> {
</span><span class="cx">     m_process->send(Messages::WebPage::HideFindUI(), m_pageID);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.h     2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h        2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -983,6 +983,7 @@
</span><span class="cx">     void findStringMatches(const String&, FindOptions, unsigned maxMatchCount);
</span><span class="cx">     void getImageForFindMatch(int32_t matchIndex);
</span><span class="cx">     void selectFindMatch(int32_t matchIndex);
</span><ins>+    void indicateFindMatch(int32_t matchIndex);
</ins><span class="cx">     void didGetImageForFindMatch(const ShareableBitmap::Handle& contentImageHandle, uint32_t matchIndex);
</span><span class="cx">     void hideFindUI();
</span><span class="cx">     void countStringMatches(const String&, FindOptions, unsigned maxMatchCount);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessmacWKTextFinderClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.h (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.h   2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.h      2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> 
</span><span class="cx"> @interface WKTextFinderClient : NSObject
</span><span class="cx"> 
</span><del>-- (instancetype)initWithPage:(WebKit::WebPageProxy&)page view:(NSView *)view;
</del><ins>+- (instancetype)initWithPage:(WebKit::WebPageProxy&)page view:(NSView *)view usePlatformFindUI:(BOOL)usePlatformFindUI;
</ins><span class="cx"> - (void)willDestroyView:(NSView *)view;
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessmacWKTextFinderClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm  2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm     2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -72,9 +72,19 @@
</span><span class="cx">         [m_textFinderClient didGetImageForMatchResult:image];
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    void didFindString(WebPageProxy*, const String&, const Vector<WebCore::IntRect>& matchRects, uint32_t, int32_t, bool didWrapAround) override
</del><ins>+    void didFindString(WebPageProxy*, const String&, const Vector<WebCore::IntRect>& matchRects, uint32_t matchCount, int32_t matchIndex, bool didWrapAround) override
</ins><span class="cx">     {
</span><del>-        [m_textFinderClient didFindStringMatchesWithRects:{ matchRects } didWrapAround:didWrapAround];
</del><ins>+        Vector<Vector<WebCore::IntRect>> allMatches;
+        if (matchCount != static_cast<unsigned>(kWKMoreThanMaximumMatchCount)) {
+            // Synthesize a vector of match rects for all `matchCount` matches,
+            // filling in the actual rects for the one that we received.
+            // The rest will remain empty, but it's important to NSTextFinder
+            // that they at least exist.
+            allMatches.resize(matchCount);
+            allMatches[matchIndex].appendVector(matchRects);
+        }
+
+        [m_textFinderClient didFindStringMatchesWithRects:allMatches didWrapAround:didWrapAround];
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     void didFailToFindString(WebPageProxy*, const String& string) override
</span><span class="lines">@@ -138,13 +148,14 @@
</span><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @implementation WKTextFinderClient {
</span><del>-    WebKit::WebPageProxy *_page;
</del><ins>+    WebKit::WebPageProxy* _page;
</ins><span class="cx">     NSView *_view;
</span><span class="cx">     Deque<WTF::Function<void(NSArray *, bool didWrap)>> _findReplyCallbacks;
</span><span class="cx">     Deque<WTF::Function<void(NSImage *)>> _imageReplyCallbacks;
</span><ins>+    BOOL _usePlatformFindUI;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (instancetype)initWithPage:(WebKit::WebPageProxy&)page view:(NSView *)view
</del><ins>+- (instancetype)initWithPage:(WebKit::WebPageProxy&)page view:(NSView *)view usePlatformFindUI:(BOOL)usePlatformFindUI
</ins><span class="cx"> {
</span><span class="cx">     self = [super init];
</span><span class="cx"> 
</span><span class="lines">@@ -153,6 +164,7 @@
</span><span class="cx"> 
</span><span class="cx">     _page = &page;
</span><span class="cx">     _view = view;
</span><ins>+    _usePlatformFindUI = usePlatformFindUI;
</ins><span class="cx">     
</span><span class="cx">     _page->setFindMatchesClient(std::make_unique<WebKit::TextFinderFindClient>(self));
</span><span class="cx">     _page->setFindClient(std::make_unique<WebKit::TextFinderFindClient>(self));
</span><span class="lines">@@ -202,6 +214,12 @@
</span><span class="cx">     if (findOptions & NSTextFinderAsynchronousDocumentFindOptionsStartsWith)
</span><span class="cx">         kitFindOptions |= WebKit::FindOptionsAtWordStarts;
</span><span class="cx"> 
</span><ins>+    if (!_usePlatformFindUI) {
+        kitFindOptions |= WebKit::FindOptionsShowOverlay;
+        kitFindOptions |= WebKit::FindOptionsShowFindIndicator;
+        kitFindOptions |= WebKit::FindOptionsDetermineMatchIndex;
+    }
+
</ins><span class="cx">     RetainPtr<NSProgress> progress = [NSProgress progressWithTotalUnitCount:1];
</span><span class="cx">     auto copiedResultCollector = Block_copy(resultCollector);
</span><span class="cx">     _findReplyCallbacks.append([progress, copiedResultCollector] (NSArray *matches, bool didWrap) {
</span><span class="lines">@@ -235,6 +253,17 @@
</span><span class="cx">     _page->selectFindMatch(textFinderMatch.index);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)scrollFindMatchToVisible:(id <NSTextFinderAsynchronousDocumentFindMatch>)findMatch
+{
+    if (_usePlatformFindUI)
+        return;
+
+    ASSERT([findMatch isKindOfClass:[WKTextFinderMatch class]]);
+
+    WKTextFinderMatch *textFinderMatch = static_cast<WKTextFinderMatch *>(findMatch);
+    _page->indicateFindMatch(textFinderMatch.index);
+}
+
</ins><span class="cx"> #pragma mark - FindMatchesClient
</span><span class="cx"> 
</span><span class="cx"> static RetainPtr<NSArray> arrayFromRects(const Vector<WebCore::IntRect>& matchRects)
</span><span class="lines">@@ -254,7 +283,12 @@
</span><span class="cx">     unsigned matchCount = rectsForMatches.size();
</span><span class="cx">     RetainPtr<NSMutableArray> matchObjects = adoptNS([[NSMutableArray alloc] initWithCapacity:matchCount]);
</span><span class="cx">     for (unsigned i = 0; i < matchCount; i++) {
</span><del>-        RetainPtr<NSArray> nsMatchRects = arrayFromRects(rectsForMatches[i]);
</del><ins>+        RetainPtr<NSArray> nsMatchRects;
+
+        if (_usePlatformFindUI)
+            nsMatchRects = arrayFromRects(rectsForMatches[i]);
+        else
+            nsMatchRects = @[];
</ins><span class="cx">         RetainPtr<WKTextFinderMatch> match = adoptNS([[WKTextFinderMatch alloc] initWithClient:self view:_view index:i rects:nsMatchRects.get()]);
</span><span class="cx">         [matchObjects addObject:match.get()];
</span><span class="cx">     }
</span><span class="lines">@@ -278,6 +312,11 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)getImageForMatchResult:(id <NSTextFinderAsynchronousDocumentFindMatch>)findMatch completionHandler:(void (^)(NSImage *generatedImage))completionHandler
</span><span class="cx"> {
</span><ins>+    if (!_usePlatformFindUI) {
+        completionHandler(nil);
+        return;
+    }
+
</ins><span class="cx">     ASSERT([findMatch isKindOfClass:[WKTextFinderMatch class]]);
</span><span class="cx"> 
</span><span class="cx">     WKTextFinderMatch *textFinderMatch = static_cast<WKTextFinderMatch *>(findMatch);
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageFindControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp        2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp   2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -130,7 +130,7 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FindController::updateFindUIAfterPageScroll(bool found, const String& string, FindOptions options, unsigned maxMatchCount, DidWrap didWrap)
</del><ins>+void FindController::updateFindUIAfterPageScroll(bool found, const String& string, FindOptions options, unsigned maxMatchCount, DidWrap didWrap, FindUIOriginator originator)
</ins><span class="cx"> {
</span><span class="cx">     Frame* selectedFrame = frameWithSelection(m_webPage->corePage());
</span><span class="cx">     
</span><span class="lines">@@ -190,14 +190,21 @@
</span><span class="cx">                 m_foundStringMatchIndex -= matchCount;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        m_findMatches.clear();
-        Vector<IntRect> matchRects;
-        if (auto range = m_webPage->corePage()->selection().firstRange()) {
-            range->absoluteTextRects(matchRects);
-            m_findMatches.append(range);
</del><ins>+        // If updating UI after finding an individual match, update the current
+        // match rects and inform the UI process that we succeeded.
+        // If we're doing a multi-result search and just updating the indicator,
+        // this would blow away the results for the other matches.
+        // FIXME: This whole class needs a much clearer division between these two paths.
+        if (originator == FindUIOriginator::FindString) {
+            m_findMatches.clear();
+            Vector<IntRect> matchRects;
+            if (auto range = m_webPage->corePage()->selection().firstRange()) {
+                range->absoluteTextRects(matchRects);
+                m_findMatches.append(range);
+            }
+
+            m_webPage->send(Messages::WebPageProxy::DidFindString(string, matchRects, matchCount, m_foundStringMatchIndex, didWrap == DidWrap::Yes));
</ins><span class="cx">         }
</span><del>-
-        m_webPage->send(Messages::WebPageProxy::DidFindString(string, matchRects, matchCount, m_foundStringMatchIndex, didWrap == DidWrap::Yes));
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!shouldShowOverlay) {
</span><span class="lines">@@ -267,7 +274,7 @@
</span><span class="cx"> 
</span><span class="cx">     RefPtr<WebPage> protectedWebPage = m_webPage;
</span><span class="cx">     m_webPage->drawingArea()->dispatchAfterEnsuringUpdatedScrollPosition([protectedWebPage, found, string, options, maxMatchCount, didWrap] () {
</span><del>-        protectedWebPage->findController().updateFindUIAfterPageScroll(found, string, options, maxMatchCount, didWrap);
</del><ins>+        protectedWebPage->findController().updateFindUIAfterPageScroll(found, string, options, maxMatchCount, didWrap, FindUIOriginator::FindString);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -286,6 +293,14 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_webPage->send(Messages::WebPageProxy::DidFindStringMatches(string, matchRects, indexForSelection));
</span><ins>+
+    if (!(options & FindOptionsShowOverlay || options & FindOptionsShowFindIndicator))
+        return;
+
+    bool found = !m_findMatches.isEmpty();
+    m_webPage->drawingArea()->dispatchAfterEnsuringUpdatedScrollPosition([protectedWebPage = makeRefPtr(m_webPage), found, string, options, maxMatchCount] () {
+        protectedWebPage->findController().updateFindUIAfterPageScroll(found, string, options, maxMatchCount, DidWrap::No, FindUIOriginator::FindStringMatches);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FindController::getImageForFindMatch(uint32_t matchIndex)
</span><span class="lines">@@ -325,6 +340,19 @@
</span><span class="cx">     frame->selection().setSelection(VisibleSelection(*m_findMatches[matchIndex]));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FindController::indicateFindMatch(uint32_t matchIndex)
+{
+    selectFindMatch(matchIndex);
+
+    Frame* selectedFrame = frameWithSelection(m_webPage->corePage());
+    if (!selectedFrame)
+        return;
+
+    selectedFrame->selection().revealSelection();
+
+    updateFindIndicator(*selectedFrame, !!m_findPageOverlay);
+}
+
</ins><span class="cx"> void FindController::hideFindUI()
</span><span class="cx"> {
</span><span class="cx">     m_findMatches.clear();
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageFindControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/FindController.h (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/FindController.h  2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebKit/WebProcess/WebPage/FindController.h     2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx">     void findStringMatches(const String&, FindOptions, unsigned maxMatchCount);
</span><span class="cx">     void getImageForFindMatch(uint32_t matchIndex);
</span><span class="cx">     void selectFindMatch(uint32_t matchIndex);
</span><ins>+    void indicateFindMatch(uint32_t matchIndex);
</ins><span class="cx">     void hideFindUI();
</span><span class="cx">     void countStringMatches(const String&, FindOptions, unsigned maxMatchCount);
</span><span class="cx">     uint32_t replaceMatches(const Vector<uint32_t>& matchIndices, const String& replacementText, bool selectionOnly);
</span><span class="lines">@@ -83,7 +84,8 @@
</span><span class="cx">     Vector<WebCore::FloatRect> rectsForTextMatchesInRect(WebCore::IntRect clipRect);
</span><span class="cx">     bool updateFindIndicator(WebCore::Frame& selectedFrame, bool isShowingOverlay, bool shouldAnimate = true);
</span><span class="cx"> 
</span><del>-    void updateFindUIAfterPageScroll(bool found, const String&, FindOptions, unsigned maxMatchCount, WebCore::DidWrap);
</del><ins>+    enum class FindUIOriginator : uint8_t { FindString, FindStringMatches };
+    void updateFindUIAfterPageScroll(bool found, const String&, FindOptions, unsigned maxMatchCount, WebCore::DidWrap, FindUIOriginator);
</ins><span class="cx"> 
</span><span class="cx">     void willFindString();
</span><span class="cx">     void didFindString();
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp       2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp  2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -4087,6 +4087,11 @@
</span><span class="cx">     findController().selectFindMatch(matchIndex);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPage::indicateFindMatch(uint32_t matchIndex)
+{
+    findController().indicateFindMatch(matchIndex);
+}
+
</ins><span class="cx"> void WebPage::hideFindUI()
</span><span class="cx"> {
</span><span class="cx">     findController().hideFindUI();
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h    2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -1438,6 +1438,7 @@
</span><span class="cx">     void findStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
</span><span class="cx">     void getImageForFindMatch(uint32_t matchIndex);
</span><span class="cx">     void selectFindMatch(uint32_t matchIndex);
</span><ins>+    void indicateFindMatch(uint32_t matchIndex);
</ins><span class="cx">     void hideFindUI();
</span><span class="cx">     void countStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
</span><span class="cx">     void replaceMatches(const Vector<uint32_t>& matchIndices, const String& replacementText, bool selectionOnly, CallbackID);
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in       2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in  2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -284,6 +284,7 @@
</span><span class="cx">     FindStringMatches(String string, uint32_t findOptions, unsigned maxMatchCount)
</span><span class="cx">     GetImageForFindMatch(uint32_t matchIndex)
</span><span class="cx">     SelectFindMatch(uint32_t matchIndex)
</span><ins>+    IndicateFindMatch(uint32_t matchIndex)
</ins><span class="cx">     HideFindUI()
</span><span class="cx">     CountStringMatches(String string, uint32_t findOptions, unsigned maxMatchCount)
</span><span class="cx">     ReplaceMatches(Vector<uint32_t> matchIndices, String replacementText, bool selectionOnly, WebKit::CallbackID callbackID)
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Tools/ChangeLog       2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2019-07-16  Tim Horton  <timothy_horton@apple.com>
+
+        NSTextFinder holes don't scroll with the page
+        https://bugs.webkit.org/show_bug.cgi?id=199815
+        <rdar://problem/52280514>
+
+        Reviewed by Simon Fraser.
+
+        * MiniBrowser/mac/WK2BrowserWindowController.m:
+        (-[MiniBrowserNSTextFinder performAction:]):
+        (-[WK2BrowserWindowController awakeFromNib]):
+        Adopt the WebKit UI in MiniBrowser. Also, override NSTextFinder's
+        -performAction: so that we can intercept the close action and
+        hide our own find UI, since there is no delegate for that action yet.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm:
+        (TEST):
+
</ins><span class="cx"> 2019-07-15  Keith Miller  <keith_miller@apple.com>
</span><span class="cx"> 
</span><span class="cx">         JSGlobalObject type macros should support feature flags and WeakRef should have one
</span></span></pre></div>
<a id="trunkToolsMiniBrowsermacWK2BrowserWindowControllerm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m 2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m    2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -47,6 +47,24 @@
</span><span class="cx"> static const int testHeaderBannerHeight = 42;
</span><span class="cx"> static const int testFooterBannerHeight = 58;
</span><span class="cx"> 
</span><ins>+@interface MiniBrowserNSTextFinder : NSTextFinder
+
+@property (nonatomic, copy) dispatch_block_t hideInterfaceCallback;
+
+@end
+
+@implementation MiniBrowserNSTextFinder
+
+- (void)performAction:(NSTextFinderAction)op
+{
+    [super performAction:op];
+
+    if (op == NSTextFinderActionHideFindInterface && _hideInterfaceCallback)
+        _hideInterfaceCallback();
+}
+
+@end
+
</ins><span class="cx"> @interface WK2BrowserWindowController () <NSTextFinderBarContainer, WKNavigationDelegate, WKUIDelegate, _WKIconLoadingDelegate>
</span><span class="cx"> @end
</span><span class="cx"> 
</span><span class="lines">@@ -58,7 +76,7 @@
</span><span class="cx"> 
</span><span class="cx">     BOOL _useShrinkToFit;
</span><span class="cx"> 
</span><del>-    NSTextFinder *_textFinder;
</del><ins>+    MiniBrowserNSTextFinder *_textFinder;
</ins><span class="cx">     NSView *_textFindBarView;
</span><span class="cx">     BOOL _findBarVisible;
</span><span class="cx"> }
</span><span class="lines">@@ -97,11 +115,16 @@
</span><span class="cx"> 
</span><span class="cx">     _zoomTextOnly = NO;
</span><span class="cx"> 
</span><del>-    _textFinder = [[NSTextFinder alloc] init];
</del><ins>+    _webView._usePlatformFindUI = NO;
+
+    _textFinder = [[MiniBrowserNSTextFinder alloc] init];
</ins><span class="cx">     _textFinder.incrementalSearchingEnabled = YES;
</span><del>-    _textFinder.incrementalSearchingShouldDimContentView = YES;
</del><ins>+    _textFinder.incrementalSearchingShouldDimContentView = NO;
</ins><span class="cx">     _textFinder.client = _webView;
</span><span class="cx">     _textFinder.findBarContainer = self;
</span><ins>+    _textFinder.hideInterfaceCallback = ^{
+        [_webView _hideFindUI];
+    };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (instancetype)initWithConfiguration:(WKWebViewConfiguration *)configuration
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaFindInPagemm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm (247489 => 247490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm        2019-07-16 18:56:39 UTC (rev 247489)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm   2019-07-16 19:46:32 UTC (rev 247490)
</span><span class="lines">@@ -142,6 +142,37 @@
</span><span class="cx">     EXPECT_EQ((NSUInteger)1000, [result.matches count]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TEST(WebKit, FindInPageWithPlatformPresentation)
+{
+    // This should be the same as above, but does not generate rects or images, so that AppKit won't paint its find UI.
+
+    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 200, 200)]);
+    [webView _setOverrideDeviceScaleFactor:2];
+    [webView _setUsePlatformFindUI:NO];
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"lots-of-text" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    [webView loadRequest:request];
+    [webView _test_waitForDidFinishNavigation];
+
+    // Find all matches, but recieve no rects.
+    auto result = findMatches(webView.get(), @"Birthday");
+    EXPECT_EQ((NSUInteger)360, [result.matches count]);
+    RetainPtr<FindMatch> match = [result.matches objectAtIndex:0];
+    EXPECT_EQ((NSUInteger)0, [match textRects].count);
+
+    // Ensure that no image is generated.
+    __block bool generateTextImageDone = false;
+    [match generateTextImage:^(NSImage *image) {
+        EXPECT_EQ(image, nullptr);
+        generateTextImageDone = true;
+    }];
+    TestWebKitAPI::Util::run(&generateTextImageDone);
+
+    // Ensure that we cap the number of matches. There are actually 1600, but we only get the first 1000.
+    result = findMatches(webView.get(), @" ");
+    EXPECT_EQ((NSUInteger)1000, [result.matches count]);
+}
+
</ins><span class="cx"> TEST(WebKit, FindInPageWrapping)
</span><span class="cx"> {
</span><span class="cx">     RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]);
</span></span></pre>
</div>
</div>

</body>
</html>