Title: [231967] trunk
Revision
231967
Author
[email protected]
Date
2018-05-18 11:23:45 -0700 (Fri, 18 May 2018)

Log Message

[Extra zoom mode] Clearing text fields should dispatch input events of type "deleteContent"
https://bugs.webkit.org/show_bug.cgi?id=185769
<rdar://problem/40368261>

Reviewed by Tim Horton.

Source/WebKit:

When setting the text of the currently focused element to the empty string, just delete the text instead of
pretending to insert an empty string. This mimics deleting content using the delete key on macOS, and fires an
input event with inputType "deleteContent" instead of "insertText".

Test: fast/forms/extrazoom/delete-content-in-text-field.html

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setTextAsync):

LayoutTests:

Adds a new test to inspect the input events dispatched as a result of inserting and deleting text in a form
control. The inputTypes should be "insertText" and "deleteContent", respectively; the data values should be the
inserted string and null, respectively.

* fast/forms/extrazoom/delete-content-in-text-field-expected.txt: Added.
* fast/forms/extrazoom/delete-content-in-text-field.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (231966 => 231967)


--- trunk/LayoutTests/ChangeLog	2018-05-18 18:17:28 UTC (rev 231966)
+++ trunk/LayoutTests/ChangeLog	2018-05-18 18:23:45 UTC (rev 231967)
@@ -1,3 +1,18 @@
+2018-05-18  Wenson Hsieh  <[email protected]>
+
+        [Extra zoom mode] Clearing text fields should dispatch input events of type "deleteContent"
+        https://bugs.webkit.org/show_bug.cgi?id=185769
+        <rdar://problem/40368261>
+
+        Reviewed by Tim Horton.
+
+        Adds a new test to inspect the input events dispatched as a result of inserting and deleting text in a form
+        control. The inputTypes should be "insertText" and "deleteContent", respectively; the data values should be the
+        inserted string and null, respectively.
+
+        * fast/forms/extrazoom/delete-content-in-text-field-expected.txt: Added.
+        * fast/forms/extrazoom/delete-content-in-text-field.html: Added.
+
 2018-05-18  Youenn Fablet  <[email protected]>
 
         Layout Test http/wpt/service-workers/header-filtering.https.html is a flaky failure

Added: trunk/LayoutTests/fast/forms/extrazoom/delete-content-in-text-field-expected.txt (0 => 231967)


--- trunk/LayoutTests/fast/forms/extrazoom/delete-content-in-text-field-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/extrazoom/delete-content-in-text-field-expected.txt	2018-05-18 18:23:45 UTC (rev 231967)
@@ -0,0 +1,12 @@
+PASS inputEventAfterInsertingText.type is 'input'
+PASS inputEventAfterInsertingText.inputType is 'insertText'
+PASS inputEventAfterInsertingText.data is 'testing'
+PASS valueAfterInsertingText is 'testing'
+PASS inputEventAfterDeletingText.type is 'input'
+PASS inputEventAfterDeletingText.inputType is 'deleteContent'
+PASS inputEventAfterDeletingText.data is null
+PASS valueAfterDeletingText is ''
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/extrazoom/delete-content-in-text-field.html (0 => 231967)


--- trunk/LayoutTests/fast/forms/extrazoom/delete-content-in-text-field.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/extrazoom/delete-content-in-text-field.html	2018-05-18 18:23:45 UTC (rev 231967)
@@ -0,0 +1,60 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<meta name="viewport" content="width=device-width">
+<head>
+<script src=""
+<script src=""
+<script>
+doneCount = 0;
+lastInputEvent = null;
+jsTestIsAsync = true;
+
+function enterTextAndWaitForKeyboardToHide(text) {
+    return new Promise(async resolve => {
+        await UIHelper.activateAndWaitForInputSessionAt(100, 100);
+        UIHelper.waitForKeyboardToHide().then(resolve);
+        UIHelper.enterText(text);
+    });
+}
+
+async function runTest() {
+    if (!window.testRunner) {
+        description(`This test requires WebKitTestRunner.`);
+        return;
+    }
+
+    await enterTextAndWaitForKeyboardToHide("testing");
+    inputEventAfterInsertingText = lastInputEvent;
+    valueAfterInsertingText = field.value;
+
+    await enterTextAndWaitForKeyboardToHide("");
+    inputEventAfterDeletingText = lastInputEvent;
+    valueAfterDeletingText = field.value;
+
+    shouldBe("inputEventAfterInsertingText.type", "'input'");
+    shouldBe("inputEventAfterInsertingText.inputType", "'insertText'");
+    shouldBe("inputEventAfterInsertingText.data", "'testing'");
+    shouldBe("valueAfterInsertingText", "'testing'");
+
+    shouldBe("inputEventAfterDeletingText.type", "'input'");
+    shouldBe("inputEventAfterDeletingText.inputType", "'deleteContent'");
+    shouldBe("inputEventAfterDeletingText.data", "null");
+    shouldBe("valueAfterDeletingText", "''");
+
+    checkDone();
+}
+
+function handleInput(event) {
+    lastInputEvent = event;
+}
+
+function checkDone() {
+    if (++doneCount === 3)
+        finishJSTest();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<input id="field" style="width: 320px; height: 568px;" _oninput_="handleInput(event)" _onblur_="checkDone()"></input>
+</body>
+</html>

Modified: trunk/Source/WebKit/ChangeLog (231966 => 231967)


--- trunk/Source/WebKit/ChangeLog	2018-05-18 18:17:28 UTC (rev 231966)
+++ trunk/Source/WebKit/ChangeLog	2018-05-18 18:23:45 UTC (rev 231967)
@@ -1,3 +1,20 @@
+2018-05-18  Wenson Hsieh  <[email protected]>
+
+        [Extra zoom mode] Clearing text fields should dispatch input events of type "deleteContent"
+        https://bugs.webkit.org/show_bug.cgi?id=185769
+        <rdar://problem/40368261>
+
+        Reviewed by Tim Horton.
+
+        When setting the text of the currently focused element to the empty string, just delete the text instead of
+        pretending to insert an empty string. This mimics deleting content using the delete key on macOS, and fires an
+        input event with inputType "deleteContent" instead of "insertText".
+
+        Test: fast/forms/extrazoom/delete-content-in-text-field.html
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setTextAsync):
+
 2018-05-18  Keith Rollin  <[email protected]>
 
         Renamed "trackNetworkActivity" to "tracksResourceLoadMilestones"

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (231966 => 231967)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2018-05-18 18:17:28 UTC (rev 231966)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2018-05-18 18:23:45 UTC (rev 231967)
@@ -4619,7 +4619,10 @@
     if (frame->selection().selection().isContentEditable()) {
         UserTypingGestureIndicator indicator(frame.get());
         frame->selection().selectAll();
-        frame->editor().insertText(text, nullptr, TextEventInputKeyboard);
+        if (text.isEmpty())
+            frame->editor().deleteSelectionWithSmartDelete(false);
+        else
+            frame->editor().insertText(text, nullptr, TextEventInputKeyboard);
         return;
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to