From: wenson_hsieh@apple.com Date: Tue, 31 Jul 2018 20:19:08 +0000 (+0000) Subject: [iOS] Spelling suggestions cannot be selected in focused form controls when zoomed in X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=3a5eacdf83deb736aab701341837d36558aee5ec [iOS] Spelling suggestions cannot be selected in focused form controls when zoomed in https://bugs.webkit.org/show_bug.cgi?id=188107 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. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234436 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index d0d2217..ca20d15 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,17 @@ +2018-07-31 Wenson Hsieh + + [iOS] Spelling suggestions cannot be selected in focused form controls when zoomed in + https://bugs.webkit.org/show_bug.cgi?id=188107 + + + 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 Remove Yosemite test results. diff --git a/LayoutTests/fast/forms/ios/click-should-not-suppress-misspelling-expected.txt b/LayoutTests/fast/forms/ios/click-should-not-suppress-misspelling-expected.txt new file mode 100644 index 0000000..691e2b4 --- /dev/null +++ b/LayoutTests/fast/forms/ios/click-should-not-suppress-misspelling-expected.txt @@ -0,0 +1,6 @@ +PASS successfullyParsed is true + +TEST COMPLETE +PASS input.selectionStart is 0 +PASS input.selectionEnd is 7 + diff --git a/LayoutTests/fast/forms/ios/click-should-not-suppress-misspelling.html b/LayoutTests/fast/forms/ios/click-should-not-suppress-misspelling.html new file mode 100644 index 0000000..0702485 --- /dev/null +++ b/LayoutTests/fast/forms/ios/click-should-not-suppress-misspelling.html @@ -0,0 +1,49 @@ + + + + + + + + + + + + diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index a8fb191..9ad8a32 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,27 @@ +2018-07-31 Wenson Hsieh + + [iOS] Spelling suggestions cannot be selected in focused form controls when zoomed in + https://bugs.webkit.org/show_bug.cgi?id=188107 + + + 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 Clean up TransformationMatrix implementation diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp index 26c89b0..c8b1447 100644 --- a/Source/WebCore/page/EventHandler.cpp +++ b/Source/WebCore/page/EventHandler.cpp @@ -1050,12 +1050,21 @@ bool EventHandler::handleMouseReleaseEvent(const MouseEventWithHitTestResults& e 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; }