Title: [262889] trunk
Revision
262889
Author
commit-qu...@webkit.org
Date
2020-06-10 19:20:45 -0700 (Wed, 10 Jun 2020)

Log Message

[iOS] Option + Forward Delete should delete next word
https://bugs.webkit.org/show_bug.cgi?id=213062
rdar://64225458

Patch by Hiro (mzp) Mizuno <m...@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

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (262888 => 262889)


--- trunk/LayoutTests/ChangeLog	2020-06-11 01:05:28 UTC (rev 262888)
+++ trunk/LayoutTests/ChangeLog	2020-06-11 02:20:45 UTC (rev 262889)
@@ -1,3 +1,18 @@
+2020-06-10  Hiro (mzp) Mizuno  <m...@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.fu...@sony.com>
 
         [WinCairo] Unreviewed test gardening

Added: trunk/LayoutTests/fast/events/ios/key-command-delete-next-word-expected.txt (0 => 262889)


--- trunk/LayoutTests/fast/events/ios/key-command-delete-next-word-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/key-command-delete-next-word-expected.txt	2020-06-11 02:20:45 UTC (rev 262889)
@@ -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
+

Added: trunk/LayoutTests/fast/events/ios/key-command-delete-next-word.html (0 => 262889)


--- trunk/LayoutTests/fast/events/ios/key-command-delete-next-word.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/key-command-delete-next-word.html	2020-06-11 02:20:45 UTC (rev 262889)
@@ -0,0 +1,63 @@
+<!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>
+<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>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (262888 => 262889)


--- trunk/LayoutTests/platform/ios/TestExpectations	2020-06-11 01:05:28 UTC (rev 262888)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2020-06-11 02:20:45 UTC (rev 262889)
@@ -258,6 +258,9 @@
 
 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
 

Modified: trunk/Source/WebKit/ChangeLog (262888 => 262889)


--- trunk/Source/WebKit/ChangeLog	2020-06-11 01:05:28 UTC (rev 262888)
+++ trunk/Source/WebKit/ChangeLog	2020-06-11 02:20:45 UTC (rev 262889)
@@ -1,3 +1,18 @@
+2020-06-10  Hiro (mzp) Mizuno  <m...@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  <gga...@apple.com>
 
         Some style improvements to main thread code

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (262888 => 262889)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-06-11 01:05:28 UTC (rev 262888)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-06-11 02:20:45 UTC (rev 262889)
@@ -3293,7 +3293,7 @@
         || 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 @@
     [self executeEditCommandWithCallback:@"deleteWordBackward"];
 }
 
+- (void)_deleteForwardByWord
+{
+    [self executeEditCommandWithCallback:@"deleteWordForward"];
+}
+
 - (void)_deleteToStartOfLine
 {
     [self executeEditCommandWithCallback:@"deleteToBeginningOfLine"];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to