Title: [293519] trunk
- Revision
- 293519
- Author
- [email protected]
- Date
- 2022-04-27 10:36:08 -0700 (Wed, 27 Apr 2022)
Log Message
[iOS] Focus changes unexpectedly when scrolling to a found text range
https://bugs.webkit.org/show_bug.cgi?id=239793
rdar://90996437
Reviewed by Wenson Hsieh.
Source/WebKit:
* WebProcess/WebPage/WebFoundTextRangeController.cpp:
(WebKit::WebFoundTextRangeController::scrollTextRangeToVisible):
Specify `DoNotSetFocus` in the `TemporarySelectionOption`s to avoid
unnecessary focus changes when scrolling to a found text range.
Focus changes can cause the web view to regain first responder status
while searching for text, which will dismiss the find panel and end
the search session.
Tools:
Add an API test to ensure that scrolling to a found range does not
change focus.
* TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm:
(TEST):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (293518 => 293519)
--- trunk/Source/WebKit/ChangeLog 2022-04-27 17:30:22 UTC (rev 293518)
+++ trunk/Source/WebKit/ChangeLog 2022-04-27 17:36:08 UTC (rev 293519)
@@ -1,3 +1,21 @@
+2022-04-27 Aditya Keerthi <[email protected]>
+
+ [iOS] Focus changes unexpectedly when scrolling to a found text range
+ https://bugs.webkit.org/show_bug.cgi?id=239793
+ rdar://90996437
+
+ Reviewed by Wenson Hsieh.
+
+ * WebProcess/WebPage/WebFoundTextRangeController.cpp:
+ (WebKit::WebFoundTextRangeController::scrollTextRangeToVisible):
+
+ Specify `DoNotSetFocus` in the `TemporarySelectionOption`s to avoid
+ unnecessary focus changes when scrolling to a found text range.
+
+ Focus changes can cause the web view to regain first responder status
+ while searching for text, which will dismiss the find panel and end
+ the search session.
+
2022-04-27 Per Arne Vollan <[email protected]>
[macOS] The function getpwnam can sometimes fail
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp (293518 => 293519)
--- trunk/Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp 2022-04-27 17:30:22 UTC (rev 293518)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp 2022-04-27 17:36:08 UTC (rev 293519)
@@ -154,7 +154,7 @@
return;
WebCore::VisibleSelection visibleSelection(*simpleRange);
- OptionSet temporarySelectionOptions { WebCore::TemporarySelectionOption::DelegateMainFrameScroll, WebCore::TemporarySelectionOption::RevealSelectionBounds };
+ OptionSet temporarySelectionOptions { WebCore::TemporarySelectionOption::DelegateMainFrameScroll, WebCore::TemporarySelectionOption::RevealSelectionBounds, WebCore::TemporarySelectionOption::DoNotSetFocus };
if (document->isTopDocument())
temporarySelectionOptions.add(WebCore::TemporarySelectionOption::SmoothScroll);
Modified: trunk/Tools/ChangeLog (293518 => 293519)
--- trunk/Tools/ChangeLog 2022-04-27 17:30:22 UTC (rev 293518)
+++ trunk/Tools/ChangeLog 2022-04-27 17:36:08 UTC (rev 293519)
@@ -1,3 +1,17 @@
+2022-04-27 Aditya Keerthi <[email protected]>
+
+ [iOS] Focus changes unexpectedly when scrolling to a found text range
+ https://bugs.webkit.org/show_bug.cgi?id=239793
+ rdar://90996437
+
+ Reviewed by Wenson Hsieh.
+
+ Add an API test to ensure that scrolling to a found range does not
+ change focus.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm:
+ (TEST):
+
2022-04-27 Jonathan Bedard <[email protected]>
test-webkitpy TestInstallGitLFS fails
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm (293518 => 293519)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm 2022-04-27 17:30:22 UTC (rev 293518)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm 2022-04-27 17:36:08 UTC (rev 293519)
@@ -35,6 +35,7 @@
#import <wtf/RetainPtr.h>
#if PLATFORM(IOS_FAMILY)
+#import "TestInputDelegate.h"
#import "UIKitSPI.h"
#endif
@@ -610,4 +611,38 @@
EXPECT_TRUE(CGPointEqualToPoint([webView scrollView].contentOffset, CGPointMake(0, 664)));
}
+TEST(WebKit, ScrollToFoundRangeDoesNotFocusElement)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)]);
+ [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width,initial-scale=1'><input id='input'><div id='editor' contenteditable><p>Top</p><p style='margin-top: 800px'>Bottom</p></div>"];
+
+ auto scrollViewDelegate = adoptNS([[TestScrollViewDelegate alloc] init]);
+ [webView scrollView].delegate = scrollViewDelegate.get();
+
+ bool inputFocused = false;
+
+ auto inputDelegate = adoptNS([TestInputDelegate new]);
+ [inputDelegate setFocusStartsInputSessionPolicyHandler:[&inputFocused] (WKWebView *, id<_WKFocusedElementInfo> focusedElementInfo) -> _WKFocusStartsInputSessionPolicy {
+ switch (focusedElementInfo.type) {
+ case WKInputTypeText:
+ inputFocused = true;
+ break;
+ default:
+ ADD_FAILURE() << "Unexpected focus change.";
+ break;
+ }
+
+ return _WKFocusStartsInputSessionPolicyAllow;
+ }];
+ [webView _setInputDelegate:inputDelegate.get()];
+
+ [webView evaluateJavaScript:@"document.getElementById('input').focus()" completionHandler:nil];
+ TestWebKitAPI::Util::run(&inputFocused);
+
+ auto ranges = textRangesForQueryString(webView.get(), @"Bottom");
+ [webView scrollRangeToVisible:[ranges firstObject] inDocument:nil];
+
+ TestWebKitAPI::Util::run(&scrollViewDelegate->_finishedScrolling);
+}
+
#endif // HAVE(UIFINDINTERACTION)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes