- Revision
- 251111
- Author
- commit-qu...@webkit.org
- Date
- 2019-10-14 16:42:38 -0700 (Mon, 14 Oct 2019)
Log Message
FindController::findString always updates foundStringMatchIndex even if match is the same as before
https://bugs.webkit.org/show_bug.cgi?id=201775
<rdar://problem/55352425>
Patch by Matt Mokary <mmok...@apple.com> on 2019-10-14
Reviewed by Tim Horton.
Source/WebKit:
Allow an update to a find string without changing current match index, as is often the desired behavior when
modifying a query rather than moving forward or backward through a match set.
* Shared/WebFindOptions.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(toFindOptions):
* UIProcess/API/Cocoa/_WKFindOptions.h:
* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::findString):
Do not change match index if NoIndexChange bit is set. Otherwise, no change in behavior.
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/WKWebViewFindString.mm:
(TestWebKitAPI::TEST):
_WKFindOptionsNoIndexChange test
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (251110 => 251111)
--- trunk/Source/WebKit/ChangeLog 2019-10-14 23:38:07 UTC (rev 251110)
+++ trunk/Source/WebKit/ChangeLog 2019-10-14 23:42:38 UTC (rev 251111)
@@ -1,3 +1,22 @@
+2019-10-14 Matt Mokary <mmok...@apple.com>
+
+ FindController::findString always updates foundStringMatchIndex even if match is the same as before
+ https://bugs.webkit.org/show_bug.cgi?id=201775
+ <rdar://problem/55352425>
+
+ Reviewed by Tim Horton.
+
+ Allow an update to a find string without changing current match index, as is often the desired behavior when
+ modifying a query rather than moving forward or backward through a match set.
+
+ * Shared/WebFindOptions.h:
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (toFindOptions):
+ * UIProcess/API/Cocoa/_WKFindOptions.h:
+ * WebProcess/WebPage/FindController.cpp:
+ (WebKit::FindController::findString):
+ Do not change match index if NoIndexChange bit is set. Otherwise, no change in behavior.
+
2019-10-14 David Quesada <david_ques...@apple.com>
Remove WebCore::IOSApplication::isWebApp()
Modified: trunk/Source/WebKit/Shared/WebFindOptions.h (251110 => 251111)
--- trunk/Source/WebKit/Shared/WebFindOptions.h 2019-10-14 23:38:07 UTC (rev 251110)
+++ trunk/Source/WebKit/Shared/WebFindOptions.h 2019-10-14 23:42:38 UTC (rev 251111)
@@ -37,6 +37,7 @@
FindOptionsShowFindIndicator = 1 << 6,
FindOptionsShowHighlight = 1 << 7,
FindOptionsDetermineMatchIndex = 1 << 8,
+ FindOptionsNoIndexChange = 1 << 9,
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (251110 => 251111)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2019-10-14 23:38:07 UTC (rev 251110)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2019-10-14 23:42:38 UTC (rev 251111)
@@ -5660,6 +5660,8 @@
findOptions |= WebKit::FindOptionsShowFindIndicator;
if (wkFindOptions & _WKFindOptionsShowHighlight)
findOptions |= WebKit::FindOptionsShowHighlight;
+ if (wkFindOptions & _WKFindOptionsNoIndexChange)
+ findOptions |= WebKit::FindOptionsNoIndexChange;
if (wkFindOptions & _WKFindOptionsDetermineMatchIndex)
findOptions |= WebKit::FindOptionsDetermineMatchIndex;
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKFindOptions.h (251110 => 251111)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKFindOptions.h 2019-10-14 23:38:07 UTC (rev 251110)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKFindOptions.h 2019-10-14 23:42:38 UTC (rev 251111)
@@ -34,7 +34,8 @@
_WKFindOptionsShowOverlay = 1 << 5,
_WKFindOptionsShowFindIndicator = 1 << 6,
_WKFindOptionsShowHighlight = 1 << 7,
- _WKFindOptionsDetermineMatchIndex = 1 << 8,
+ _WKFindOptionsNoIndexChange = 1 << 8,
+ _WKFindOptionsDetermineMatchIndex = 1 << 9,
_WKFindOptionsIrrelevantForIncrementalResults = _WKFindOptionsShowOverlay | _WKFindOptionsShowFindIndicator | _WKFindOptionsShowHighlight | _WKFindOptionsDetermineMatchIndex,
_WKFindOptionsIrrelevantForBatchResults = _WKFindOptionsBackwards | _WKFindOptionsWrapAround | _WKFindOptionsIrrelevantForIncrementalResults
Modified: trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp (251110 => 251111)
--- trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp 2019-10-14 23:38:07 UTC (rev 251110)
+++ trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp 2019-10-14 23:42:38 UTC (rev 251111)
@@ -268,7 +268,7 @@
if (!foundStringStartsAfterSelection) {
if (options & FindOptionsBackwards)
m_foundStringMatchIndex--;
- else
+ else if (!(options & FindOptionsNoIndexChange))
m_foundStringMatchIndex++;
}
}
Modified: trunk/Tools/ChangeLog (251110 => 251111)
--- trunk/Tools/ChangeLog 2019-10-14 23:38:07 UTC (rev 251110)
+++ trunk/Tools/ChangeLog 2019-10-14 23:42:38 UTC (rev 251111)
@@ -1,3 +1,15 @@
+2019-10-14 Matt Mokary <mmok...@apple.com>
+
+ FindController::findString always updates foundStringMatchIndex even if match is the same as before
+ https://bugs.webkit.org/show_bug.cgi?id=201775
+ <rdar://problem/55352425>
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewFindString.mm:
+ (TestWebKitAPI::TEST):
+ _WKFindOptionsNoIndexChange test
+
2019-10-14 Andy Estes <aes...@apple.com>
REGRESSION (r243682): Quick Look previews loaded from the memory cache render with the wrong content type
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewFindString.mm (251110 => 251111)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewFindString.mm 2019-10-14 23:38:07 UTC (rev 251110)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewFindString.mm 2019-10-14 23:42:38 UTC (rev 251111)
@@ -170,4 +170,23 @@
}
#endif
+TEST(WKWebViewFindString, DoNotUpdateMatchIndexWhenGivenNoIndexChangeOption)
+{
+ auto findDelegate = adoptNS([[WKWebViewFindStringFindDelegate alloc] init]);
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ auto firstWebView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 300, 200) configuration:configuration.get() addToWindow:YES]);
+ [firstWebView synchronouslyLoadHTMLString:@"<p>hello</p><p>hello</p>"];
+ [firstWebView _setFindDelegate:findDelegate.get()];
+
+ [firstWebView _findString:@"hello" options:0 maxCount:maxCount];
+ Util::run(&isDone);
+
+ EXPECT_EQ(0, [findDelegate matchIndex]);
+
+ [firstWebView _findString:@"hello" options:_WKFindOptionsNoIndexChange maxCount:maxCount];
+ Util::run(&isDone);
+
+ EXPECT_EQ(0, [findDelegate matchIndex]);
+}
+
} // namespace TestWebKitAPI