Title: [236619] trunk/Source
Revision
236619
Author
[email protected]
Date
2018-09-28 16:02:41 -0700 (Fri, 28 Sep 2018)

Log Message

[iOS] Allow programmatic focus when hardware keyboard is attached
https://bugs.webkit.org/show_bug.cgi?id=190017
<rdar://problem/42270463>

Reviewed by Wenson Hsieh.

Source/WebCore:

Add support for checking if the embedding client is WebKitTestRunner and export isDumpRenderTree()
so that we can make use of it from WebKit. We will make use of these functions to keep the current
behavior of disallowing programmatic focus when running tests in these apps. This is needed to
keep testing deterministic. Otherwise, test results would be dependent on whether a hardware
keyboard is attached. When running tests in Simulator.app the hardware keyboard may also not be
connected (i.e. Hardware > Keyboard > Connect Hardware Keyboard is disabled).

* platform/RuntimeApplicationChecks.h:
* platform/cocoa/RuntimeApplicationChecksCocoa.mm:
(WebCore::IOSApplication::isWebKitTestRunner): Added.

Source/WebKit:

Make the experience of using iOS with a hardware keyboard more desktop-like by allowing
programmatic focusing of editable elements.

* Platform/spi/ios/UIKitSPI.h: Forward declare SPI.
* Shared/NativeWebKeyboardEvent.h:
* Shared/ios/NativeWebKeyboardEventIOS.mm:
(WebKit::isInHardwareKeyboardMode): Returns whether we are in hardware keyboard mode. In DumpRenderTree
and WebKitTestRunner this function always returns false to keep test results deterministic.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
Allow starting an input session if we are in hardware keyboard mode.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::platformEditorState const): Send the full editor state if we are in hardware
keyboard mode regardless of whether layout has been performed so that UIProcess can update UI,
including the position of the caret, immediately.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (236618 => 236619)


--- trunk/Source/WebCore/ChangeLog	2018-09-28 22:32:56 UTC (rev 236618)
+++ trunk/Source/WebCore/ChangeLog	2018-09-28 23:02:41 UTC (rev 236619)
@@ -1,3 +1,22 @@
+2018-09-28  Daniel Bates  <[email protected]>
+
+        [iOS] Allow programmatic focus when hardware keyboard is attached
+        https://bugs.webkit.org/show_bug.cgi?id=190017
+        <rdar://problem/42270463>
+
+        Reviewed by Wenson Hsieh.
+
+        Add support for checking if the embedding client is WebKitTestRunner and export isDumpRenderTree()
+        so that we can make use of it from WebKit. We will make use of these functions to keep the current
+        behavior of disallowing programmatic focus when running tests in these apps. This is needed to
+        keep testing deterministic. Otherwise, test results would be dependent on whether a hardware
+        keyboard is attached. When running tests in Simulator.app the hardware keyboard may also not be
+        connected (i.e. Hardware > Keyboard > Connect Hardware Keyboard is disabled).
+
+        * platform/RuntimeApplicationChecks.h:
+        * platform/cocoa/RuntimeApplicationChecksCocoa.mm:
+        (WebCore::IOSApplication::isWebKitTestRunner): Added.
+
 2018-09-28  Ryosuke Niwa  <[email protected]>
 
         REGRESSION(r236609): API tests for mso list preservation are failing

Modified: trunk/Source/WebCore/platform/RuntimeApplicationChecks.h (236618 => 236619)


--- trunk/Source/WebCore/platform/RuntimeApplicationChecks.h	2018-09-28 22:32:56 UTC (rev 236618)
+++ trunk/Source/WebCore/platform/RuntimeApplicationChecks.h	2018-09-28 23:02:41 UTC (rev 236619)
@@ -79,7 +79,8 @@
 WEBCORE_EXPORT bool isMobileMail();
 WEBCORE_EXPORT bool isMobileSafari();
 WEBCORE_EXPORT bool isWebBookmarksD();
-bool isDumpRenderTree();
+WEBCORE_EXPORT bool isWebKitTestRunner();
+WEBCORE_EXPORT bool isDumpRenderTree();
 bool isMobileStore();
 bool isSpringBoard();
 WEBCORE_EXPORT bool isWebApp();

Modified: trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm (236618 => 236619)


--- trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm	2018-09-28 22:32:56 UTC (rev 236618)
+++ trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm	2018-09-28 23:02:41 UTC (rev 236619)
@@ -217,6 +217,14 @@
     return isDumpRenderTree;
 }
 
+bool IOSApplication::isWebKitTestRunner()
+{
+    // We use a prefix match instead of strict equality since multiple instances of WebKitTestRunner
+    // may be launched, where the bundle identifier of each instance has a unique suffix.
+    static bool isWebKitTestRunner = applicationBundleIsEqualTo("org.webkit.WebKitTestRunnerApp"_s); // e.g. org.webkit.WebKitTestRunnerApp0
+    return isWebKitTestRunner;
+}
+
 bool IOSApplication::isMobileStore()
 {
     static bool isMobileStore = applicationBundleIsEqualTo("com.apple.MobileStore"_s);

Modified: trunk/Source/WebKit/ChangeLog (236618 => 236619)


--- trunk/Source/WebKit/ChangeLog	2018-09-28 22:32:56 UTC (rev 236618)
+++ trunk/Source/WebKit/ChangeLog	2018-09-28 23:02:41 UTC (rev 236619)
@@ -1,3 +1,27 @@
+2018-09-28  Daniel Bates  <[email protected]>
+
+        [iOS] Allow programmatic focus when hardware keyboard is attached
+        https://bugs.webkit.org/show_bug.cgi?id=190017
+        <rdar://problem/42270463>
+
+        Reviewed by Wenson Hsieh.
+
+        Make the experience of using iOS with a hardware keyboard more desktop-like by allowing
+        programmatic focusing of editable elements.
+
+        * Platform/spi/ios/UIKitSPI.h: Forward declare SPI.
+        * Shared/NativeWebKeyboardEvent.h:
+        * Shared/ios/NativeWebKeyboardEventIOS.mm:
+        (WebKit::isInHardwareKeyboardMode): Returns whether we are in hardware keyboard mode. In DumpRenderTree
+        and WebKitTestRunner this function always returns false to keep test results deterministic.
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
+        Allow starting an input session if we are in hardware keyboard mode.
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::platformEditorState const): Send the full editor state if we are in hardware
+        keyboard mode regardless of whether layout has been performed so that UIProcess can update UI,
+        including the position of the caret, immediately.
+
 2018-09-28  Ryosuke Niwa  <[email protected]>
 
         Rename createMarkup to serializePreservingVisualAppearance

Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (236618 => 236619)


--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2018-09-28 22:32:56 UTC (rev 236618)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2018-09-28 23:02:41 UTC (rev 236619)
@@ -247,6 +247,7 @@
 - (void)activate;
 - (void)geometryChangeDone:(BOOL)keyboardVisible;
 - (void)prepareForGeometryChange;
++ (BOOL)isInHardwareKeyboardMode;
 @end
 
 @interface UIKeyboardImpl : UIView <UIKeyboardCandidateListDelegate>

Modified: trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h (236618 => 236619)


--- trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h	2018-09-28 22:32:56 UTC (rev 236618)
+++ trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h	2018-09-28 23:02:41 UTC (rev 236619)
@@ -105,6 +105,11 @@
 #endif
 };
 
+// FIXME: Find a better place for this.
+#if PLATFORM(IOS)
+bool isInHardwareKeyboardMode();
+#endif
+
 } // namespace WebKit
 
 #endif // NativeWebKeyboardEvent_h

Modified: trunk/Source/WebKit/Shared/ios/NativeWebKeyboardEventIOS.mm (236618 => 236619)


--- trunk/Source/WebKit/Shared/ios/NativeWebKeyboardEventIOS.mm	2018-09-28 22:32:56 UTC (rev 236618)
+++ trunk/Source/WebKit/Shared/ios/NativeWebKeyboardEventIOS.mm	2018-09-28 23:02:41 UTC (rev 236619)
@@ -28,10 +28,17 @@
 
 #if PLATFORM(IOS)
 
+#import "UIKitSPI.h"
 #import "WebIOSEventFactory.h"
+#import <WebCore/RuntimeApplicationChecks.h>
 
 namespace WebKit {
 
+bool isInHardwareKeyboardMode()
+{
+    return !WebCore::IOSApplication::isDumpRenderTree() && !WebCore::IOSApplication::isWebKitTestRunner() && [UIKeyboard isInHardwareKeyboardMode];
+}
+
 NativeWebKeyboardEvent::NativeWebKeyboardEvent(::WebEvent *event)
     : WebKeyboardEvent(WebIOSEventFactory::createWebKeyboardEvent(event))
     , m_nativeEvent(event)

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (236618 => 236619)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-09-28 22:32:56 UTC (rev 236618)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-09-28 23:02:41 UTC (rev 236619)
@@ -4191,6 +4191,7 @@
             || (_isChangingFocus && ![_focusedFormControlView isHidden])
 #else
             || _isChangingFocus
+            || isInHardwareKeyboardMode()
 #endif
 #if ENABLE(DRAG_SUPPORT)
             || _dragDropInteractionState.isPerformingDrop()

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (236618 => 236619)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2018-09-28 22:32:56 UTC (rev 236618)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2018-09-28 23:02:41 UTC (rev 236619)
@@ -37,6 +37,7 @@
 #import "GestureTypes.h"
 #import "InteractionInformationAtPosition.h"
 #import "Logging.h"
+#import "NativeWebKeyboardEvent.h"
 #import "PluginView.h"
 #import "PrintInfo.h"
 #import "RemoteLayerTreeDrawingArea.h"
@@ -191,12 +192,12 @@
         }
     }
 
-    // We only set the remaining EditorState entries if the layout is done. To compute these
-    // entries, we need the layout to be done and we don't want to trigger a synchronous
-    // layout as this would be bad for performance. If we have a composition, we send everything
-    // right away as the UIProcess needs the caretRects ASAP for marked text.
-    bool frameViewHasFinishedLayout = frame.view() && !frame.view()->needsLayout();
-    if (shouldIncludePostLayoutData == IncludePostLayoutDataHint::No && !frameViewHasFinishedLayout && !frame.editor().hasComposition()) {
+    // We only set the remaining EditorState entries if layout is done as a performance optimization
+    // to avoid the need to force a synchronous layout here to compute these entries. If we
+    // have a composition or are using a hardware keyboard then we send the full editor state
+    // immediately so that the UIProcess can update UI, including the position of the caret.
+    bool needsLayout = !frame.view() || frame.view()->needsLayout();
+    if (shouldIncludePostLayoutData == IncludePostLayoutDataHint::No && needsLayout && !isInHardwareKeyboardMode() && !frame.editor().hasComposition()) {
         result.isMissingPostLayoutData = true;
         return;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to