Title: [246564] trunk
Revision
246564
Author
dba...@webkit.org
Date
2019-06-18 13:59:35 -0700 (Tue, 18 Jun 2019)

Log Message

[iOS] Pressing key while holding Command should not insert character
https://bugs.webkit.org/show_bug.cgi?id=198925
<rdar://problem/51778811>

Reviewed by Brent Fulgham.

Source/WebKit:

Do not insert a character for an unhandled key command that has a Command modifier.
For example, pressing Command + Shift + v, which is an unhandled key command (at the
time of writing) should not insert v. This matches iOS and Mac platform conventions.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _interpretKeyEvent:isCharEvent:]):

LayoutTests:

Add a test that Command + Shift + v does not insert a v as we don't expect it
to as of the time of writing. A more comprehensive test would be needed to
ensure that all unhandled key commands with Command modifiers do not insert
a character. For now, the added test seems good enough.

* fast/events/ios/command+shift+v-should-not-insert-v-expected.txt: Added.
* fast/events/ios/command+shift+v-should-not-insert-v.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (246563 => 246564)


--- trunk/LayoutTests/ChangeLog	2019-06-18 20:53:01 UTC (rev 246563)
+++ trunk/LayoutTests/ChangeLog	2019-06-18 20:59:35 UTC (rev 246564)
@@ -1,3 +1,19 @@
+2019-06-18  Daniel Bates  <daba...@apple.com>
+
+        [iOS] Pressing key while holding Command should not insert character
+        https://bugs.webkit.org/show_bug.cgi?id=198925
+        <rdar://problem/51778811>
+
+        Reviewed by Brent Fulgham.
+
+        Add a test that Command + Shift + v does not insert a v as we don't expect it
+        to as of the time of writing. A more comprehensive test would be needed to
+        ensure that all unhandled key commands with Command modifiers do not insert
+        a character. For now, the added test seems good enough.
+
+        * fast/events/ios/command+shift+v-should-not-insert-v-expected.txt: Added.
+        * fast/events/ios/command+shift+v-should-not-insert-v.html: Added.
+
 2019-06-18  Russell Epstein  <russel...@apple.com>
 
         [iOS] Layout Test http/tests/resourceLoadStatistics/website-data-removal-for-site-navigated-to-with-link-decoration.html is frequently failing or timing out.

Added: trunk/LayoutTests/fast/events/ios/command+shift+v-should-not-insert-v-expected.txt (0 => 246564)


--- trunk/LayoutTests/fast/events/ios/command+shift+v-should-not-insert-v-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/command+shift+v-should-not-insert-v-expected.txt	2019-06-18 20:59:35 UTC (rev 246564)
@@ -0,0 +1,10 @@
+Tests that Command + Shift + v does not insert v and that pressing a does insert an a.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.event.data is "a"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/ios/command+shift+v-should-not-insert-v.html (0 => 246564)


--- trunk/LayoutTests/fast/events/ios/command+shift+v-should-not-insert-v.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/command+shift+v-should-not-insert-v.html	2019-06-18 20:59:35 UTC (rev 246564)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+window.jsTestIsAsync = true;
+
+let testElement;
+
+function checkTextInput(event)
+{
+    shouldBeEqualToString("window.event.data", "a");
+    document.body.removeChild(testElement);
+    finishJSTest();
+}
+
+function handleFocus()
+{
+    testElement.addEventListener("input", checkTextInput, { once: true });
+    if (window.testRunner) {
+        UIHelper.keyDown("v", ["metaKey", "shiftKey"]); // Should emit no TextInput event.
+        UIHelper.keyDown("a"); // To end the test.
+    }
+}
+
+function runTest()
+{
+    testElement = document.getElementById("test");
+
+    description("Tests that <kbd>Command</kbd> + <kbd>Shift</kbd> + <kbd>v</kbd> does not insert v and that pressing <kbd>a</kbd> does insert an a.");
+
+    testElement.addEventListener("focus", handleFocus, { once: true });
+    if (window.testRunner)
+        UIHelper.activateFormControl(testElement);
+    else
+        testElement.focus();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p id="description"></p>
+<div id="console"></div>
+<input type="text" id="test" placeholder="Press Command + Shift + v. Then press a." style="width: 300px"></div>
+</body>
+</html>

Modified: trunk/Source/WebKit/ChangeLog (246563 => 246564)


--- trunk/Source/WebKit/ChangeLog	2019-06-18 20:53:01 UTC (rev 246563)
+++ trunk/Source/WebKit/ChangeLog	2019-06-18 20:59:35 UTC (rev 246564)
@@ -1,3 +1,18 @@
+2019-06-18  Daniel Bates  <daba...@apple.com>
+
+        [iOS] Pressing key while holding Command should not insert character
+        https://bugs.webkit.org/show_bug.cgi?id=198925
+        <rdar://problem/51778811>
+
+        Reviewed by Brent Fulgham.
+
+        Do not insert a character for an unhandled key command that has a Command modifier.
+        For example, pressing Command + Shift + v, which is an unhandled key command (at the
+        time of writing) should not insert v. This matches iOS and Mac platform conventions.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _interpretKeyEvent:isCharEvent:]):
+
 2019-06-18  John Wilander  <wilan...@apple.com>
 
         Change log channel name from ResourceLoadStatisticsDebug to ITPDebug and remove unnecessary #if !RELEASE_LOG_DISABLED

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (246563 => 246564)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-06-18 20:53:01 UTC (rev 246563)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-06-18 20:59:35 UTC (rev 246564)
@@ -4674,6 +4674,10 @@
         return YES;
 #endif
 
+    // Don't insert character for an unhandled Command-key key command. This matches iOS and Mac platform conventions.
+    if (event.modifierFlags & WebEventFlagMaskCommandKey)
+        return NO;
+
     NSString *characters = event.characters;
     if (!characters.length)
         return NO;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to