iOS: inputmode=none is not respected with a hardware keyboard attached
https://bugs.webkit.org/show_bug.cgi?id=203061

Reviewed by Daniel Bates.

Source/WebKit:

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView shouldShowAutomaticKeyboardUI]):
We can resolve this FIXME, as the underlying bug was fixed in <rdar://problem/52706523>.
This now means that we will respect inputmode=none even when a hardware
keyboard is attached, significantly improving the experience on sites that use it
by avoiding an intermittent input bar.

LayoutTests:

* fast/forms/ios/inputmode-none-with-hardware-keyboard.html: Added.
Clone inputmode-none.html to inputmode-none-with-hardware-keyboard.html
and remove the line to faux-detach the hardware keyboard.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251218 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 791daa6..92e351b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2019-10-16  Tim Horton  <timothy_horton@apple.com>
+
+        iOS: inputmode=none is not respected with a hardware keyboard attached
+        https://bugs.webkit.org/show_bug.cgi?id=203061
+
+        Reviewed by Daniel Bates.
+
+        * fast/forms/ios/inputmode-none-with-hardware-keyboard.html: Added.
+        Clone inputmode-none.html to inputmode-none-with-hardware-keyboard.html
+        and remove the line to faux-detach the hardware keyboard.
+
 2019-10-16  John Wilander  <wilander@apple.com>
 
         Resource Load Statistics (experimental): Block all third-party cookies on websites without prior user interaction
diff --git a/LayoutTests/fast/forms/ios/inputmode-none-with-hardware-keyboard.html b/LayoutTests/fast/forms/ios/inputmode-none-with-hardware-keyboard.html
new file mode 100644
index 0000000..70de08c
--- /dev/null
+++ b/LayoutTests/fast/forms/ios/inputmode-none-with-hardware-keyboard.html
@@ -0,0 +1,54 @@
+<!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 onload="runTest()">
+<div><input id="input-keyboard" inputmode="text"></div>
+<div><input id="input-nokeyboard" inputmode="none"></div>
+<pre id="description"></pre>
+<pre id="console"></pre>
+<script>
+jsTestIsAsync = true;
+
+async function runTest() {
+    inputWithSystemKeyboard = document.getElementById("input-keyboard");
+    inputWithoutSystemKeyboard = document.getElementById("input-nokeyboard");
+
+    description("This test verifies that the system keyboard is not visible when tapping on an input field with inputmode=none.");
+
+    debug("\nACTIVATE input with inputmode=text");
+    await UIHelper.activateElementAndWaitForInputSession(inputWithSystemKeyboard);
+    systemKeyboardRect = await UIHelper.inputViewBounds();
+    shouldBe("systemKeyboardRect.height > 0", "true");
+    await UIHelper.enterText("Text");
+    shouldBe("inputWithSystemKeyboard.value", "'Text'");
+
+    debug("\nACTIVATE input with inputmode=none");
+    await UIHelper.activateElement(inputWithoutSystemKeyboard);
+    await UIHelper.waitForKeyboardToHide();
+    testPassed("Successfully dismissed keyboard");
+
+    debug("\nTEST enter text in input with inputmode=none");
+    await UIHelper.enterText("None");
+    shouldBe("inputWithoutSystemKeyboard.value", "'None'");
+
+    debug("\nTEST selection in input with inputmode=none");
+    inputWithoutSystemKeyboard.select();
+
+    selectionRects = [];
+    while (!selectionRects.length)
+        selectionRects = await UIHelper.getUISelectionViewRects();
+
+    shouldBe("selectionRects.length", "1");
+    shouldBe("selectionRects[0].left", "16");
+    shouldBe("selectionRects[0].top", "38");
+    shouldBe("selectionRects[0].width", "27");
+    shouldBe("selectionRects[0].height", "15");
+    finishJSTest();
+}
+</script>
+</body>
+</html>
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index 3b7476f..f1b6258 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,17 @@
+2019-10-16  Tim Horton  <timothy_horton@apple.com>
+
+        iOS: inputmode=none is not respected with a hardware keyboard attached
+        https://bugs.webkit.org/show_bug.cgi?id=203061
+
+        Reviewed by Daniel Bates.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView shouldShowAutomaticKeyboardUI]):
+        We can resolve this FIXME, as the underlying bug was fixed in <rdar://problem/52706523>.
+        This now means that we will respect inputmode=none even when a hardware
+        keyboard is attached, significantly improving the experience on sites that use it
+        by avoiding an intermittent input bar.
+
 2019-10-16  Per Arne Vollan  <pvollan@apple.com>
 
         [iOS] Remove send-signal from mach-lookup rule
diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
index b2d5503..76ce342 100644
--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
@@ -1797,10 +1797,7 @@
 
 - (BOOL)shouldShowAutomaticKeyboardUI
 {
-    // FIXME: We should support inputmode="none" when the hardware keyboard is attached.
-    // We currently refrain from doing so because that would prevent UIKit from showing
-    // the language picker when pressing the globe key to change the input language.
-    if (_focusedElementInformation.inputMode == WebCore::InputMode::None && !GSEventIsHardwareKeyboardAttached())
+    if (_focusedElementInformation.inputMode == WebCore::InputMode::None)
         return NO;
 
     return [self _shouldShowAutomaticKeyboardUIIgnoringInputMode];