Title: [290543] trunk
- Revision
- 290543
- Author
- [email protected]
- Date
- 2022-02-25 21:38:48 -0800 (Fri, 25 Feb 2022)
Log Message
Adjust -[WKContentView _requiresKeyboardWhenFirstResponder] to account for editable web views
https://bugs.webkit.org/show_bug.cgi?id=237226
rdar://89447095
Reviewed by Aditya Keerthi.
Source/WebKit:
Adjust the implementation of `-[WKContentView _requiresKeyboardWhenFirstResponder]`, such that it returns YES
for editable web views, except for the scenario where an input field that does *not* require the automatic
keyboard is currently focused in the page inside the editable web view (e.g. a `readonly` text field).
UIKit consults this method to know whether or not a given responder would require the keyboard (either software
keyboard or the minimized UCB for hardware keyboard) if it were to become the first responder. For web views
that are made editable in the SPI sense, we know a-priori that this should return YES, unless a readonly element
underneath the web view has focus (in which case, `_disableAutomaticKeyboardUI` would be true).
Test: KeyboardInputTests.EditableWebViewRequiresKeyboardWhenFirstResponder
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _requiresKeyboardWhenFirstResponder]):
Tools:
Add an API test to exercise the change. This new API test is comprised of 3 parts:
- Verify that `-_requiresKeyboardWhenFirstResponder` is NO after loading the page.
- Verify that `-_requiresKeyboardWhenFirstResponder` becomes YES after making the web view editable.
- Verify that `-_requiresKeyboardWhenFirstResponder` is NO again after focusing a readonly input inside the
now-editable web view.
* TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/ios/UIKitSPI.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (290542 => 290543)
--- trunk/Source/WebKit/ChangeLog 2022-02-26 05:05:55 UTC (rev 290542)
+++ trunk/Source/WebKit/ChangeLog 2022-02-26 05:38:48 UTC (rev 290543)
@@ -1,3 +1,25 @@
+2022-02-25 Wenson Hsieh <[email protected]>
+
+ Adjust -[WKContentView _requiresKeyboardWhenFirstResponder] to account for editable web views
+ https://bugs.webkit.org/show_bug.cgi?id=237226
+ rdar://89447095
+
+ Reviewed by Aditya Keerthi.
+
+ Adjust the implementation of `-[WKContentView _requiresKeyboardWhenFirstResponder]`, such that it returns YES
+ for editable web views, except for the scenario where an input field that does *not* require the automatic
+ keyboard is currently focused in the page inside the editable web view (e.g. a `readonly` text field).
+
+ UIKit consults this method to know whether or not a given responder would require the keyboard (either software
+ keyboard or the minimized UCB for hardware keyboard) if it were to become the first responder. For web views
+ that are made editable in the SPI sense, we know a-priori that this should return YES, unless a readonly element
+ underneath the web view has focus (in which case, `_disableAutomaticKeyboardUI` would be true).
+
+ Test: KeyboardInputTests.EditableWebViewRequiresKeyboardWhenFirstResponder
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView _requiresKeyboardWhenFirstResponder]):
+
2022-02-25 Said Abou-Hallawa <[email protected]>
[GPU Process] Implement RemoteImageBufferProxy::drawConsuming()
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (290542 => 290543)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2022-02-26 05:05:55 UTC (rev 290542)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2022-02-26 05:38:48 UTC (rev 290543)
@@ -2343,6 +2343,8 @@
- (BOOL)_requiresKeyboardWhenFirstResponder
{
+ if ([_webView _isEditable] && !self._disableAutomaticKeyboardUI)
+ return YES;
// FIXME: We should add the logic to handle keyboard visibility during focus redirects.
return [self _shouldShowAutomaticKeyboardUIIgnoringInputMode] || _seenHardwareKeyDownInNonEditableElement;
}
Modified: trunk/Tools/ChangeLog (290542 => 290543)
--- trunk/Tools/ChangeLog 2022-02-26 05:05:55 UTC (rev 290542)
+++ trunk/Tools/ChangeLog 2022-02-26 05:38:48 UTC (rev 290543)
@@ -1,3 +1,21 @@
+2022-02-25 Wenson Hsieh <[email protected]>
+
+ Adjust -[WKContentView _requiresKeyboardWhenFirstResponder] to account for editable web views
+ https://bugs.webkit.org/show_bug.cgi?id=237226
+ rdar://89447095
+
+ Reviewed by Aditya Keerthi.
+
+ Add an API test to exercise the change. This new API test is comprised of 3 parts:
+ - Verify that `-_requiresKeyboardWhenFirstResponder` is NO after loading the page.
+ - Verify that `-_requiresKeyboardWhenFirstResponder` becomes YES after making the web view editable.
+ - Verify that `-_requiresKeyboardWhenFirstResponder` is NO again after focusing a readonly input inside the
+ now-editable web view.
+
+ * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/ios/UIKitSPI.h:
+
2022-02-25 J Pascoe <[email protected]>
[WebAuthn] Fallback to attestation=none whenever attestation fails
Modified: trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm (290542 => 290543)
--- trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm 2022-02-26 05:05:55 UTC (rev 290542)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm 2022-02-26 05:38:48 UTC (rev 290543)
@@ -871,6 +871,28 @@
[webView waitForNextPresentationUpdate];
}
+TEST(KeyboardInputTests, EditableWebViewRequiresKeyboardWhenFirstResponder)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+ auto delegate = adoptNS([TestInputDelegate new]);
+ [webView _setInputDelegate:delegate.get()];
+ [delegate setFocusStartsInputSessionPolicyHandler:[](WKWebView *, id <_WKFocusedElementInfo>) {
+ return _WKFocusStartsInputSessionPolicyAllow;
+ }];
+
+ auto contentView = [webView textInputContentView];
+ [webView synchronouslyLoadHTMLString:@"<input value='foo' readonly>"];
+ EXPECT_FALSE([contentView _requiresKeyboardWhenFirstResponder]);
+
+ [webView _setEditable:YES];
+ [webView waitForNextPresentationUpdate];
+ EXPECT_TRUE([contentView _requiresKeyboardWhenFirstResponder]);
+
+ [webView stringByEvaluatingJavaScript:@"document.querySelector('input').focus()"];
+ [webView waitForNextPresentationUpdate];
+ EXPECT_FALSE([contentView _requiresKeyboardWhenFirstResponder]);
+}
+
} // namespace TestWebKitAPI
#endif // PLATFORM(IOS_FAMILY)
Modified: trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h (290542 => 290543)
--- trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h 2022-02-26 05:05:55 UTC (rev 290542)
+++ trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h 2022-02-26 05:38:48 UTC (rev 290543)
@@ -318,6 +318,7 @@
@interface UIResponder (Internal)
- (void)_share:(id)sender;
+@property (nonatomic, readonly) BOOL _requiresKeyboardWhenFirstResponder;
@end
@interface UIWebGeolocationPolicyDecider : NSObject
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes