[iOS] Software keyboard is shown too frequently on some websites
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Apr 2019 17:30:00 +0000 (17:30 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Apr 2019 17:30:00 +0000 (17:30 +0000)
commit0356b8a37882d1b209bb24a7bbf8b87e0ee4c105
tree10a30284cb4c0615721b759d09f4d4276f152739
parent35b1d50a7b1d309f3a6ea1700936d8bfcff9307d
[iOS] Software keyboard is shown too frequently on some websites
https://bugs.webkit.org/show_bug.cgi?id=195856
<rdar://problem/49191395>

Reviewed by Darin Adler.

Source/WebCore/PAL:

Declare new GraphicsServices SPI.

* pal/spi/ios/GraphicsServicesSPI.h:

Source/WebKit:

On some websites, hidden editable elements are very frequently focused upon user interaction. Currently, this
causes the software keyboard to pop in and out unexpectedly; luckily, these same sites also apply
inputmode="none" to the hidden editable element, which ought to ensure that the software keyboard doesn't appear
when the element is focused.

However, since we disabled support for inputmode="none" in r240497, the software keyboard is no longer
suppressed, and becomes a big nuissance. r240497 removed support for this feature because, when using a hardware
keyboard, pressing the globe key no longer showed UI for switching languages. However, support for inputmode
none makes a much larger impact when a software keyboard is used (since the entire software keyboard animates in
and out), whereas a hardware keyboard only displays an input accessory view. For this reason, we can mitigate
this bug without reintroducing <rdar://problem/47406553> by re-enabling inputmode="none", but only when a
hardware keyboard is not attached.

* UIProcess/API/Cocoa/WKWebView.mm:
(hardwareKeyboardAvailabilityChangedCallback):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView shouldShowAutomaticKeyboardUI]):

Don't show the keyboard if inputmode is none and a hardware keyboard is not attached.

(-[WKContentView _hardwareKeyboardAvailabilityChanged]):

Reload input views if the inputmode is none to ensure that if a hardware keyboard is attached while editing an
element with inputmode="none", we'll show the input accessory view once again.

Tools:

Add support for attaching or detaching the hardware keyboard on iOS in layout tests.

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::setHardwareKeyboardAttached):
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::setHardwareKeyboardAttached):
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/Configurations/WebKitTestRunnerApp.xcconfig:

Additionally link against GraphicsServices in WebKitTestRunner.

* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::TestController::platformResetStateToConsistentValues):
(WTR::UIScriptController::setHardwareKeyboardAttached):

WebKitLibraries:

Add a symbol for GSEventSetHardwareKeyboardAttached.

* WebKitPrivateFrameworkStubs/iOS/12/GraphicsServices.framework/GraphicsServices.tbd:

LayoutTests:

Fix a failing layout test, which (among other reasons) is currently failing because support for inputmode="none"
is disabled.

* fast/forms/ios/inputmode-none-expected.txt:
* fast/forms/ios/inputmode-none.html:
* resources/ui-helper.js:

Add a UIHelper method for attaching or detaching the hardware keyboard.

(window.UIHelper.setHardwareKeyboardAttached):
(window.UIHelper):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244220 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/ios/inputmode-none-expected.txt
LayoutTests/fast/forms/ios/inputmode-none.html
LayoutTests/resources/ui-helper.js
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/ios/GraphicsServicesSPI.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Tools/ChangeLog
Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm
Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
Tools/WebKitTestRunner/Configurations/WebKitTestRunnerApp.xcconfig
Tools/WebKitTestRunner/ios/TestControllerIOS.mm
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/12/GraphicsServices.framework/GraphicsServices.tbd