[iOS] Option + Forward Delete should delete next word
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jun 2020 02:20:45 +0000 (02:20 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jun 2020 02:20:45 +0000 (02:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=213062
rdar://64225458

Patch by Hiro (mzp) Mizuno <mzp@apple.com> on 2020-06-10
Reviewed by Daniel Bates.

Source/WebKit:

Implement support for pressing Option + Forward Delete to delete the next word. This makes text editing
in WebKit more closely match the platform conventions.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView canPerformAction:withSender:]): Handle _deleteForwardByWord.
(-[WKContentView _deleteForwardByWord]): Added.

LayoutTests:

Add tests to ensure that Option + Forward Delete delete to the next word.
Skip the tests for now until we have the UIKit fix <rdar://problem/63253983>.

* fast/events/ios/key-command-delete-next-word-expected.txt: Added.
* fast/events/ios/key-command-delete-next-word.html: Added.
* platform/ios/TestExpectations: Skip tests for now

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

LayoutTests/ChangeLog
LayoutTests/fast/events/ios/key-command-delete-next-word-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/ios/key-command-delete-next-word.html [new file with mode: 0644]
LayoutTests/platform/ios/TestExpectations
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

index 49983a2..5ef78e6 100644 (file)
@@ -1,3 +1,18 @@
+2020-06-10  Hiro (mzp) Mizuno  <mzp@apple.com>
+
+        [iOS] Option + Forward Delete should delete next word
+        https://bugs.webkit.org/show_bug.cgi?id=213062
+        rdar://64225458
+
+        Reviewed by Daniel Bates.
+
+        Add tests to ensure that Option + Forward Delete delete to the next word.
+        Skip the tests for now until we have the UIKit fix <rdar://problem/63253983>.
+
+        * fast/events/ios/key-command-delete-next-word-expected.txt: Added.
+        * fast/events/ios/key-command-delete-next-word.html: Added.
+        * platform/ios/TestExpectations: Skip tests for now
+
 2020-06-10  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         [WinCairo] Unreviewed test gardening
diff --git a/LayoutTests/fast/events/ios/key-command-delete-next-word-expected.txt b/LayoutTests/fast/events/ios/key-command-delete-next-word-expected.txt
new file mode 100644 (file)
index 0000000..8d67617
--- /dev/null
@@ -0,0 +1,12 @@
+Tests that pressing Option + Forward Delete in a content-editable field deletes to next word.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+To run this test by hand, place the text insertion point at the begin of the text below and press Option + Forward Delete.
+
+PASS document.getElementById("test").textContent is "world"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/events/ios/key-command-delete-next-word.html b/LayoutTests/fast/events/ios/key-command-delete-next-word.html
new file mode 100644 (file)
index 0000000..00bdb24
--- /dev/null
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta name="viewport" content="width=device-width">
+<script src="../../../resources/js-test.js"></script>
+<script src="../../../resources/ui-helper.js"></script>
+<style>
+#test {
+    border: 1px solid black;
+    height: 500px;
+    width: 500px;
+}
+
+.hidden {
+    display: none;
+}
+</style>
+</head>
+<body>
+<p id="description"></p>
+<p id="manual-instructions" class="hide">To run this test by hand, place the text insertion point at the begin of the text below and press Option + Forward Delete.</p>
+<div id="console"></div>
+<div id="test" contenteditable="true">hello world</div>
+<script>
+window.jsTestIsAsync = true;
+
+let testElement = document.getElementById("test");
+let mutationObserver = null;
+
+function handleMutation()
+{
+    mutationObserver.disconnect();
+    shouldBeEqualToString('document.getElementById("test").textContent', "world");
+    document.body.removeChild(testElement);
+    finishJSTest();
+}
+
+async function runTest()
+{
+    if (!window.testRunner)
+        document.getElementById("manual-instructions").classList.remove("hidden");
+
+    mutationObserver = new MutationObserver(handleMutation);
+    mutationObserver.observe(testElement, { subtree:true, characterData: true });
+
+    function handleFocus() {
+        window.getSelection().setBaseAndExtent(testElement.firstChild, 0, testElement.firstChild, 0); // Put caret before the 'h'.
+        if (window.testRunner)
+            UIHelper.keyDown("forwardDelete", ["altKey"]);
+    }
+
+    if (window.testRunner) {
+        await UIHelper.activateElement(testElement);
+        handleFocus();
+    } else
+        testElement.addEventListener("focus", handleFocus, { once: true });
+}
+
+description("Tests that pressing Option + Forward Delete in a content-editable field deletes to next word.");
+runTest();
+</script>
+</body>
+</html>
index a2894a8..58350ce 100644 (file)
@@ -258,6 +258,9 @@ webkit.org/b/152491 fast/text/woff2.html [ Skip ]
 
 webkit.org/b/162668 fast/text/woff2-totalsfntsize.html [ Skip ]
 
+# FIXME: Unskip the following test once we have the fix for <rdar://problem/63253983>.
+fast/events/ios/key-command-delete-next-word.html [ Skip ]
+
 # Needs testRunner.enableAutoResizeMode()
 fast/autoresize
 
index b27b50d..cc134af 100644 (file)
@@ -1,3 +1,18 @@
+2020-06-10  Hiro (mzp) Mizuno  <mzp@apple.com>
+
+        [iOS] Option + Forward Delete should delete next word
+        https://bugs.webkit.org/show_bug.cgi?id=213062
+        rdar://64225458
+
+        Reviewed by Daniel Bates.
+
+        Implement support for pressing Option + Forward Delete to delete the next word. This makes text editing
+        in WebKit more closely match the platform conventions.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView canPerformAction:withSender:]): Handle _deleteForwardByWord.
+        (-[WKContentView _deleteForwardByWord]): Added.
+
 2020-06-10  Geoffrey Garen  <ggaren@apple.com>
 
         Some style improvements to main thread code
index d2b4f73..61b1624 100644 (file)
@@ -3293,7 +3293,7 @@ WEBCORE_COMMAND_FOR_WEBVIEW(pasteAndMatchStyle);
         || action == @selector(_moveToStartOfParagraph:withHistory:) || action == @selector(_moveToStartOfWord:withHistory:) || action == @selector(_moveUp:withHistory:))
         return !editorState.selectionIsNone;
 
-    if (action == @selector(_deleteByWord) || action == @selector(_deleteForwardAndNotify:) || action == @selector(_deleteToEndOfParagraph) || action == @selector(_deleteToStartOfLine)
+    if (action == @selector(_deleteByWord) || action == @selector(_deleteForwardByWord) || action == @selector(_deleteForwardAndNotify:) || action == @selector(_deleteToEndOfParagraph) || action == @selector(_deleteToStartOfLine)
         || action == @selector(_transpose))
         return editorState.isContentEditable;
 
@@ -5492,6 +5492,11 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName)
     [self executeEditCommandWithCallback:@"deleteWordBackward"];
 }
 
+- (void)_deleteForwardByWord
+{
+    [self executeEditCommandWithCallback:@"deleteWordForward"];
+}
+
 - (void)_deleteToStartOfLine
 {
     [self executeEditCommandWithCallback:@"deleteToBeginningOfLine"];