Changeset 245067 in webkit


Ignore:
Timestamp:
May 8, 2019 1:50:22 PM (5 years ago)
Author:
timothy_horton@apple.com
Message:

iOS: Selection is dismissed even if click is preventDefault()'d
https://bugs.webkit.org/show_bug.cgi?id=197686
<rdar://problem/49398824>

Reviewed by Wenson Hsieh.

Source/WebKit:

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):

LayoutTests:

  • 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.

New tests.

  • platform/ios/editing/deleting/smart-delete-paragraph-003-expected.txt:
  • platform/ios/editing/pasteboard/smart-paste-paragraph-003-expected.txt:

Rebaseline since we changed the timing of editing callbacks by changing where the selection happens.

Location:
trunk
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245062 r245067  
     12019-05-08  Tim Horton  <timothy_horton@apple.com>
     2
     3        iOS: Selection is dismissed even if click is preventDefault()'d
     4        https://bugs.webkit.org/show_bug.cgi?id=197686
     5        <rdar://problem/49398824>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        * editing/selection/ios/clear-selection-after-tapping-on-element-with-no-click-handler-expected.txt: Added.
     10        * editing/selection/ios/clear-selection-after-tapping-on-element-with-no-click-handler.html: Added.
     11        * editing/selection/ios/persist-selection-after-tapping-on-element-with-click-handler-expected.txt: Added.
     12        * editing/selection/ios/persist-selection-after-tapping-on-element-with-click-handler.html: Added.
     13        New tests.
     14
     15        * platform/ios/editing/deleting/smart-delete-paragraph-003-expected.txt:
     16        * platform/ios/editing/pasteboard/smart-paste-paragraph-003-expected.txt:
     17        Rebaseline since we changed the timing of editing callbacks by changing where the selection happens.
     18
    1192019-05-08  Wenson Hsieh  <wenson_hsieh@apple.com>
    220
  • trunk/LayoutTests/platform/ios/editing/deleting/smart-delete-paragraph-003-expected.txt

    r243296 r245067  
    11EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    3 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     2EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of BODY > HTML > #document to 3 of BODY > HTML > #document toDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    43EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    54EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment toDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    6 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment toDOMRange:range from 0 of #text > DIV > #document-fragment to 4 of #text > DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    7 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    85EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    96EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of #text > DIV > #document-fragment to 15 of #text > DIV > #document-fragment
  • trunk/LayoutTests/platform/ios/editing/pasteboard/smart-paste-paragraph-003-expected.txt

    r243124 r245067  
    11EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    3 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     2EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of BODY > HTML > #document to 3 of BODY > HTML > #document toDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    43EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    54EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment toDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    6 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > #document-fragment to 0 of DIV > #document-fragment toDOMRange:range from 0 of #text > DIV > #document-fragment to 4 of #text > DIV > #document-fragment affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    7 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    85EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    96EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
  • trunk/Source/WebKit/ChangeLog

    r245065 r245067  
     12019-05-08  Tim Horton  <timothy_horton@apple.com>
     2
     3        iOS: Selection is dismissed even if click is preventDefault()'d
     4        https://bugs.webkit.org/show_bug.cgi?id=197686
     5        <rdar://problem/49398824>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        We currently unconditionally dismiss the selection on any tap; however
     10        if a site preventDefault()s on click, we shouldn't perform the default
     11        action of dismissing the selection.
     12
     13        Instead of clearing the selection in the UI process, clear it in the
     14        Web content process if we don't dispatch a synthetic click; the normal
     15        WebCore machinery will handle it in the case that we do.
     16
     17        * UIProcess/ios/WKContentViewInteraction.mm:
     18        (-[WKContentView _singleTapRecognized:]):
     19        * WebProcess/WebPage/WebPage.h:
     20        * WebProcess/WebPage/ios/WebPageIOS.mm:
     21        (WebKit::WebPage::commitPotentialTapFailed):
     22        (WebKit::WebPage::selectWithGesture):
     23        (WebKit::WebPage::clearSelection):
     24        (WebKit::WebPage::selectTextWithGranularityAtPoint):
     25
    1262019-05-08  Alexander Mikhaylenko  <exalm7659@gmail.com>
    227
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r245062 r245067  
    23492349    ASSERT(_potentialTapInProgress);
    23502350
    2351     // We don't want to clear the selection if it is in editable content.
    2352     // The selection could have been set by autofocusing on page load and not
    2353     // reflected in the UI process since the user was not interacting with the page.
    2354     if (!_page->editorState().isContentEditable)
    2355         _page->clearSelection();
    2356 
    23572351    _lastInteractionLocation = gestureRecognizer.location;
    23582352
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r245062 r245067  
    18191819    WebCore::FloatSize m_availableScreenSize;
    18201820    WebCore::FloatSize m_overrideScreenSize;
    1821     RefPtr<WebCore::Range> m_currentBlockSelection;
    18221821    WebCore::IntRect m_blockRectForTextSelection;
    18231822
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r245062 r245067  
    948948void WebPage::commitPotentialTapFailed()
    949949{
     950    if (!m_page->focusController().focusedOrMainFrame().selection().selection().isContentEditable())
     951        clearSelection();
     952
    950953    send(Messages::WebPageProxy::CommitPotentialTapFailed());
    951954    send(Messages::WebPageProxy::DidNotHandleTapAsClick(roundedIntPoint(m_potentialTapLocation)));
     
    13681371            m_blockSelectionDesiredSize.setWidth(blockSelectionStartWidth);
    13691372            m_blockSelectionDesiredSize.setHeight(blockSelectionStartHeight);
    1370             m_currentBlockSelection = nullptr;
    13711373        }
    13721374        range = rangeForWebSelectionAtPosition(point, position, flags);
     
    15001502{
    15011503    m_startingGestureRange = nullptr;
    1502     m_currentBlockSelection = nullptr;
    15031504    m_page->focusController().focusedOrMainFrame().selection().clear();
    15041505}
     
    19591960        m_blockSelectionDesiredSize.setWidth(blockSelectionStartWidth);
    19601961        m_blockSelectionDesiredSize.setHeight(blockSelectionStartHeight);
    1961         m_currentBlockSelection = nullptr;
    19621962        auto* renderer = range ? range->startContainer().renderer() : nullptr;
    19631963        if (renderer && renderer->style().preserveNewline())
Note: See TracChangeset for help on using the changeset viewer.