Title: [237935] trunk
Revision
237935
Author
dba...@webkit.org
Date
2018-11-07 12:12:49 -0800 (Wed, 07 Nov 2018)

Log Message

Override +[UIKeyboard isInHardwareKeyboardMode] in WebKitTestRunner and DumpRenderTree
https://bugs.webkit.org/show_bug.cgi?id=190141

Reviewed by Darin Adler.

Source/WebCore:

Remove the runtime application check for WebKitTestRunner as we no longer need this
now that WebKitTestRunner and DumpRenderTree override +[UIKeyboard isInHardwareKeyboardMode].

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

Source/WebKit:

Directly use +[UIKeyboard isInHardwareKeyboardMode]. We will override this class method
in DumpRenderTree and WebKitTestRunner to always return NO so as to make test runs
deterministic regardless of whether a hardware keyboard is attached.

* Shared/NativeWebKeyboardEvent.h:
* Shared/ios/NativeWebKeyboardEventIOS.mm:
(WebKit::isInHardwareKeyboardMode): Deleted.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::platformEditorState const):

Tools:

Override +[UIKeyboard isInHardwareKeyboardMode] to always return NO so as to make test
runs deterministic regardless of whether a hardware keyboard is attached.

* DumpRenderTree/mac/DumpRenderTree.mm:
(overrideIsInHardwareKeyboardMode): Added.
(prepareConsistentTestingEnvironment):
* TestRunnerShared/spi/UIKitTestSPI.h: Forward declare SPI.
* WebKitTestRunner/ios/TestControllerIOS.mm:
(overrideIsInHardwareKeyboardMode): Added.
(WTR::TestController::platformInitialize):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (237934 => 237935)


--- trunk/Source/WebCore/ChangeLog	2018-11-07 19:48:04 UTC (rev 237934)
+++ trunk/Source/WebCore/ChangeLog	2018-11-07 20:12:49 UTC (rev 237935)
@@ -1,3 +1,17 @@
+2018-11-07  Daniel Bates  <daba...@apple.com>
+
+        Override +[UIKeyboard isInHardwareKeyboardMode] in WebKitTestRunner and DumpRenderTree
+        https://bugs.webkit.org/show_bug.cgi?id=190141
+
+        Reviewed by Darin Adler.
+
+        Remove the runtime application check for WebKitTestRunner as we no longer need this
+        now that WebKitTestRunner and DumpRenderTree override +[UIKeyboard isInHardwareKeyboardMode].
+
+        * platform/RuntimeApplicationChecks.h:
+        * platform/cocoa/RuntimeApplicationChecksCocoa.mm:
+        (WebCore::IOSApplication::isWebKitTestRunner): Deleted.
+
 2018-11-07  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: Fix "_javascript_" => "_javascript_" enum in protocol generated objects

Modified: trunk/Source/WebCore/platform/RuntimeApplicationChecks.h (237934 => 237935)


--- trunk/Source/WebCore/platform/RuntimeApplicationChecks.h	2018-11-07 19:48:04 UTC (rev 237934)
+++ trunk/Source/WebCore/platform/RuntimeApplicationChecks.h	2018-11-07 20:12:49 UTC (rev 237935)
@@ -79,7 +79,6 @@
 WEBCORE_EXPORT bool isMobileMail();
 WEBCORE_EXPORT bool isMobileSafari();
 WEBCORE_EXPORT bool isWebBookmarksD();
-WEBCORE_EXPORT bool isWebKitTestRunner();
 WEBCORE_EXPORT bool isDumpRenderTree();
 bool isMobileStore();
 bool isSpringBoard();

Modified: trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm (237934 => 237935)


--- trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm	2018-11-07 19:48:04 UTC (rev 237934)
+++ trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm	2018-11-07 20:12:49 UTC (rev 237935)
@@ -217,14 +217,6 @@
     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 (237934 => 237935)


--- trunk/Source/WebKit/ChangeLog	2018-11-07 19:48:04 UTC (rev 237934)
+++ trunk/Source/WebKit/ChangeLog	2018-11-07 20:12:49 UTC (rev 237935)
@@ -1,3 +1,22 @@
+2018-11-07  Daniel Bates  <daba...@apple.com>
+
+        Override +[UIKeyboard isInHardwareKeyboardMode] in WebKitTestRunner and DumpRenderTree
+        https://bugs.webkit.org/show_bug.cgi?id=190141
+
+        Reviewed by Darin Adler.
+
+        Directly use +[UIKeyboard isInHardwareKeyboardMode]. We will override this class method
+        in DumpRenderTree and WebKitTestRunner to always return NO so as to make test runs
+        deterministic regardless of whether a hardware keyboard is attached.
+
+        * Shared/NativeWebKeyboardEvent.h:
+        * Shared/ios/NativeWebKeyboardEventIOS.mm:
+        (WebKit::isInHardwareKeyboardMode): Deleted.
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::platformEditorState const):
+
 2018-11-07  Zamiul Haque  <zha...@apple.com>
 
         Force a gregorian calendar to show for credit card expiration date inputs

Modified: trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h (237934 => 237935)


--- trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h	2018-11-07 19:48:04 UTC (rev 237934)
+++ trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h	2018-11-07 20:12:49 UTC (rev 237935)
@@ -105,11 +105,6 @@
 #endif
 };
 
-// FIXME: Find a better place for this.
-#if PLATFORM(IOS_FAMILY)
-bool isInHardwareKeyboardMode();
-#endif
-
 } // namespace WebKit
 
 #endif // NativeWebKeyboardEvent_h

Modified: trunk/Source/WebKit/Shared/ios/NativeWebKeyboardEventIOS.mm (237934 => 237935)


--- trunk/Source/WebKit/Shared/ios/NativeWebKeyboardEventIOS.mm	2018-11-07 19:48:04 UTC (rev 237934)
+++ trunk/Source/WebKit/Shared/ios/NativeWebKeyboardEventIOS.mm	2018-11-07 20:12:49 UTC (rev 237935)
@@ -34,11 +34,6 @@
 
 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 (237934 => 237935)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-11-07 19:48:04 UTC (rev 237934)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-11-07 20:12:49 UTC (rev 237935)
@@ -4216,7 +4216,7 @@
             || (_isChangingFocus && ![_focusedFormControlView isHidden])
 #else
             || _isChangingFocus
-            || isInHardwareKeyboardMode()
+            || [UIKeyboard isInHardwareKeyboardMode]
 #endif
 #if ENABLE(DRAG_SUPPORT)
             || _dragDropInteractionState.isPerformingDrop()

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


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2018-11-07 19:48:04 UTC (rev 237934)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2018-11-07 20:12:49 UTC (rev 237935)
@@ -42,6 +42,7 @@
 #import "PrintInfo.h"
 #import "RemoteLayerTreeDrawingArea.h"
 #import "SandboxUtilities.h"
+#import "UIKitSPI.h"
 #import "UserData.h"
 #import "VisibleContentRectUpdateInfo.h"
 #import "WKAccessibilityWebPageObjectIOS.h"
@@ -197,7 +198,7 @@
     // 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()) {
+    if (shouldIncludePostLayoutData == IncludePostLayoutDataHint::No && needsLayout && ![UIKeyboard isInHardwareKeyboardMode] && !frame.editor().hasComposition()) {
         result.isMissingPostLayoutData = true;
         return;
     }

Modified: trunk/Tools/ChangeLog (237934 => 237935)


--- trunk/Tools/ChangeLog	2018-11-07 19:48:04 UTC (rev 237934)
+++ trunk/Tools/ChangeLog	2018-11-07 20:12:49 UTC (rev 237935)
@@ -1,3 +1,21 @@
+2018-11-07  Daniel Bates  <daba...@apple.com>
+
+        Override +[UIKeyboard isInHardwareKeyboardMode] in WebKitTestRunner and DumpRenderTree
+        https://bugs.webkit.org/show_bug.cgi?id=190141
+
+        Reviewed by Darin Adler.
+
+        Override +[UIKeyboard isInHardwareKeyboardMode] to always return NO so as to make test
+        runs deterministic regardless of whether a hardware keyboard is attached.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (overrideIsInHardwareKeyboardMode): Added.
+        (prepareConsistentTestingEnvironment):
+        * TestRunnerShared/spi/UIKitTestSPI.h: Forward declare SPI.
+        * WebKitTestRunner/ios/TestControllerIOS.mm:
+        (overrideIsInHardwareKeyboardMode): Added.
+        (WTR::TestController::platformInitialize):
+
 2018-11-07  Jonathan Bedard  <jbed...@apple.com>
 
         Unreviewed, rolling out r237913.

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (237934 => 237935)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2018-11-07 19:48:04 UTC (rev 237934)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2018-11-07 20:12:49 UTC (rev 237935)
@@ -1201,6 +1201,13 @@
     }
 }
 
+#if PLATFORM(IOS_FAMILY)
+static BOOL overrideIsInHardwareKeyboardMode()
+{
+    return NO;
+}
+#endif
+
 static void prepareConsistentTestingEnvironment()
 {
 #if !PLATFORM(IOS_FAMILY)
@@ -1208,6 +1215,10 @@
     poseAsClass("DumpRenderTreeEvent", "NSEvent");
 #else
     poseAsClass("DumpRenderTreeEvent", "GSEvent");
+
+    // Override the implementation of +[UIKeyboard isInHardwareKeyboardMode] to ensure that test runs are deterministic
+    // regardless of whether a hardware keyboard is attached. We intentionally never restore the original implementation.
+    method_setImplementation(class_getClassMethod([UIKeyboard class], @selector(isInHardwareKeyboardMode)), reinterpret_cast<IMP>(overrideIsInHardwareKeyboardMode));
 #endif
 
     [[WebPreferences standardPreferences] setAutosaves:NO];

Modified: trunk/Tools/TestRunnerShared/spi/UIKitTestSPI.h (237934 => 237935)


--- trunk/Tools/TestRunnerShared/spi/UIKitTestSPI.h	2018-11-07 19:48:04 UTC (rev 237934)
+++ trunk/Tools/TestRunnerShared/spi/UIKitTestSPI.h	2018-11-07 20:12:49 UTC (rev 237935)
@@ -63,6 +63,7 @@
 
 @interface UIKeyboard ()
 + (void)removeAllDynamicDictionaries;
++ (BOOL)isInHardwareKeyboardMode;
 @end
 
 @interface UIView ()

Modified: trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm (237934 => 237935)


--- trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm	2018-11-07 19:48:04 UTC (rev 237934)
+++ trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm	2018-11-07 20:12:49 UTC (rev 237935)
@@ -42,8 +42,14 @@
 #import <WebKit/WKUserContentControllerPrivate.h>
 #import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <WebKit/WKWebViewPrivate.h>
+#import <objc/runtime.h>
 #import <wtf/MainThread.h>
 
+static BOOL overrideIsInHardwareKeyboardMode()
+{
+    return NO;
+}
+
 namespace WTR {
 
 static bool isDoneWaitingForKeyboardToDismiss = true;
@@ -73,6 +79,10 @@
     auto center = CFNotificationCenterGetLocalCenter();
     CFNotificationCenterAddObserver(center, this, handleKeyboardWillHideNotification, (CFStringRef)UIKeyboardWillHideNotification, nullptr, CFNotificationSuspensionBehaviorDeliverImmediately);
     CFNotificationCenterAddObserver(center, this, handleKeyboardDidHideNotification, (CFStringRef)UIKeyboardDidHideNotification, nullptr, CFNotificationSuspensionBehaviorDeliverImmediately);
+
+    // Override the implementation of +[UIKeyboard isInHardwareKeyboardMode] to ensure that test runs are deterministic
+    // regardless of whether a hardware keyboard is attached. We intentionally never restore the original implementation.
+    method_setImplementation(class_getClassMethod([UIKeyboard class], @selector(isInHardwareKeyboardMode)), reinterpret_cast<IMP>(overrideIsInHardwareKeyboardMode));
 }
 
 void TestController::platformDestroy()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to