Title: [239125] tags/Safari-607.1.16.2
Revision
239125
Author
[email protected]
Date
2018-12-12 12:43:53 -0800 (Wed, 12 Dec 2018)

Log Message

Cherry-pick r238814. rdar://problem/46046013

    [iOS] Do not handle key events that are key commands
    https://bugs.webkit.org/show_bug.cgi?id=191608
    <rdar://problem/46046013>

    Reviewed by Ryosuke Niwa.

    Source/WebKit:

    A key down event may be associated with a key command. If it is then we want to execute the
    key command instead of inserting or deleting text. We need to ask UIKit to handle the current
    event as a key command to find out.

    * UIProcess/ios/WKContentViewInteraction.mm:
    (-[WKContentView _interpretKeyEvent:isCharEvent:]): Ask UIKit to handle the current event
    as a key command. If it handles it then we're done. Otherwise, do what we do now.

    Source/WebKitLegacy/ios:

    Add default implementation of -handleKeyCommandForCurrentEvent that returns NO - the current
    event was not handled as a key command.

    * DefaultDelegates/WebDefaultUIKitDelegate.m:
    (-[WebDefaultUIKitDelegate handleKeyCommandForCurrentEvent]):
    * WebView/WebUIKitDelegate.h:

    Source/WebKitLegacy/mac:

    A key down event may be associated with a key command. If it is then we want to execute the
    key command instead of inserting or deleting text. We need to ask UIKit to handle the current
    event as a key command to find out.

    * WebView/WebHTMLView.mm:
    (-[WebHTMLView _handleEditingKeyEvent:]):

    LayoutTests:

    Add tests to ensure that we process key commands correctly.

    * fast/events/ios/key-command-italic-dispatches-keydown-expected.txt: Added.
    * fast/events/ios/key-command-italic-dispatches-keydown.html: Added.
    * fast/events/ios/key-command-italic-expected.txt: Added.
    * fast/events/ios/key-command-italic.html: Added.
    * fast/events/ios/type-digits-holding-control-key-expected.txt: Added.
    * fast/events/ios/type-digits-holding-control-key.html: Added.
    * platform/ios-wk1/TestExpectations:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238814 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: tags/Safari-607.1.16.2/LayoutTests/ChangeLog (239124 => 239125)


--- tags/Safari-607.1.16.2/LayoutTests/ChangeLog	2018-12-12 19:15:58 UTC (rev 239124)
+++ tags/Safari-607.1.16.2/LayoutTests/ChangeLog	2018-12-12 20:43:53 UTC (rev 239125)
@@ -1,3 +1,73 @@
+2018-12-12  Kocsen Chung  <[email protected]>
+
+        Cherry-pick r238814. rdar://problem/46046013
+
+    [iOS] Do not handle key events that are key commands
+    https://bugs.webkit.org/show_bug.cgi?id=191608
+    <rdar://problem/46046013>
+    
+    Reviewed by Ryosuke Niwa.
+    
+    Source/WebKit:
+    
+    A key down event may be associated with a key command. If it is then we want to execute the
+    key command instead of inserting or deleting text. We need to ask UIKit to handle the current
+    event as a key command to find out.
+    
+    * UIProcess/ios/WKContentViewInteraction.mm:
+    (-[WKContentView _interpretKeyEvent:isCharEvent:]): Ask UIKit to handle the current event
+    as a key command. If it handles it then we're done. Otherwise, do what we do now.
+    
+    Source/WebKitLegacy/ios:
+    
+    Add default implementation of -handleKeyCommandForCurrentEvent that returns NO - the current
+    event was not handled as a key command.
+    
+    * DefaultDelegates/WebDefaultUIKitDelegate.m:
+    (-[WebDefaultUIKitDelegate handleKeyCommandForCurrentEvent]):
+    * WebView/WebUIKitDelegate.h:
+    
+    Source/WebKitLegacy/mac:
+    
+    A key down event may be associated with a key command. If it is then we want to execute the
+    key command instead of inserting or deleting text. We need to ask UIKit to handle the current
+    event as a key command to find out.
+    
+    * WebView/WebHTMLView.mm:
+    (-[WebHTMLView _handleEditingKeyEvent:]):
+    
+    LayoutTests:
+    
+    Add tests to ensure that we process key commands correctly.
+    
+    * fast/events/ios/key-command-italic-dispatches-keydown-expected.txt: Added.
+    * fast/events/ios/key-command-italic-dispatches-keydown.html: Added.
+    * fast/events/ios/key-command-italic-expected.txt: Added.
+    * fast/events/ios/key-command-italic.html: Added.
+    * fast/events/ios/type-digits-holding-control-key-expected.txt: Added.
+    * fast/events/ios/type-digits-holding-control-key.html: Added.
+    * platform/ios-wk1/TestExpectations:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238814 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-12-03  Daniel Bates  <[email protected]>
+
+            [iOS] Do not handle key events that are key commands
+            https://bugs.webkit.org/show_bug.cgi?id=191608
+            <rdar://problem/46046013>
+
+            Reviewed by Ryosuke Niwa.
+
+            Add tests to ensure that we process key commands correctly.
+
+            * fast/events/ios/key-command-italic-dispatches-keydown-expected.txt: Added.
+            * fast/events/ios/key-command-italic-dispatches-keydown.html: Added.
+            * fast/events/ios/key-command-italic-expected.txt: Added.
+            * fast/events/ios/key-command-italic.html: Added.
+            * fast/events/ios/type-digits-holding-control-key-expected.txt: Added.
+            * fast/events/ios/type-digits-holding-control-key.html: Added.
+            * platform/ios-wk1/TestExpectations:
+
 2018-12-03  Guillaume Emont  <[email protected]>
 
         Gardening: unskip marsaglia.js on arm

Added: tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/key-command-italic-dispatches-keydown-expected.txt (0 => 239125)


--- tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/key-command-italic-dispatches-keydown-expected.txt	                        (rev 0)
+++ tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/key-command-italic-dispatches-keydown-expected.txt	2018-12-12 20:43:53 UTC (rev 239125)
@@ -0,0 +1,11 @@
+Tests that pressing Command + I in a rich editing field dispatches a key down event. To run this test by hand, select all the text below and press Command + I.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.event.key is "i"
+PASS window.event.metaKey is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/key-command-italic-dispatches-keydown.html (0 => 239125)


--- tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/key-command-italic-dispatches-keydown.html	                        (rev 0)
+++ tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/key-command-italic-dispatches-keydown.html	2018-12-12 20:43:53 UTC (rev 239125)
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta name="viewport" content="width=device-width">
+<script src=""
+<script src=""
+<style>
+#test {
+    border: 1px solid black;
+    height: 500px;
+    width: 500px;
+}
+
+.hidden {
+    display: none;
+}
+</style>
+</head>
+<body>
+<p id="description"></p>
+<div id="test" contenteditable="true">This text should be italicized.</div>
+<div id="console"></div>
+<script>
+window.jsTestIsAsync = true;
+
+let testElement;
+let event;
+let ignoredFirstKeyDownEvent = false;
+
+function shouldIgnoreKeyDownEvent(event)
+{
+    // When performing the test manually a person is not fast enough to press Command + I simultaneously.
+    // We receive a key down for Command followed by a key down for Command + I. So, we ignore the first
+    // event to normalize the test result.
+    if (window.testRunner || ignoredFirstKeyDownEvent)
+        return false;
+    ignoredFirstKeyDownEvent = true;
+    console.assert(event.key == "Meta");
+    return true;
+}
+
+function handleKeyDownEvent(event)
+{
+    if (shouldIgnoreKeyDownEvent(event))
+        return;
+
+    testElement.removeEventListener("keydown", handleKeyDownEvent, true);
+
+    shouldBeEqualToString("window.event.key", "i");
+    shouldBeTrue("window.event.metaKey");
+
+    // Remove the test element to make the output pretty.
+    document.body.removeChild(document.getElementById("test"));
+
+    finishJSTest();
+}
+
+function runTest()
+{
+    if (!window.testRunner)
+        return;
+    function handleFocus() {
+        window.getSelection().selectAllChildren(testElement);
+        UIHelper.keyDown("i", ["metaKey"]);
+    }
+    testElement.addEventListener("focus", handleFocus, { once: true });
+    UIHelper.activateElement(testElement);
+}
+
+description("Tests that pressing Command + I in a rich editing field dispatches a key down event. To run this test by hand, select all the text below and press Command + I.");
+
+testElement = document.getElementById("test");
+testElement.addEventListener("keydown", handleKeyDownEvent, true);
+
+runTest();
+</script>
+</body>
+</html>

Added: tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/key-command-italic-expected.txt (0 => 239125)


--- tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/key-command-italic-expected.txt	                        (rev 0)
+++ tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/key-command-italic-expected.txt	2018-12-12 20:43:53 UTC (rev 239125)
@@ -0,0 +1,3 @@
+Tests that pressing Command + I in a rich editing field italizes the selection.
+| <i>
+|   "<#selection-anchor>This text should be italicized.<#selection-focus>"

Added: tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/key-command-italic.html (0 => 239125)


--- tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/key-command-italic.html	                        (rev 0)
+++ tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/key-command-italic.html	2018-12-12 20:43:53 UTC (rev 239125)
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta name="viewport" content="width=device-width">
+<script src=""
+<script src=""
+<style>
+#test {
+    border: 1px solid black;
+    height: 500px;
+    width: 500px;
+}
+
+.hidden {
+    display: none;
+}
+</style>
+</head>
+<body>
+<p id="description">Tests that pressing Command + I in a rich editing field italizes the selection.</p>
+<p id="manual-instructions" class="hide">To run this test by hand, select all the text below and press Command + I. This test PASSED if the text becomes italic. Otherwise, it FAILED.</p>
+<div id="test" contenteditable="true">This text should be italicized.</div>
+<script>
+let testElement = document.getElementById("test");
+let mutationObserver = null;
+
+function handleChildListModified()
+{
+    mutationObserver.disconnect();
+    Markup.dump(testElement);
+    Markup.notifyDone();
+}
+
+function runTest()
+{
+    if (!window.testRunner) {
+        document.getElementById("manual-instructions").classList.remove("hidden");
+        return;
+    }
+
+    Markup.description(document.getElementById("description").textContent);
+
+    mutationObserver = new MutationObserver(handleChildListModified);
+    mutationObserver.observe(testElement, { childList: true });
+
+    function handleFocus() {
+        window.getSelection().selectAllChildren(testElement);
+        UIHelper.keyDown("i", ["metaKey"]);
+    }
+    testElement.addEventListener("focus", handleFocus, { once: true });
+    UIHelper.activateElement(testElement);
+}
+
+Markup.waitUntilDone();
+runTest();
+</script>
+</body>
+</html>

Added: tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/type-digits-holding-control-key-expected.txt (0 => 239125)


--- tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/type-digits-holding-control-key-expected.txt	                        (rev 0)
+++ tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/type-digits-holding-control-key-expected.txt	2018-12-12 20:43:53 UTC (rev 239125)
@@ -0,0 +1,3 @@
+Tests that decimal numbers typed while holding down the Control key are inserted.
+
+PASS

Added: tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/type-digits-holding-control-key.html (0 => 239125)


--- tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/type-digits-holding-control-key.html	                        (rev 0)
+++ tags/Safari-607.1.16.2/LayoutTests/fast/events/ios/type-digits-holding-control-key.html	2018-12-12 20:43:53 UTC (rev 239125)
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+<script type="text/plain" id="ui-script">
+const charactersToType = "1234567890".split("");
+for (const c of charactersToType)
+    uiController.keyDown(c, ["ctrlKey"]);
+</script>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+const expectedCharacters = "1234567890";
+
+function checkDone()
+{
+    let input = document.getElementById("input");
+    if (input.value === expectedCharacters) {
+        document.getElementById("result").textContent = "PASS";
+        document.body.removeChild(input);
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }
+}
+
+function runTest()
+{
+    if (!window.testRunner)
+        return;
+
+    function handleFocus() {
+        testRunner.runUIScript(document.getElementById("ui-script").text, () => { /* Do nothing */ });
+    }
+    let input = document.getElementById("input");
+    input.addEventListener("focus", handleFocus, { once: true });
+    UIHelper.activateFormControl(input);
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests that decimal numbers typed while holding down the <key>Control</key> key are inserted.</p>
+<!--
+Note that when running this test by hande this test assumes that iOS maps Control + k to k for some non-numpad numeral. This
+is a non-issue when running the test in WebKitTestRunner because uiController.keyDown() generates "after key mapping" events.
+-->
+<input type="text" id="input" size="100" _oninput_="checkDone()">
+<div id="result">FAIL</div>
+</body>
+</html>

Modified: tags/Safari-607.1.16.2/LayoutTests/platform/ios-wk1/TestExpectations (239124 => 239125)


--- tags/Safari-607.1.16.2/LayoutTests/platform/ios-wk1/TestExpectations	2018-12-12 19:15:58 UTC (rev 239124)
+++ tags/Safari-607.1.16.2/LayoutTests/platform/ios-wk1/TestExpectations	2018-12-12 20:43:53 UTC (rev 239125)
@@ -33,6 +33,9 @@
 
 # No support for testing key commands with modifiers in WK1
 fast/events/ios/focus-tab-previous-field.html [ Skip ]
+fast/events/ios/key-command-italic-dispatches-keydown.html [ Skip ]
+fast/events/ios/key-command-italic.html [ Skip ]
+fast/events/ios/type-digits-holding-control-key.html [ Skip ]
 
 # <input type=color> is not supported in WebKit1 on iOS.
 fast/forms/color/input-color-onchange-event.html [ Failure ]

Modified: tags/Safari-607.1.16.2/Source/WebKit/ChangeLog (239124 => 239125)


--- tags/Safari-607.1.16.2/Source/WebKit/ChangeLog	2018-12-12 19:15:58 UTC (rev 239124)
+++ tags/Safari-607.1.16.2/Source/WebKit/ChangeLog	2018-12-12 20:43:53 UTC (rev 239125)
@@ -1,5 +1,73 @@
 2018-12-12  Kocsen Chung  <[email protected]>
 
+        Cherry-pick r238814. rdar://problem/46046013
+
+    [iOS] Do not handle key events that are key commands
+    https://bugs.webkit.org/show_bug.cgi?id=191608
+    <rdar://problem/46046013>
+    
+    Reviewed by Ryosuke Niwa.
+    
+    Source/WebKit:
+    
+    A key down event may be associated with a key command. If it is then we want to execute the
+    key command instead of inserting or deleting text. We need to ask UIKit to handle the current
+    event as a key command to find out.
+    
+    * UIProcess/ios/WKContentViewInteraction.mm:
+    (-[WKContentView _interpretKeyEvent:isCharEvent:]): Ask UIKit to handle the current event
+    as a key command. If it handles it then we're done. Otherwise, do what we do now.
+    
+    Source/WebKitLegacy/ios:
+    
+    Add default implementation of -handleKeyCommandForCurrentEvent that returns NO - the current
+    event was not handled as a key command.
+    
+    * DefaultDelegates/WebDefaultUIKitDelegate.m:
+    (-[WebDefaultUIKitDelegate handleKeyCommandForCurrentEvent]):
+    * WebView/WebUIKitDelegate.h:
+    
+    Source/WebKitLegacy/mac:
+    
+    A key down event may be associated with a key command. If it is then we want to execute the
+    key command instead of inserting or deleting text. We need to ask UIKit to handle the current
+    event as a key command to find out.
+    
+    * WebView/WebHTMLView.mm:
+    (-[WebHTMLView _handleEditingKeyEvent:]):
+    
+    LayoutTests:
+    
+    Add tests to ensure that we process key commands correctly.
+    
+    * fast/events/ios/key-command-italic-dispatches-keydown-expected.txt: Added.
+    * fast/events/ios/key-command-italic-dispatches-keydown.html: Added.
+    * fast/events/ios/key-command-italic-expected.txt: Added.
+    * fast/events/ios/key-command-italic.html: Added.
+    * fast/events/ios/type-digits-holding-control-key-expected.txt: Added.
+    * fast/events/ios/type-digits-holding-control-key.html: Added.
+    * platform/ios-wk1/TestExpectations:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238814 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-12-03  Daniel Bates  <[email protected]>
+
+            [iOS] Do not handle key events that are key commands
+            https://bugs.webkit.org/show_bug.cgi?id=191608
+            <rdar://problem/46046013>
+
+            Reviewed by Ryosuke Niwa.
+
+            A key down event may be associated with a key command. If it is then we want to execute the
+            key command instead of inserting or deleting text. We need to ask UIKit to handle the current
+            event as a key command to find out.
+
+            * UIProcess/ios/WKContentViewInteraction.mm:
+            (-[WKContentView _interpretKeyEvent:isCharEvent:]): Ask UIKit to handle the current event
+            as a key command. If it handles it then we're done. Otherwise, do what we do now.
+
+2018-12-12  Kocsen Chung  <[email protected]>
+
         Cherry-pick r239046. rdar://problem/46500832
 
     Add SPI to allow the client to set the user-agent at main frame level, from the UIProcess

Modified: tags/Safari-607.1.16.2/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (239124 => 239125)


--- tags/Safari-607.1.16.2/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-12-12 19:15:58 UTC (rev 239124)
+++ tags/Safari-607.1.16.2/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-12-12 20:43:53 UTC (rev 239125)
@@ -133,6 +133,14 @@
 
 #endif
 
+#if PLATFORM(IOS_FAMILY)
+
+@interface UIKeyboardImpl (Staging)
+- (BOOL)handleKeyCommandForCurrentEvent;
+@end
+
+#endif
+
 using namespace WebCore;
 using namespace WebKit;
 
@@ -3963,8 +3971,13 @@
         return YES;
 
     UIKeyboardImpl *keyboard = [UIKeyboardImpl sharedInstance];
+
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
+    if (event.type == WebEventKeyDown && [keyboard respondsToSelector:@selector(handleKeyCommandForCurrentEvent)] && [keyboard handleKeyCommandForCurrentEvent])
+        return YES;
+#endif
+
     NSString *characters = event.characters;
-    
     if (!characters.length)
         return NO;
 

Modified: tags/Safari-607.1.16.2/Source/WebKitLegacy/ios/ChangeLog (239124 => 239125)


--- tags/Safari-607.1.16.2/Source/WebKitLegacy/ios/ChangeLog	2018-12-12 19:15:58 UTC (rev 239124)
+++ tags/Safari-607.1.16.2/Source/WebKitLegacy/ios/ChangeLog	2018-12-12 20:43:53 UTC (rev 239125)
@@ -1,3 +1,70 @@
+2018-12-12  Kocsen Chung  <[email protected]>
+
+        Cherry-pick r238814. rdar://problem/46046013
+
+    [iOS] Do not handle key events that are key commands
+    https://bugs.webkit.org/show_bug.cgi?id=191608
+    <rdar://problem/46046013>
+    
+    Reviewed by Ryosuke Niwa.
+    
+    Source/WebKit:
+    
+    A key down event may be associated with a key command. If it is then we want to execute the
+    key command instead of inserting or deleting text. We need to ask UIKit to handle the current
+    event as a key command to find out.
+    
+    * UIProcess/ios/WKContentViewInteraction.mm:
+    (-[WKContentView _interpretKeyEvent:isCharEvent:]): Ask UIKit to handle the current event
+    as a key command. If it handles it then we're done. Otherwise, do what we do now.
+    
+    Source/WebKitLegacy/ios:
+    
+    Add default implementation of -handleKeyCommandForCurrentEvent that returns NO - the current
+    event was not handled as a key command.
+    
+    * DefaultDelegates/WebDefaultUIKitDelegate.m:
+    (-[WebDefaultUIKitDelegate handleKeyCommandForCurrentEvent]):
+    * WebView/WebUIKitDelegate.h:
+    
+    Source/WebKitLegacy/mac:
+    
+    A key down event may be associated with a key command. If it is then we want to execute the
+    key command instead of inserting or deleting text. We need to ask UIKit to handle the current
+    event as a key command to find out.
+    
+    * WebView/WebHTMLView.mm:
+    (-[WebHTMLView _handleEditingKeyEvent:]):
+    
+    LayoutTests:
+    
+    Add tests to ensure that we process key commands correctly.
+    
+    * fast/events/ios/key-command-italic-dispatches-keydown-expected.txt: Added.
+    * fast/events/ios/key-command-italic-dispatches-keydown.html: Added.
+    * fast/events/ios/key-command-italic-expected.txt: Added.
+    * fast/events/ios/key-command-italic.html: Added.
+    * fast/events/ios/type-digits-holding-control-key-expected.txt: Added.
+    * fast/events/ios/type-digits-holding-control-key.html: Added.
+    * platform/ios-wk1/TestExpectations:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238814 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-12-03  Daniel Bates  <[email protected]>
+
+            [iOS] Do not handle key events that are key commands
+            https://bugs.webkit.org/show_bug.cgi?id=191608
+            <rdar://problem/46046013>
+
+            Reviewed by Ryosuke Niwa.
+
+            Add default implementation of -handleKeyCommandForCurrentEvent that returns NO - the current
+            event was not handled as a key command.
+
+            * DefaultDelegates/WebDefaultUIKitDelegate.m:
+            (-[WebDefaultUIKitDelegate handleKeyCommandForCurrentEvent]):
+            * WebView/WebUIKitDelegate.h:
+
 2018-11-29  Zalan Bujtas  <[email protected]>
 
         Rename *ObservedContentModifier(s) to *ObservedDOMTimer(s)

Modified: tags/Safari-607.1.16.2/Source/WebKitLegacy/ios/DefaultDelegates/WebDefaultUIKitDelegate.m (239124 => 239125)


--- tags/Safari-607.1.16.2/Source/WebKitLegacy/ios/DefaultDelegates/WebDefaultUIKitDelegate.m	2018-12-12 19:15:58 UTC (rev 239124)
+++ tags/Safari-607.1.16.2/Source/WebKitLegacy/ios/DefaultDelegates/WebDefaultUIKitDelegate.m	2018-12-12 20:43:53 UTC (rev 239125)
@@ -162,6 +162,11 @@
 {
 }
 
+- (BOOL)handleKeyCommandForCurrentEvent
+{
+    return NO;
+}
+
 - (void)addInputString:(NSString *)str withFlags:(NSUInteger)flags
 {
 }

Modified: tags/Safari-607.1.16.2/Source/WebKitLegacy/ios/WebView/WebUIKitDelegate.h (239124 => 239125)


--- tags/Safari-607.1.16.2/Source/WebKitLegacy/ios/WebView/WebUIKitDelegate.h	2018-12-12 19:15:58 UTC (rev 239124)
+++ tags/Safari-607.1.16.2/Source/WebKitLegacy/ios/WebView/WebUIKitDelegate.h	2018-12-12 20:43:53 UTC (rev 239125)
@@ -90,6 +90,7 @@
 - (void)webView:(WebView *)webView didHideFullScreenForPlugInView:(id)plugInView;
 - (void)webView:(WebView *)aWebView didReceiveMessage:(NSDictionary *)aMessage;
 - (void)addInputString:(NSString *)str withFlags:(NSUInteger)flags;
+- (BOOL)handleKeyCommandForCurrentEvent;
 // FIXME: remove deleteFromInput when UIKit implements deleteFromInputWithFlags.
 - (void)deleteFromInput;
 - (void)deleteFromInputWithFlags:(NSUInteger)flags;

Modified: tags/Safari-607.1.16.2/Source/WebKitLegacy/mac/ChangeLog (239124 => 239125)


--- tags/Safari-607.1.16.2/Source/WebKitLegacy/mac/ChangeLog	2018-12-12 19:15:58 UTC (rev 239124)
+++ tags/Safari-607.1.16.2/Source/WebKitLegacy/mac/ChangeLog	2018-12-12 20:43:53 UTC (rev 239125)
@@ -1,5 +1,72 @@
 2018-12-12  Kocsen Chung  <[email protected]>
 
+        Cherry-pick r238814. rdar://problem/46046013
+
+    [iOS] Do not handle key events that are key commands
+    https://bugs.webkit.org/show_bug.cgi?id=191608
+    <rdar://problem/46046013>
+    
+    Reviewed by Ryosuke Niwa.
+    
+    Source/WebKit:
+    
+    A key down event may be associated with a key command. If it is then we want to execute the
+    key command instead of inserting or deleting text. We need to ask UIKit to handle the current
+    event as a key command to find out.
+    
+    * UIProcess/ios/WKContentViewInteraction.mm:
+    (-[WKContentView _interpretKeyEvent:isCharEvent:]): Ask UIKit to handle the current event
+    as a key command. If it handles it then we're done. Otherwise, do what we do now.
+    
+    Source/WebKitLegacy/ios:
+    
+    Add default implementation of -handleKeyCommandForCurrentEvent that returns NO - the current
+    event was not handled as a key command.
+    
+    * DefaultDelegates/WebDefaultUIKitDelegate.m:
+    (-[WebDefaultUIKitDelegate handleKeyCommandForCurrentEvent]):
+    * WebView/WebUIKitDelegate.h:
+    
+    Source/WebKitLegacy/mac:
+    
+    A key down event may be associated with a key command. If it is then we want to execute the
+    key command instead of inserting or deleting text. We need to ask UIKit to handle the current
+    event as a key command to find out.
+    
+    * WebView/WebHTMLView.mm:
+    (-[WebHTMLView _handleEditingKeyEvent:]):
+    
+    LayoutTests:
+    
+    Add tests to ensure that we process key commands correctly.
+    
+    * fast/events/ios/key-command-italic-dispatches-keydown-expected.txt: Added.
+    * fast/events/ios/key-command-italic-dispatches-keydown.html: Added.
+    * fast/events/ios/key-command-italic-expected.txt: Added.
+    * fast/events/ios/key-command-italic.html: Added.
+    * fast/events/ios/type-digits-holding-control-key-expected.txt: Added.
+    * fast/events/ios/type-digits-holding-control-key.html: Added.
+    * platform/ios-wk1/TestExpectations:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238814 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-12-03  Daniel Bates  <[email protected]>
+
+            [iOS] Do not handle key events that are key commands
+            https://bugs.webkit.org/show_bug.cgi?id=191608
+            <rdar://problem/46046013>
+
+            Reviewed by Ryosuke Niwa.
+
+            A key down event may be associated with a key command. If it is then we want to execute the
+            key command instead of inserting or deleting text. We need to ask UIKit to handle the current
+            event as a key command to find out.
+
+            * WebView/WebHTMLView.mm:
+            (-[WebHTMLView _handleEditingKeyEvent:]):
+
+2018-12-12  Kocsen Chung  <[email protected]>
+
         Cherry-pick r239088. rdar://problem/46615532
 
     WebCore shouldn't have a Objective-C class named NSCursor

Modified: tags/Safari-607.1.16.2/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm (239124 => 239125)


--- tags/Safari-607.1.16.2/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2018-12-12 19:15:58 UTC (rev 239124)
+++ tags/Safari-607.1.16.2/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2018-12-12 20:43:53 UTC (rev 239125)
@@ -6087,13 +6087,19 @@
         WebEvent *event = platformEvent->event();
         if (event.keyboardFlags & WebEventKeyboardInputModifierFlagsChanged)
             return NO;
-        if (![[self _webView] isEditable] && event.isTabKey) 
+
+        WebView *webView = [self _webView];
+        if (!webView.isEditable && event.isTabKey)
             return NO;
-        
+
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
+        if (event.type == WebEventKeyDown && [webView._UIKitDelegateForwarder handleKeyCommandForCurrentEvent])
+            return YES;
+#endif
+
         NSString *s = [event characters];
         if (!s.length)
             return NO;
-        WebView* webView = [self _webView];
         switch ([s characterAtIndex:0]) {
         case kWebBackspaceKey:
         case kWebDeleteKey:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to