Title: [239277] trunk
Revision
239277
Author
dba...@webkit.org
Date
2018-12-17 11:19:25 -0800 (Mon, 17 Dec 2018)

Log Message

Implement UIScriptController::toggleCapsLock() for iOS
https://bugs.webkit.org/show_bug.cgi?id=191815

Reviewed by Andy Estes.

Source/WebCore/PAL:

Add HID usage enumerator for the Caps Lock key.

* pal/spi/cocoa/IOKitSPI.h:

Source/WebKit:

Add test infrastructure to clear the current modifier state. We will use this to ensure that
the caps lock state does not persist between tests.

* UIProcess/API/C/WKContext.cpp:
(WKContextClearCurrentModifierStateForTesting): Added.
* UIProcess/API/C/WKContextPrivate.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::clearCurrentModifierStateForTesting): Added.
* UIProcess/WebProcessPool.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::clearCurrentModifierStateForTesting): Added.
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

Tools:

Add support for toggling the caps lock state in WebKitTestRunner on iOS.

* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetStateToConsistentValues): Clear the current modifier state
before running a test. This ensures that the caps lock state does not persist between
tests should a test enable caps lock and not disable it.
* WebKitTestRunner/ios/HIDEventGenerator.mm:
(hidUsageCodeForCharacter): Map "capsLock" to the Caps Lock key usage code.
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::createUIPhysicalKeyboardEvent): Modified to take the keyboard input flags to use to
create the event. Also substituted NSString* for const String& as the data type for the first
two parameters to avoid conversions in the implementation of UIScriptController::toggleCapsLock()
below.
(WTR::UIScriptController::keyDown): Update as needed due to changes to prototype of createUIPhysicalKeyboardEvent().
(WTR::UIScriptController::toggleCapsLock): Dispatch a UIEvent to toggle caps lock.

LayoutTests:

Add iOS-specific results for some of the tests. We need to continue to skip the caps
lock tests on iOS until we have the fix for <rdar://problem/44930119>.

* fast/forms/password-scrolled-after-caps-lock-toggled.html: Replace input.focus() with
UIHelper.activateElement(input) to make it work on iOS and update logic accordingly.
Compensate for the fact that one less character than the size of the input is visible in
a password field on iOS.
* fast/repaint/placeholder-after-caps-lock-hidden.html: Replace input.focus() with
UIHelper.activateElement(input) to make it work on iOS and update logic accordingly.
* platform/ios-wk2/TestExpectations:
* platform/ios-wk2/fast/forms/password-scrolled-after-caps-lock-toggled-expected.txt: Added.
* platform/ios-wk2/fast/repaint/placeholder-after-caps-lock-hidden-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (239276 => 239277)


--- trunk/LayoutTests/ChangeLog	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/LayoutTests/ChangeLog	2018-12-17 19:19:25 UTC (rev 239277)
@@ -1,3 +1,23 @@
+2018-12-17  Daniel Bates  <daba...@apple.com>
+
+        Implement UIScriptController::toggleCapsLock() for iOS
+        https://bugs.webkit.org/show_bug.cgi?id=191815
+
+        Reviewed by Andy Estes.
+
+        Add iOS-specific results for some of the tests. We need to continue to skip the caps
+        lock tests on iOS until we have the fix for <rdar://problem/44930119>.
+
+        * fast/forms/password-scrolled-after-caps-lock-toggled.html: Replace input.focus() with
+        UIHelper.activateElement(input) to make it work on iOS and update logic accordingly.
+        Compensate for the fact that one less character than the size of the input is visible in
+        a password field on iOS.
+        * fast/repaint/placeholder-after-caps-lock-hidden.html: Replace input.focus() with
+        UIHelper.activateElement(input) to make it work on iOS and update logic accordingly.
+        * platform/ios-wk2/TestExpectations:
+        * platform/ios-wk2/fast/forms/password-scrolled-after-caps-lock-toggled-expected.txt: Added.
+        * platform/ios-wk2/fast/repaint/placeholder-after-caps-lock-hidden-expected.txt: Added.
+
 2018-12-17  Simon Fraser  <simon.fra...@apple.com>
 
         REGRESSION (r233268): Elements animated in from offscreen sometimes don't display

Modified: trunk/LayoutTests/fast/forms/password-scrolled-after-caps-lock-toggled.html (239276 => 239277)


--- trunk/LayoutTests/fast/forms/password-scrolled-after-caps-lock-toggled.html	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/LayoutTests/fast/forms/password-scrolled-after-caps-lock-toggled.html	2018-12-17 19:19:25 UTC (rev 239277)
@@ -52,9 +52,15 @@
 function testFocusedEmptyFieldIsNotScrolled()
 {
     debug("Case 1: Empty field:");
-    input.focus();
-    shouldBeZero("document.getElementById('input').scrollLeft");
-    runNextTest();
+    function handleFocus() {
+        shouldBeZero("document.getElementById('input').scrollLeft");
+        runNextTest();
+    }
+    input.addEventListener("focus", handleFocus, { once: true });
+    if (window.testRunner)
+        UIHelper.activateElement(input);
+    else
+        input.focus();
 }
 
 function testFieldDidNotScrollAfterTyping()
@@ -90,10 +96,10 @@
         eventToListenFor = "keyup";
     }
 
-    let oldValue = document.getElementById('input').scrollLeft;
+    let oldValue = document.getElementById("input").scrollLeft;
     function handleCapsLockChange(event) {
         console.assert(event.key === "CapsLock");
-        callback(oldValue, document.getElementById('input').scrollLeft);
+        callback(oldValue, document.getElementById("input").scrollLeft);
         runNextTest();
     }
     input.addEventListener(eventToListenFor, handleCapsLockChange, { once: true });
@@ -166,6 +172,14 @@
 input = document.getElementById("input");
 console.assert(input.hasAttribute("size"));
 numberOfCharactersToOverflowFieldWhenCapsLockShown = input.size;
+
+// FIXME: Find a way to compute the maximum number of visible characters the field can hold
+// in a way that allows for running this test by hand.
+let mayBeIOS = window.TouchEvent != undefined;
+if (mayBeIOS) {
+    // The look of the password field on iOS gives less space to the value than on Mac.
+    --numberOfCharactersToOverflowFieldWhenCapsLockShown;
+}
 console.assert(numberOfCharactersToOverflowFieldWhenCapsLockShown >= 3);
 
 description("Tests that the password field is scrolled when the caps lock indicator is toggled.");

Modified: trunk/LayoutTests/fast/repaint/placeholder-after-caps-lock-hidden.html (239276 => 239277)


--- trunk/LayoutTests/fast/repaint/placeholder-after-caps-lock-hidden.html	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/LayoutTests/fast/repaint/placeholder-after-caps-lock-hidden.html	2018-12-17 19:19:25 UTC (rev 239277)
@@ -38,15 +38,17 @@
         return;
 
     let input = document.getElementById("input");
-    input.focus();
-
-    function handleCapsLockEnabled(event) {
-        console.assert(event.key === "CapsLock");
-        input.addEventListener("keyup", handleKeyUp, false);
-        UIHelper.keyDown("a");
+    function handleFocus() {
+        function handleCapsLockEnabled(event) {
+            console.assert(event.key === "CapsLock");
+            input.addEventListener("keyup", handleKeyUp, false);
+            UIHelper.keyDown("a");
+        }
+        input.addEventListener("keydown", handleCapsLockEnabled, { once: true });
+        UIHelper.toggleCapsLock();
     }
-    input.addEventListener("keydown", handleCapsLockEnabled, { once: true });
-    UIHelper.toggleCapsLock();
+    input.addEventListener("focus", handleFocus, { once: true });
+    UIHelper.activateElement(input);
 }
 </script>
 </head>

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (239276 => 239277)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2018-12-17 19:19:25 UTC (rev 239277)
@@ -1323,4 +1323,10 @@
 http/wpt/webauthn/public-key-credential-create-success-hid.https.html [ Skip ]
 http/wpt/webauthn/public-key-credential-get-failure-hid-silent.https.html [ Skip ]
 http/wpt/webauthn/public-key-credential-get-failure-hid.https.html [ Skip ]
-http/wpt/webauthn/public-key-credential-get-success-hid.https.html [ Skip ]
\ No newline at end of file
+http/wpt/webauthn/public-key-credential-get-success-hid.https.html [ Skip ]
+
+# FIXME: Unskip these tests once we have the fix for <rdar://problem/44930119>.
+fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button.html [ Skip ]
+fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible.html [ Skip ]
+fast/forms/password-scrolled-after-caps-lock-toggled.html [ Skip ]
+fast/repaint/placeholder-after-caps-lock-hidden.html [ Skip ]

Added: trunk/LayoutTests/platform/ios-wk2/fast/forms/password-scrolled-after-caps-lock-toggled-expected.txt (0 => 239277)


--- trunk/LayoutTests/platform/ios-wk2/fast/forms/password-scrolled-after-caps-lock-toggled-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-wk2/fast/forms/password-scrolled-after-caps-lock-toggled-expected.txt	2018-12-17 19:19:25 UTC (rev 239277)
@@ -0,0 +1,45 @@
+Tests that the password field is scrolled when the caps lock indicator is toggled.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Case 1: Empty field:
+PASS document.getElementById('input').scrollLeft is 0
+
+After caps lock enabled:
+PASS document.getElementById('input').scrollLeft is 0
+
+After caps lock disabled:
+PASS document.getElementById('input').scrollLeft is 0
+
+Case 2: After typing into field:
+PASS document.getElementById('input').scrollLeft is 0
+
+After caps lock enabled:
+PASS document.getElementById('input').scrollLeft is non-zero.
+
+After caps lock disabled:
+PASS document.getElementById('input').scrollLeft is 0
+
+Case 3: After selecting the first 2 characters:
+PASS document.getElementById('input').scrollLeft is 0
+
+After caps lock enabled:
+FAIL document.getElementById('input').scrollLeft should be 0. Was 3.
+
+After caps lock disabled:
+PASS document.getElementById('input').scrollLeft is 0
+
+Case 4: After selecting the last 2 characters:
+PASS document.getElementById('input').scrollLeft is 0
+
+After caps lock enabled:
+PASS document.getElementById('input').scrollLeft is non-zero.
+
+After caps lock disabled:
+PASS document.getElementById('input').scrollLeft is 0
+PASS successfullyParsed is true
+Some tests failed.
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/ios-wk2/fast/repaint/placeholder-after-caps-lock-hidden-expected.txt (0 => 239277)


--- trunk/LayoutTests/platform/ios-wk2/fast/repaint/placeholder-after-caps-lock-hidden-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-wk2/fast/repaint/placeholder-after-caps-lock-hidden-expected.txt	2018-12-17 19:19:25 UTC (rev 239277)
@@ -0,0 +1,27 @@
+Tests that the placeholder text is repainted when the caps lock indicator is hidden.
+
+
+(repaint rects
+  (rect 25 50.50 27 27)
+  (rect 30 55.50 17 17)
+  (rect 11.50 50.50 23.50 24)
+  (rect 16.50 57 13.50 14)
+  (rect 11.50 50.50 40.50 24)
+  (rect 16.50 57 30.50 14)
+  (rect 25 50.50 27 24)
+  (rect 30 57 17 14)
+  (rect 25 50.50 10 24)
+  (rect 11.50 49 40.50 27)
+  (rect 16.50 55.50 30.50 17)
+  (rect 11.50 49 40.50 24)
+  (rect 16.50 55.50 30.50 14)
+  (rect 11.50 50.50 40.50 27)
+  (rect 16.50 55.50 30.50 17)
+  (rect 11.50 52 40.50 24)
+  (rect 16.50 57 30.50 14)
+  (rect 11.50 52 23.50 24)
+  (rect 16.50 57 13.50 14)
+  (rect 11.50 52 40.50 24)
+  (rect 16.50 57 30.50 14)
+)
+

Modified: trunk/Source/WebCore/PAL/ChangeLog (239276 => 239277)


--- trunk/Source/WebCore/PAL/ChangeLog	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Source/WebCore/PAL/ChangeLog	2018-12-17 19:19:25 UTC (rev 239277)
@@ -1,3 +1,14 @@
+2018-12-17  Daniel Bates  <daba...@apple.com>
+
+        Implement UIScriptController::toggleCapsLock() for iOS
+        https://bugs.webkit.org/show_bug.cgi?id=191815
+
+        Reviewed by Andy Estes.
+
+        Add HID usage enumerator for the Caps Lock key.
+
+        * pal/spi/cocoa/IOKitSPI.h:
+
 2018-12-17  Matt Lewis  <jlew...@apple.com>
 
         Unreviewed, rolling out r239254.

Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/IOKitSPI.h (239276 => 239277)


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/IOKitSPI.h	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/IOKitSPI.h	2018-12-17 19:19:25 UTC (rev 239277)
@@ -183,6 +183,7 @@
     kHIDUsage_KeyboardComma = 0x36,
     kHIDUsage_KeyboardPeriod = 0x37,
     kHIDUsage_KeyboardSlash = 0x38,
+    kHIDUsage_KeyboardCapsLock = 0x39,
     kHIDUsage_KeyboardF1 = 0x3A,
     kHIDUsage_KeyboardPrintScreen = 0x46,
     kHIDUsage_KeyboardInsert = 0x49,

Modified: trunk/Source/WebKit/ChangeLog (239276 => 239277)


--- trunk/Source/WebKit/ChangeLog	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Source/WebKit/ChangeLog	2018-12-17 19:19:25 UTC (rev 239277)
@@ -1,3 +1,24 @@
+2018-12-17  Daniel Bates  <daba...@apple.com>
+
+        Implement UIScriptController::toggleCapsLock() for iOS
+        https://bugs.webkit.org/show_bug.cgi?id=191815
+
+        Reviewed by Andy Estes.
+
+        Add test infrastructure to clear the current modifier state. We will use this to ensure that
+        the caps lock state does not persist between tests.
+
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextClearCurrentModifierStateForTesting): Added.
+        * UIProcess/API/C/WKContextPrivate.h:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::clearCurrentModifierStateForTesting): Added.
+        * UIProcess/WebProcessPool.h:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::clearCurrentModifierStateForTesting): Added.
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+
 2018-12-17  David Kilzer  <ddkil...@apple.com>
 
         REGRESSION (r239262): Fix broken builds prior to Mojave

Modified: trunk/Source/WebKit/UIProcess/API/C/WKContext.cpp (239276 => 239277)


--- trunk/Source/WebKit/UIProcess/API/C/WKContext.cpp	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Source/WebKit/UIProcess/API/C/WKContext.cpp	2018-12-17 19:19:25 UTC (rev 239277)
@@ -649,3 +649,8 @@
 {
     WebKit::toImpl(contextRef)->setIDBPerOriginQuota(quota);
 }
+
+void WKContextClearCurrentModifierStateForTesting(WKContextRef contextRef)
+{
+    toImpl(contextRef)->clearCurrentModifierStateForTesting();
+}

Modified: trunk/Source/WebKit/UIProcess/API/C/WKContextPrivate.h (239276 => 239277)


--- trunk/Source/WebKit/UIProcess/API/C/WKContextPrivate.h	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Source/WebKit/UIProcess/API/C/WKContextPrivate.h	2018-12-17 19:19:25 UTC (rev 239277)
@@ -118,6 +118,8 @@
 
 WK_EXPORT void WKContextSetIDBPerOriginQuota(WKContextRef context, uint64_t quota);
 
+WK_EXPORT void WKContextClearCurrentModifierStateForTesting(WKContextRef context);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (239276 => 239277)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2018-12-17 19:19:25 UTC (rev 239277)
@@ -2358,4 +2358,9 @@
     process.send(Messages::WebProcess::PrewarmWithDomainInformation(*prewarmInformation), 0);
 }
 
+void WebProcessPool::clearCurrentModifierStateForTesting()
+{
+    sendToAllProcesses(Messages::WebProcess::ClearCurrentModifierStateForTesting());
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (239276 => 239277)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.h	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h	2018-12-17 19:19:25 UTC (rev 239277)
@@ -467,6 +467,7 @@
     void resetMockMediaDevices();
 
     void sendDisplayConfigurationChangedMessageForTesting();
+    void clearCurrentModifierStateForTesting();
 
 #if PLATFORM(GTK) || PLATFORM(WPE)
     void setSandboxEnabled(bool enabled) { m_sandboxEnabled = enabled; };

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (239276 => 239277)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2018-12-17 19:19:25 UTC (rev 239277)
@@ -104,6 +104,7 @@
 #include <WebCore/Page.h>
 #include <WebCore/PageCache.h>
 #include <WebCore/PageGroup.h>
+#include <WebCore/PlatformKeyboardEvent.h>
 #include <WebCore/PlatformMediaSessionManager.h>
 #include <WebCore/ProcessWarming.h>
 #include <WebCore/ResourceLoadObserver.h>
@@ -1761,4 +1762,9 @@
 }
 #endif
 
+void WebProcess::clearCurrentModifierStateForTesting()
+{
+    PlatformKeyboardEvent::setCurrentModifierState({ });
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (239276 => 239277)


--- trunk/Source/WebKit/WebProcess/WebProcess.h	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h	2018-12-17 19:19:25 UTC (rev 239277)
@@ -399,6 +399,8 @@
 #endif
 #endif
 
+    void clearCurrentModifierStateForTesting();
+
     RefPtr<WebConnectionToUIProcess> m_webConnection;
 
     HashMap<uint64_t, RefPtr<WebPage>> m_pageMap;

Modified: trunk/Source/WebKit/WebProcess/WebProcess.messages.in (239276 => 239277)


--- trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2018-12-17 19:19:25 UTC (rev 239277)
@@ -153,4 +153,6 @@
     RemoveMockMediaDevice(String persistentId);
     ResetMockMediaDevices();
 #endif
+
+    ClearCurrentModifierStateForTesting()
 }

Modified: trunk/Tools/ChangeLog (239276 => 239277)


--- trunk/Tools/ChangeLog	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Tools/ChangeLog	2018-12-17 19:19:25 UTC (rev 239277)
@@ -1,5 +1,29 @@
 2018-12-17  Daniel Bates  <daba...@apple.com>
 
+        Implement UIScriptController::toggleCapsLock() for iOS
+        https://bugs.webkit.org/show_bug.cgi?id=191815
+
+        Reviewed by Andy Estes.
+
+        Add support for toggling the caps lock state in WebKitTestRunner on iOS.
+
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetStateToConsistentValues): Clear the current modifier state
+        before running a test. This ensures that the caps lock state does not persist between
+        tests should a test enable caps lock and not disable it.
+        * WebKitTestRunner/ios/HIDEventGenerator.mm:
+        (hidUsageCodeForCharacter): Map "capsLock" to the Caps Lock key usage code.
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::createUIPhysicalKeyboardEvent): Modified to take the keyboard input flags to use to
+        create the event. Also substituted NSString* for const String& as the data type for the first
+        two parameters to avoid conversions in the implementation of UIScriptController::toggleCapsLock()
+        below.
+        (WTR::UIScriptController::keyDown): Update as needed due to changes to prototype of createUIPhysicalKeyboardEvent().
+        (WTR::UIScriptController::toggleCapsLock): Dispatch a UIEvent to toggle caps lock.
+
+2018-12-17  Daniel Bates  <daba...@apple.com>
+
         [iOS] Remove -[WebEvent initWithKeyEventType:...:characterSet:]
         https://bugs.webkit.org/show_bug.cgi?id=192633
 

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (239276 => 239277)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2018-12-17 19:19:25 UTC (rev 239277)
@@ -228,7 +228,7 @@
 
     UIScriptContext* m_context;
 
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
     bool m_capsLockOn { false };
 #endif
 };

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (239276 => 239277)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2018-12-17 19:19:25 UTC (rev 239277)
@@ -872,6 +872,8 @@
 
     WKContextSetAllowsAnySSLCertificateForServiceWorkerTesting(platformContext(), true);
 
+    WKContextClearCurrentModifierStateForTesting(TestController::singleton().context());
+
     // FIXME: This function should also ensure that there is only one page open.
 
     // Reset the EventSender for each test.

Modified: trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm (239276 => 239277)


--- trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm	2018-12-17 19:19:25 UTC (rev 239277)
@@ -925,6 +925,8 @@
     if (auto keyCode = keyCodeForDOMFunctionKey(key))
         return *keyCode;
 
+    if ([key isEqualToString:@"capsLock"])
+        return kHIDUsage_KeyboardCapsLock;
     if ([key isEqualToString:@"pageUp"])
         return kHIDUsage_KeyboardPageUp;
     if ([key isEqualToString:@"pageDown"])

Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (239276 => 239277)


--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2018-12-17 19:17:11 UTC (rev 239276)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2018-12-17 19:19:25 UTC (rev 239277)
@@ -400,9 +400,9 @@
     return modifiers;
 }
 
-static UIPhysicalKeyboardEvent *createUIPhysicalKeyboardEvent(const String& hidInputString, const String& uiEventInputString, UIKeyModifierFlags modifierFlags, bool isKeyDown)
+static UIPhysicalKeyboardEvent *createUIPhysicalKeyboardEvent(NSString *hidInputString, NSString *uiEventInputString, UIKeyModifierFlags modifierFlags, UIKeyboardInputFlags inputFlags, bool isKeyDown)
 {
-    auto* keyboardEvent = [getUIPhysicalKeyboardEventClass() _eventWithInput:uiEventInputString inputFlags:(UIKeyboardInputFlags)0];
+    auto* keyboardEvent = [getUIPhysicalKeyboardEventClass() _eventWithInput:uiEventInputString inputFlags:inputFlags];
     keyboardEvent._modifierFlags = modifierFlags;
     auto hidEvent = createHIDKeyEvent(hidInputString, keyboardEvent.timestamp, isKeyDown);
     [keyboardEvent _setHIDEvent:hidEvent.get() keyboard:nullptr];
@@ -422,15 +422,16 @@
     String inputString = toWTFString(toWK(character));
     String uiEventInputString = inputString.length() > 1 ? emptyString() : inputString;
     auto modifierFlags = parseModifierArray(m_context->jsContext(), modifierArray);
+    UIKeyboardInputFlags inputFlags = static_cast<UIKeyboardInputFlags>(0);
 
     // Note that UIKit will call -release on the passed UIPhysicalKeyboardEvent.
 
     // Key down
-    auto* keyboardEvent = createUIPhysicalKeyboardEvent(inputString, uiEventInputString, modifierFlags, true /* isKeyDown */);
+    auto* keyboardEvent = createUIPhysicalKeyboardEvent(inputString, uiEventInputString, modifierFlags, inputFlags, true /* isKeyDown */);
     [[UIApplication sharedApplication] handleKeyUIEvent:keyboardEvent];
 
     // Key up
-    keyboardEvent = createUIPhysicalKeyboardEvent(inputString, uiEventInputString, modifierFlags, false /* isKeyDown */);
+    keyboardEvent = createUIPhysicalKeyboardEvent(inputString, uiEventInputString, modifierFlags, inputFlags, false /* isKeyDown */);
     [[UIApplication sharedApplication] handleKeyUIEvent:keyboardEvent];
 }
 
@@ -932,7 +933,10 @@
 
 void UIScriptController::toggleCapsLock(JSValueRef callback)
 {
-    // FIXME: Implement for iOS. See <https://bugs.webkit.org/show_bug.cgi?id=191815>.
+    m_capsLockOn = !m_capsLockOn;
+    auto *keyboardEvent = createUIPhysicalKeyboardEvent(@"capsLock", [NSString string], m_capsLockOn ? UIKeyModifierAlphaShift : 0,
+        kUIKeyboardInputModifierFlagsChanged, m_capsLockOn);
+    [[UIApplication sharedApplication] handleKeyUIEvent:keyboardEvent];
     doAsyncTask(callback);
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to