REGRESSION(r245148): Removing inputmode="none" does not bring up software keyboard
https://bugs.webkit.org/show_bug.cgi?id=198141
Reviewed by Geoffrey Garen.
Source/WebKit:
r245148 changed _requiresKeyboardWhenFirstResponder to return NO when shouldShowAutomaticKeyboardUI
returns NO with regards to software keyboard. This introduced a regression that removing inputmode="none"
no longer brings up the software keyboard. Fixed the bug by making it return YES when inputmode="none"
is present on an editable element in shouldShowAutomaticKeyboardUI, partially restoring the old behavior.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView shouldShowAutomaticKeyboardUI]):
(-[WKContentView _shouldShowAutomaticKeyboardUIIgnoringInputMode]):
(-[WKContentView _requiresKeyboardWhenFirstResponder]):
LayoutTests:
Added a regression test.
* fast/forms/ios/inputmode-removing-none-expected.txt: Added.
* fast/forms/ios/inputmode-removing-none.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@245661 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 1df60b4..34b9ba7 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2019-05-22 Ryosuke Niwa <rniwa@webkit.org>
+
+ REGRESSION(r245148): Removing inputmode="none" does not bring up software keyboard
+ https://bugs.webkit.org/show_bug.cgi?id=198141
+
+ Reviewed by Geoffrey Garen.
+
+ Added a regression test.
+
+ * fast/forms/ios/inputmode-removing-none-expected.txt: Added.
+ * fast/forms/ios/inputmode-removing-none.html: Added.
+
2019-05-22 Simon Fraser <simon.fraser@apple.com>
<rdar://problem/50058173> REGRESSION (r243347) Layout tests fast/events/touch/ios/drag-block-without-overflow-scroll-and-passive-observer-on* are failing
diff --git a/LayoutTests/fast/forms/ios/inputmode-removing-none-expected.txt b/LayoutTests/fast/forms/ios/inputmode-removing-none-expected.txt
new file mode 100644
index 0000000..b45ac03
--- /dev/null
+++ b/LayoutTests/fast/forms/ios/inputmode-removing-none-expected.txt
@@ -0,0 +1,18 @@
+This tests removing inputmode="none" from an input element after the element was focused.
+To manually test, detach a hardware keyboard and tap on the text field below. The software keyboard should come up.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+ACTIVATE input with inputmode=none
+PASS systemKeyboardRect.height is 0
+PASS input.value is "hello,"
+
+Removing inputmode=none
+PASS systemKeyboardRect.height > 0 is true
+PASS input.value is "hello, world"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/ios/inputmode-removing-none.html b/LayoutTests/fast/forms/ios/inputmode-removing-none.html
new file mode 100644
index 0000000..4eee32c
--- /dev/null
+++ b/LayoutTests/fast/forms/ios/inputmode-removing-none.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+<script src="../../../resources/js-test.js"></script>
+<script src="../../../resources/ui-helper.js"></script>
+</head>
+<body>
+<input inputmode="none">
+<script>
+
+description(`This tests removing inputmode="none" from an input element after the element was focused.<br>
+To manually test, detach a hardware keyboard and tap on the text field below. The software keyboard should come up.`);
+
+jsTestIsAsync = true;
+
+const input = document.querySelector('input');
+if (window.testRunner)
+ window.onload = runTest;
+else
+ input.addEventListener('click', () => this.removeAttribute('inputmode'));
+
+let systemKeyboardRect;
+async function runTest() {
+ await UIHelper.setHardwareKeyboardAttached(false);
+
+ // We insert a dummy input element to detect when the keyboard hides for an input element with inputmode="none".
+ const dummyInput = document.createElement('input');
+ document.body.appendChild(dummyInput);
+ await UIHelper.activateElementAndWaitForInputSession(dummyInput);
+
+ debug("\nACTIVATE input with inputmode=none");
+ input.focus();
+ await UIHelper.activateElement(input);
+ await UIHelper.waitForKeyboardToHide();
+ systemKeyboardRect = await UIHelper.inputViewBounds();
+ shouldBe("systemKeyboardRect.height", "0");
+
+ await UIHelper.enterText("hello,");
+ shouldBeEqualToString("input.value", "hello,");
+
+ debug("\nRemoving inputmode=none");
+ input.removeAttribute('inputmode');
+
+ await new Promise((resolve) => {
+ window.visualViewport.addEventListener('resize', resolve);
+ setTimeout(resolve, 3000); // Failed.
+ });
+
+ systemKeyboardRect = await UIHelper.inputViewBounds();
+ shouldBeTrue("systemKeyboardRect.height > 0");
+
+ await UIHelper.enterText(" world");
+ shouldBeEqualToString("input.value", "hello, world");
+
+ finishJSTest();
+}
+
+</script>
+</body>
+</html>
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index 430d490..aaf5925 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,20 @@
+2019-05-22 Ryosuke Niwa <rniwa@webkit.org>
+
+ REGRESSION(r245148): Removing inputmode="none" does not bring up software keyboard
+ https://bugs.webkit.org/show_bug.cgi?id=198141
+
+ Reviewed by Geoffrey Garen.
+
+ r245148 changed _requiresKeyboardWhenFirstResponder to return NO when shouldShowAutomaticKeyboardUI
+ returns NO with regards to software keyboard. This introduced a regression that removing inputmode="none"
+ no longer brings up the software keyboard. Fixed the bug by making it return YES when inputmode="none"
+ is present on an editable element in shouldShowAutomaticKeyboardUI, partially restoring the old behavior.
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView shouldShowAutomaticKeyboardUI]):
+ (-[WKContentView _shouldShowAutomaticKeyboardUIIgnoringInputMode]):
+ (-[WKContentView _requiresKeyboardWhenFirstResponder]):
+
2019-05-22 Tim Horton <timothy_horton@apple.com>
REGRESSION (r240552): PDF contents are not exposed to Accessibility (VO, etc.)
diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
index 4e82322..cdb8c7a 100644
--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
@@ -1640,6 +1640,11 @@
if (_focusedElementInformation.inputMode == WebCore::InputMode::None && !GSEventIsHardwareKeyboardAttached())
return NO;
+ return [self _shouldShowAutomaticKeyboardUIIgnoringInputMode];
+}
+
+- (BOOL)_shouldShowAutomaticKeyboardUIIgnoringInputMode
+{
switch (_focusedElementInformation.elementType) {
case WebKit::InputType::None:
case WebKit::InputType::Drawing:
@@ -1671,7 +1676,7 @@
- (BOOL)_requiresKeyboardWhenFirstResponder
{
// FIXME: We should add the logic to handle keyboard visibility during focus redirects.
- return [self shouldShowAutomaticKeyboardUI]
+ return [self _shouldShowAutomaticKeyboardUIIgnoringInputMode]
#if USE(UIKIT_KEYBOARD_ADDITIONS)
|| _seenHardwareKeyDownInNonEditableElement
#endif