[iOS] Pressing forward delete key in text field does nothing and we should not invoke...
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Nov 2018 17:06:50 +0000 (17:06 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Nov 2018 17:06:50 +0000 (17:06 +0000)
action when forward delete is pressed outside a text field
https://bugs.webkit.org/show_bug.cgi?id=190566
<rdar://problem/45262367>

Reviewed by Wenson Hsieh.

Source/WebKit:

Override -_deleteForwardAndNotify to perform a forward deletion and remove the dead code that
expected UIKit to send us a character string with 0xF728 for the forward delete key. UIKit
ceased doing this many years ago. We may revist this decision once <rdar://problem/45772078>
is fixed.

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

Source/WebKitLegacy/mac:

Remove dead code. UIKit ceased sending us a character string with 0xF728 for the forward delete
key many years ago. We will need to fix up iOS Legacy WebKit support for the forward delete key
in UIKit. We may revist this decision once <rdar://problem/45772078> is fixed.

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

LayoutTests:

Add a test to ensure that pressing the forward delete key deletes the next character.

* fast/events/ios/forward-delete-in-editable-expected.txt: Added.
* fast/events/ios/forward-delete-in-editable.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/events/ios/forward-delete-in-editable-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/ios/forward-delete-in-editable.html [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebHTMLView.mm

index 662822d..6ca3f70 100644 (file)
@@ -1,3 +1,17 @@
+2018-11-09  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Pressing forward delete key in text field does nothing and we should not invoke an editor
+        action when forward delete is pressed outside a text field
+        https://bugs.webkit.org/show_bug.cgi?id=190566
+        <rdar://problem/45262367>
+
+        Reviewed by Wenson Hsieh.
+
+        Add a test to ensure that pressing the forward delete key deletes the next character.
+
+        * fast/events/ios/forward-delete-in-editable-expected.txt: Added.
+        * fast/events/ios/forward-delete-in-editable.html: Added.
+
 2018-11-09  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         REGRESSION(r236365): [GTK] Many form-related tests are failing
diff --git a/LayoutTests/fast/events/ios/forward-delete-in-editable-expected.txt b/LayoutTests/fast/events/ios/forward-delete-in-editable-expected.txt
new file mode 100644 (file)
index 0000000..a59d259
--- /dev/null
@@ -0,0 +1,10 @@
+Tests that pressing the forward delete key in an editable element deletes the next character. To run this test manually, press the forward delete key and then click Check Result.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.getElementById("input").value is "ext"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/events/ios/forward-delete-in-editable.html b/LayoutTests/fast/events/ios/forward-delete-in-editable.html
new file mode 100644 (file)
index 0000000..a93b9b7
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/js-test.js"></script>
+<script src="../../../resources/ui-helper.js"></script>
+</head>
+<body>
+<div id="test-container">
+    <input type="text" id="input" value="Text">
+    <button onclick="checkResultAndNotifyDone()">Check Result</button>
+</div>
+<script>
+window.jsTestIsAsync = true;
+
+description("Tests that pressing the forward delete key in an editable element deletes the next character. To run this test  manually, press the forward delete key and then click Check Result.");
+
+runTest();
+
+async function runTest()
+{
+    let inputElement = document.getElementById("input");
+    if (!window.testRunner) {
+        inputElement.focus();
+        inputElement.setSelectionRange(0, 0);
+        return;
+    }
+    // FIXME: We cannot listen for a keyup event because the forward delete key does not generate one
+    // due to <rdar://problem/45772078>. So, we listen for a blur event.
+    inputElement.addEventListener("blur", checkResultAndNotifyDone, {once: true});
+    await UIHelper.activateFormControl(inputElement);
+    inputElement.setSelectionRange(0, 0);
+    await UIHelper.typeCharacter("forwardDelete");
+    inputElement.blur();
+}
+
+function checkResultAndNotifyDone()
+{
+    shouldBeEqualToString('document.getElementById("input").value', "ext");
+    document.body.removeChild(document.getElementById("test-container"));
+    finishJSTest();
+}
+</script>
+</body>
+</html>
index 8c30e4c..1718f28 100644 (file)
@@ -1,3 +1,21 @@
+2018-11-09  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Pressing forward delete key in text field does nothing and we should not invoke an editor
+        action when forward delete is pressed outside a text field
+        https://bugs.webkit.org/show_bug.cgi?id=190566
+        <rdar://problem/45262367>
+
+        Reviewed by Wenson Hsieh.
+
+        Override -_deleteForwardAndNotify to perform a forward deletion and remove the dead code that
+        expected UIKit to send us a character string with 0xF728 for the forward delete key. UIKit
+        ceased doing this many years ago. We may revist this decision once <rdar://problem/45772078>
+        is fixed.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _interpretKeyEvent:isCharEvent:]):
+        (-[WKContentView _deleteForwardAndNotify:]):
+
 2018-11-08  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Unreviewed, try to fix the 32-bit macOS build
index 614ad9f..ee5dff8 100644 (file)
@@ -3823,7 +3823,6 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName)
     static const unsigned kWebBackspaceKey = 0x0008;
     static const unsigned kWebReturnKey = 0x000D;
     static const unsigned kWebDeleteKey = 0x007F;
-    static const unsigned kWebDeleteForwardKey = 0xF728;
     static const unsigned kWebSpaceKey = 0x20;
 
     if (event.keyboardFlags & WebEventKeyboardInputModifierFlagsChanged)
@@ -3868,10 +3867,6 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName)
         }
         break;
 
-    case kWebDeleteForwardKey:
-        _page->executeEditCommand("deleteForward"_s);
-        return YES;
-
     default:
         if (contentEditable && isCharEvent) {
             [keyboard addInputString:event.characters withFlags:event.keyboardFlags withInputManagerHint:event.inputManagerHint];
@@ -3942,6 +3937,11 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName)
     [self executeEditCommandWithCallback:@"deleteToEndOfLine"];
 }
 
+- (void)_deleteForwardAndNotify:(BOOL)notify
+{
+    [self executeEditCommandWithCallback:@"deleteForward"];
+}
+
 - (UITextInputArrowKeyHistory *)_moveUp:(BOOL)extending withHistory:(UITextInputArrowKeyHistory *)history
 {
     [self executeEditCommandWithCallback:extending ? @"moveUpAndModifySelection" : @"moveUp"];
index 69a29e5..a03a78a 100644 (file)
@@ -1,3 +1,19 @@
+2018-11-09  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Pressing forward delete key in text field does nothing and we should not invoke an editor
+        action when forward delete is pressed outside a text field
+        https://bugs.webkit.org/show_bug.cgi?id=190566
+        <rdar://problem/45262367>
+
+        Reviewed by Wenson Hsieh.
+
+        Remove dead code. UIKit ceased sending us a character string with 0xF728 for the forward delete
+        key many years ago. We will need to fix up iOS Legacy WebKit support for the forward delete key
+        in UIKit. We may revist this decision once <rdar://problem/45772078> is fixed.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _handleEditingKeyEvent:]):
+
 2018-11-08  Megan Gardner  <megan_gardner@apple.com>
 
         Adopt Reveal Framework to replace Lookup
index 6ddaca1..734fd02 100644 (file)
@@ -6054,7 +6054,6 @@ static BOOL writingDirectionKeyBindingsEnabled()
 #define kWebBackspaceKey     0x0008
 #define kWebReturnKey        0x000d
 #define kWebDeleteKey        0x007F
-#define kWebDeleteForwardKey 0xF728
     
 - (BOOL)_handleEditingKeyEvent:(KeyboardEvent *)wcEvent
 {
@@ -6089,9 +6088,6 @@ static BOOL writingDirectionKeyBindingsEnabled()
                 return YES;
             }
             break;
-        case kWebDeleteForwardKey:
-            [self deleteForward:self];
-            return YES;
         default:
             if (platformEvent->type() == PlatformKeyboardEvent::Char) {
                 [[webView _UIKitDelegateForwarder] addInputString:event.characters withFlags:event.keyboardFlags];