WebKit Bugzilla
Attachment 369397 Details for
Bug 197686
: iOS: Selection is dismissed even if click is preventDefault()'d
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197686-20190508111920.patch (text/plain), 12.32 KB, created by
Tim Horton
on 2019-05-08 11:19:21 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tim Horton
Created:
2019-05-08 11:19:21 PDT
Size:
12.32 KB
patch
obsolete
>Subversion Revision: 245023 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 7cb4a7c6935ecba83d3f695e052bef919358fedb..705ccc60aec04c78d0edaed9a3aaeed6d1800e4b 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,28 @@ >+2019-05-07 Tim Horton <timothy_horton@apple.com> >+ >+ iOS: Selection is dismissed even if click is preventDefault()'d >+ https://bugs.webkit.org/show_bug.cgi?id=197686 >+ <rdar://problem/49398824> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ We currently unconditionally dismiss the selection on any tap; however >+ if a site preventDefault()s on click, we shouldn't perform the default >+ action of dismissing the selection. >+ >+ Instead of clearing the selection in the UI process, clear it in the >+ Web content process if we don't dispatch a synthetic click; the normal >+ WebCore machinery will handle it in the case that we do. >+ >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView _singleTapRecognized:]): >+ * WebProcess/WebPage/WebPage.h: >+ * WebProcess/WebPage/ios/WebPageIOS.mm: >+ (WebKit::WebPage::commitPotentialTapFailed): >+ (WebKit::WebPage::selectWithGesture): >+ (WebKit::WebPage::clearSelection): >+ (WebKit::WebPage::selectTextWithGranularityAtPoint): >+ > 2019-05-07 John Wilander <wilander@apple.com> > > Change IsITPFirstPartyWebsiteDataRemovalEnabled from DEFAULT_EXPERIMENTAL_FEATURES_ENABLED to true. >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index abf883cedc476ec1f4bcd3d23252996f0e9926b6..05644d11e0827f157409eae02fcd1094376cbbbf 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -2348,12 +2348,6 @@ - (void)_singleTapRecognized:(UITapGestureRecognizer *)gestureRecognizer > > ASSERT(_potentialTapInProgress); > >- // We don't want to clear the selection if it is in editable content. >- // The selection could have been set by autofocusing on page load and not >- // reflected in the UI process since the user was not interacting with the page. >- if (!_page->editorState().isContentEditable) >- _page->clearSelection(); >- > _lastInteractionLocation = gestureRecognizer.location; > > [self _endPotentialTapAndEnableDoubleTapGesturesIfNecessary]; >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index d9d804cbd637991052c8c6d2c1ce229e67d36a98..f11ef0ca7644d00c76d89d101b391229249d8a68 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -1812,7 +1812,6 @@ private: > WebCore::FloatSize m_screenSize; > WebCore::FloatSize m_availableScreenSize; > WebCore::FloatSize m_overrideScreenSize; >- RefPtr<WebCore::Range> m_currentBlockSelection; > WebCore::IntRect m_blockRectForTextSelection; > > RefPtr<WebCore::Range> m_initialSelection; >diff --git a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >index c2db1f5b30b3c70e1993fe65d63e13581c2f8568..4f847f80150114ffd8b8fb4527e5fedb577198b6 100644 >--- a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >+++ b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >@@ -947,6 +947,9 @@ void WebPage::commitPotentialTap(OptionSet<WebEvent::Modifier> modifiers, uint64 > > void WebPage::commitPotentialTapFailed() > { >+ if (!m_page->focusController().focusedOrMainFrame().selection().selection().isContentEditable()) >+ clearSelection(); >+ > send(Messages::WebPageProxy::CommitPotentialTapFailed()); > send(Messages::WebPageProxy::DidNotHandleTapAsClick(roundedIntPoint(m_potentialTapLocation))); > } >@@ -1367,7 +1370,6 @@ void WebPage::selectWithGesture(const IntPoint& point, uint32_t granularity, uin > if (wkGestureState == GestureRecognizerState::Began) { > m_blockSelectionDesiredSize.setWidth(blockSelectionStartWidth); > m_blockSelectionDesiredSize.setHeight(blockSelectionStartHeight); >- m_currentBlockSelection = nullptr; > } > range = rangeForWebSelectionAtPosition(point, position, flags); > break; >@@ -1479,9 +1481,9 @@ static RefPtr<Range> rangeAtWordBoundaryForPosition(Frame* frame, const VisibleP > return (base < extent) ? Range::create(*frame->document(), base, extent) : Range::create(*frame->document(), extent, base); > } > >-void WebPage::clearSelection(){ >+void WebPage::clearSelection() >+{ > m_startingGestureRange = nullptr; >- m_currentBlockSelection = nullptr; > m_page->focusController().focusedOrMainFrame().selection().clear(); > } > >@@ -1876,7 +1878,6 @@ void WebPage::selectTextWithGranularityAtPoint(const WebCore::IntPoint& point, u > if (!isInteractingWithFocusedElement) { > m_blockSelectionDesiredSize.setWidth(blockSelectionStartWidth); > m_blockSelectionDesiredSize.setHeight(blockSelectionStartHeight); >- m_currentBlockSelection = nullptr; > auto* renderer = range ? range->startContainer().renderer() : nullptr; > if (renderer && renderer->style().preserveNewline()) > m_blockRectForTextSelection = renderer->absoluteBoundingBoxRect(true); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 8652c07a574e27a97a14049981399882f1437001..3f382e7507c05c541ef78418b21e29bcb5764508 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,16 @@ >+2019-05-08 Tim Horton <timothy_horton@apple.com> >+ >+ iOS: Selection is dismissed even if click is preventDefault()'d >+ https://bugs.webkit.org/show_bug.cgi?id=197686 >+ <rdar://problem/49398824> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * editing/selection/ios/clear-selection-after-tapping-on-element-with-no-click-handler-expected.txt: Added. >+ * editing/selection/ios/clear-selection-after-tapping-on-element-with-no-click-handler.html: Added. >+ * editing/selection/ios/persist-selection-after-tapping-on-element-with-click-handler-expected.txt: Added. >+ * editing/selection/ios/persist-selection-after-tapping-on-element-with-click-handler.html: Added. >+ > 2019-05-07 Antti Koivisto <antti@apple.com> > > <body> with overflow:hidden shouldn't be keyboard scrollable on iOS >diff --git a/LayoutTests/editing/selection/ios/clear-selection-after-tapping-on-element-with-no-click-handler-expected.txt b/LayoutTests/editing/selection/ios/clear-selection-after-tapping-on-element-with-no-click-handler-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..137f22b3aa8e565727b660b2811b1156d33b63f3 >--- /dev/null >+++ b/LayoutTests/editing/selection/ios/clear-selection-after-tapping-on-element-with-no-click-handler-expected.txt >@@ -0,0 +1,3 @@ >+WebKit >+The selected text is: "" >+This test verifies that the WebCore selection is dismissed when tapping on an element that does not listen to click events. >diff --git a/LayoutTests/editing/selection/ios/clear-selection-after-tapping-on-element-with-no-click-handler.html b/LayoutTests/editing/selection/ios/clear-selection-after-tapping-on-element-with-no-click-handler.html >new file mode 100644 >index 0000000000000000000000000000000000000000..01ea88f13174b279d4cbd8f4a31e232e937362c8 >--- /dev/null >+++ b/LayoutTests/editing/selection/ios/clear-selection-after-tapping-on-element-with-no-click-handler.html >@@ -0,0 +1,64 @@ >+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] --> >+<html> >+<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> >+<head> >+ <script src="../../../resources/basic-gestures.js"></script> >+ <script src="../../../resources/ui-helper.js"></script> >+ <style> >+ body { >+ margin: 0; >+ } >+ >+ #target { >+ font-size: 100px; >+ } >+ >+ #clickTarget { >+ width: 100px; >+ height: 100px; >+ } >+ </style> >+ <script> >+ if (window.testRunner) { >+ testRunner.dumpAsText(); >+ testRunner.waitUntilDone(); >+ } >+ >+ async function run() >+ { >+ if (!window.testRunner) >+ return; >+ >+ function didChangeSelection() >+ { >+ result.textContent = window.getSelection().toString() >+ } >+ >+ document.addEventListener("selectionchange", didChangeSelection); >+ >+ var clickTarget = document.getElementById("clickTarget"); >+ >+ var target = document.getElementById("target"); >+ window.getSelection().setBaseAndExtent(target, 0, target, 6); >+ >+ await UIHelper.activateElement(clickTarget); >+ >+ setTimeout(async function () { >+ // The test is done, but we need to tap again to ensure we don't >+ // hang the next test with a double tap. >+ document.removeEventListener("selectionchange", didChangeSelection); >+ await UIHelper.tapAt(10, 500); >+ >+ testRunner.notifyDone(); >+ }, 0); >+ } >+ </script> >+</head> >+<body onload="run()"> >+ <div id="target">WebKit</div> >+ <div id="clickTarget"></div> >+ <div id="nonclickTarget"></div> >+ <pre>The selected text is: "<span id="result"></span>"</pre> >+ <p>This test verifies that the WebCore selection is dismissed when tapping on an element that does not listen to click events.</p> >+</body> >+</html> >diff --git a/LayoutTests/editing/selection/ios/persist-selection-after-tapping-on-element-with-click-handler-expected.txt b/LayoutTests/editing/selection/ios/persist-selection-after-tapping-on-element-with-click-handler-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..b26f5496a6e534af2ae82eac1687d9ca937c6d0f >--- /dev/null >+++ b/LayoutTests/editing/selection/ios/persist-selection-after-tapping-on-element-with-click-handler-expected.txt >@@ -0,0 +1,3 @@ >+WebKit >+The selected text is: "WebKit" >+This test verifies that the WebCore selection is not dismissed when tapping on an element that preventDefault()s the click event. >diff --git a/LayoutTests/editing/selection/ios/persist-selection-after-tapping-on-element-with-click-handler.html b/LayoutTests/editing/selection/ios/persist-selection-after-tapping-on-element-with-click-handler.html >new file mode 100644 >index 0000000000000000000000000000000000000000..9117a2ef579b52d56acb53846dd6f4b2461420fb >--- /dev/null >+++ b/LayoutTests/editing/selection/ios/persist-selection-after-tapping-on-element-with-click-handler.html >@@ -0,0 +1,68 @@ >+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] --> >+<html> >+<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> >+<head> >+ <script src="../../../resources/basic-gestures.js"></script> >+ <script src="../../../resources/ui-helper.js"></script> >+ <style> >+ body { >+ margin: 0; >+ } >+ >+ #target { >+ font-size: 100px; >+ } >+ >+ #clickTarget { >+ width: 100px; >+ height: 100px; >+ background-color: green; >+ } >+ </style> >+ <script> >+ if (window.testRunner) { >+ testRunner.dumpAsText(); >+ testRunner.waitUntilDone(); >+ } >+ >+ async function run() >+ { >+ if (!window.testRunner) >+ return; >+ >+ function didChangeSelection() >+ { >+ result.textContent = window.getSelection().toString() >+ } >+ >+ document.addEventListener("selectionchange", didChangeSelection); >+ >+ var clickTarget = document.getElementById("clickTarget"); >+ >+ clickTarget.addEventListener("click", event => { >+ event.preventDefault(); >+ >+ setTimeout(async function () { >+ // The test is done, but we need to tap again to ensure we don't >+ // hang the next test with a double tap. >+ document.removeEventListener("selectionchange", didChangeSelection); >+ await UIHelper.tapAt(10, 500); >+ >+ testRunner.notifyDone(); >+ }, 0); >+ }); >+ >+ var target = document.getElementById("target"); >+ window.getSelection().setBaseAndExtent(target, 0, target, 6); >+ >+ await UIHelper.activateElement(clickTarget); >+ } >+ </script> >+</head> >+<body onload="run()"> >+ <div id="target">WebKit</div> >+ <div id="clickTarget"></div> >+ <pre>The selected text is: "<span id="result"></span>"</pre> >+ <p>This test verifies that the WebCore selection is not dismissed when tapping on an element that preventDefault()s the click event.</p> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197686
:
369363
|
369366
|
369371
|
369374
|
369380
|
369397
|
369401
|
369412
|
369415