Title: [234436] trunk
Revision
234436
Author
wenson_hs...@apple.com
Date
2018-07-31 13:19:08 -0700 (Tue, 31 Jul 2018)

Log Message

[iOS] Spelling suggestions cannot be selected in focused form controls when zoomed in
https://bugs.webkit.org/show_bug.cgi?id=188107
<rdar://problem/42354250>

Reviewed by Tim Horton.

Source/WebCore:

After r232040, the synthetic click gesture recognizer was enabled when tapping inside of the focused element,
which allows the page to handle click events inside editable content. However, this means that codepaths in
EventHandler that are responsible for changing selection due to default click event behaviors on macOS are now
active on iOS; this conflicts with selection changes due to text interaction gestures, which are the existing
mechanism for modifying the selection on iOS.

To address this, we defer selection changes when clicking to text interaction gestures on iOS by tweaking the
default behavior of a click on iOS to /not/ change selection when moving within the same editable root. This is
similar to r233311, but in a different codepath that specifically handles selection changes when clicking on
content that is already selected.

Test: fast/forms/ios/click-should-not-suppress-misspelling.html

* page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseReleaseEvent):

LayoutTests:

Adds a new test to verify that tapping in a misspelled word to bring up the spelling correction callout and
selection view does not immediately cause the selection to dismiss.

* fast/forms/ios/click-should-not-suppress-misspelling-expected.txt: Added.
* fast/forms/ios/click-should-not-suppress-misspelling.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (234435 => 234436)


--- trunk/LayoutTests/ChangeLog	2018-07-31 19:30:46 UTC (rev 234435)
+++ trunk/LayoutTests/ChangeLog	2018-07-31 20:19:08 UTC (rev 234436)
@@ -1,3 +1,17 @@
+2018-07-31  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS] Spelling suggestions cannot be selected in focused form controls when zoomed in
+        https://bugs.webkit.org/show_bug.cgi?id=188107
+        <rdar://problem/42354250>
+
+        Reviewed by Tim Horton.
+
+        Adds a new test to verify that tapping in a misspelled word to bring up the spelling correction callout and
+        selection view does not immediately cause the selection to dismiss.
+
+        * fast/forms/ios/click-should-not-suppress-misspelling-expected.txt: Added.
+        * fast/forms/ios/click-should-not-suppress-misspelling.html: Added.
+
 2018-07-31  Alex Christensen  <achristen...@webkit.org>
 
         Remove Yosemite test results.

Added: trunk/LayoutTests/fast/forms/ios/click-should-not-suppress-misspelling-expected.txt (0 => 234436)


--- trunk/LayoutTests/fast/forms/ios/click-should-not-suppress-misspelling-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/click-should-not-suppress-misspelling-expected.txt	2018-07-31 20:19:08 UTC (rev 234436)
@@ -0,0 +1,6 @@
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS input.selectionStart is 0
+PASS input.selectionEnd is 7
+

Added: trunk/LayoutTests/fast/forms/ios/click-should-not-suppress-misspelling.html (0 => 234436)


--- trunk/LayoutTests/fast/forms/ios/click-should-not-suppress-misspelling.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/click-should-not-suppress-misspelling.html	2018-07-31 20:19:08 UTC (rev 234436)
@@ -0,0 +1,49 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+<script src=""
+<script src=""
+<style>
+html, body {
+    margin: 0;
+    width: 100%;
+    height: 100%;
+}
+
+input {
+    font-size: 320px;
+    display: block;
+}
+</style>
+</head>
+<body>
+<input id="input" value="covfefe">
+</body>
+<script>
+const input = document.getElementById("input");
+
+addEventListener("load", async () => {
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    } else {
+        description(`To manually test, tap the input field to bring up the keyboard, and then tap on a part of the word in
+            the input field that is far away from the editing caret. As a result, the contents of the input should be
+            selected and marked as a misspelled word.`);
+        return;
+    }
+
+    await UIHelper.activateAndWaitForInputSessionAt(100, 150);
+
+    input.addEventListener("click", () => {
+        setTimeout(() => {
+            shouldBe("input.selectionStart", "0");
+            shouldBe("input.selectionEnd", "7");
+            testRunner.notifyDone();
+        });
+    });
+
+    await UIHelper.tapAt(800, 150);
+});
+</script>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (234435 => 234436)


--- trunk/Source/WebCore/ChangeLog	2018-07-31 19:30:46 UTC (rev 234435)
+++ trunk/Source/WebCore/ChangeLog	2018-07-31 20:19:08 UTC (rev 234436)
@@ -1,3 +1,27 @@
+2018-07-31  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS] Spelling suggestions cannot be selected in focused form controls when zoomed in
+        https://bugs.webkit.org/show_bug.cgi?id=188107
+        <rdar://problem/42354250>
+
+        Reviewed by Tim Horton.
+
+        After r232040, the synthetic click gesture recognizer was enabled when tapping inside of the focused element,
+        which allows the page to handle click events inside editable content. However, this means that codepaths in
+        EventHandler that are responsible for changing selection due to default click event behaviors on macOS are now
+        active on iOS; this conflicts with selection changes due to text interaction gestures, which are the existing
+        mechanism for modifying the selection on iOS.
+
+        To address this, we defer selection changes when clicking to text interaction gestures on iOS by tweaking the
+        default behavior of a click on iOS to /not/ change selection when moving within the same editable root. This is
+        similar to r233311, but in a different codepath that specifically handles selection changes when clicking on
+        content that is already selected.
+
+        Test: fast/forms/ios/click-should-not-suppress-misspelling.html
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleMouseReleaseEvent):
+
 2018-07-31  Yusuke Suzuki  <utatane....@gmail.com>
 
         Clean up TransformationMatrix implementation

Modified: trunk/Source/WebCore/page/EventHandler.cpp (234435 => 234436)


--- trunk/Source/WebCore/page/EventHandler.cpp	2018-07-31 19:30:46 UTC (rev 234435)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2018-07-31 20:19:08 UTC (rev 234436)
@@ -1050,12 +1050,21 @@
         VisibleSelection newSelection;
         Node* node = event.targetNode();
         bool caretBrowsing = m_frame.settings().caretBrowsingEnabled();
+        bool allowSelectionChanges = true;
         if (node && node->renderer() && (caretBrowsing || node->hasEditableStyle())) {
             VisiblePosition pos = node->renderer()->positionForPoint(event.localPoint(), nullptr);
             newSelection = VisibleSelection(pos);
+#if PLATFORM(IOS)
+            // On iOS, selection changes are triggered using platform-specific text interaction gestures rather than
+            // default behavior on click or mouseup. As such, the only time we should allow click events to change the
+            // selection on iOS is when we focus a different editable element, in which case the text interaction
+            // gestures will fail.
+            allowSelectionChanges = m_frame.selection().selection().rootEditableElement() != newSelection.rootEditableElement();
+#endif
         }
 
-        setSelectionIfNeeded(m_frame.selection(), newSelection);
+        if (allowSelectionChanges)
+            setSelectionIfNeeded(m_frame.selection(), newSelection);
 
         handled = true;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to