Changeset 247027 in webkit


Ignore:
Timestamp:
Jul 1, 2019 3:10:44 PM (5 years ago)
Author:
Wenson Hsieh
Message:

[iOS] REGRESSION (r246757): Unable to select non-editable text in subframes
https://bugs.webkit.org/show_bug.cgi?id=199366
<rdar://problem/52460509>

Reviewed by Tim Horton.

r246757 removed logic in selectionPositionInformation responsible for setting the focused frame when handling a
position information request. As the FIXME formerly in InteractionInformationRequest.h alluded to, text
selection gestures on iOS were dependent on this behavior when selecting text in subframes, since text selection
helpers in WebPageIOS.mm assume that the focused frame already contains the selection being set.

Rather than calling setFocusedFrame when requesting position information, we can fix this by making
WebPage::selectWithGesture and WebPage::selectTextWithGranularityAtPoint both set the focused frame if needed
before extending or moving text selections.

Covered by layout tests that began to fail after r246757:

  • editing/selection/ios/selection-handles-in-iframe.html
  • editing/selection/ios/selection-handle-clamping-in-iframe.html
  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::selectWithGesture):

Only call the new helper method, setFocusedFrameBeforeSelectingTextAtLocation, at the start of the gesture.

(WebKit::WebPage::setFocusedFrameBeforeSelectingTextAtLocation):
(WebKit::WebPage::selectTextWithGranularityAtPoint):

Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r247026 r247027  
     12019-07-01  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS] REGRESSION (r246757): Unable to select non-editable text in subframes
     4        https://bugs.webkit.org/show_bug.cgi?id=199366
     5        <rdar://problem/52460509>
     6
     7        Reviewed by Tim Horton.
     8
     9        r246757 removed logic in selectionPositionInformation responsible for setting the focused frame when handling a
     10        position information request. As the FIXME formerly in InteractionInformationRequest.h alluded to, text
     11        selection gestures on iOS were dependent on this behavior when selecting text in subframes, since text selection
     12        helpers in WebPageIOS.mm assume that the focused frame already contains the selection being set.
     13
     14        Rather than calling setFocusedFrame when requesting position information, we can fix this by making
     15        WebPage::selectWithGesture and WebPage::selectTextWithGranularityAtPoint both set the focused frame if needed
     16        before extending or moving text selections.
     17
     18        Covered by layout tests that began to fail after r246757:
     19        - editing/selection/ios/selection-handles-in-iframe.html
     20        - editing/selection/ios/selection-handle-clamping-in-iframe.html
     21
     22        * WebProcess/WebPage/WebPage.h:
     23        * WebProcess/WebPage/ios/WebPageIOS.mm:
     24        (WebKit::WebPage::selectWithGesture):
     25
     26        Only call the new helper method, setFocusedFrameBeforeSelectingTextAtLocation, at the start of the gesture.
     27
     28        (WebKit::WebPage::setFocusedFrameBeforeSelectingTextAtLocation):
     29        (WebKit::WebPage::selectTextWithGranularityAtPoint):
     30
    1312019-07-01  Alex Christensen  <achristensen@webkit.org>
    232
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r246938 r247027  
    12461246    WebCore::VisiblePosition visiblePositionInFocusedNodeForPoint(const WebCore::Frame&, const WebCore::IntPoint&, bool isInteractingWithFocusedElement);
    12471247    RefPtr<WebCore::Range> rangeForGranularityAtPoint(WebCore::Frame&, const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithFocusedElement);
     1248    void setFocusedFrameBeforeSelectingTextAtLocation(const WebCore::IntPoint&);
    12481249    void dispatchSyntheticMouseEventsForSelectionGesture(SelectionTouch, const WebCore::IntPoint&);
    12491250
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r247015 r247027  
    13091309void WebPage::selectWithGesture(const IntPoint& point, uint32_t granularity, uint32_t gestureType, uint32_t gestureState, bool isInteractingWithFocusedElement, CallbackID callbackID)
    13101310{
     1311    if (static_cast<GestureRecognizerState>(gestureState) == GestureRecognizerState::Began)
     1312        setFocusedFrameBeforeSelectingTextAtLocation(point);
     1313
    13111314    auto& frame = m_page->focusController().focusedOrMainFrame();
    13121315    VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithFocusedElement);
     
    20282031}
    20292032
     2033void WebPage::setFocusedFrameBeforeSelectingTextAtLocation(const IntPoint& point)
     2034{
     2035    auto result = m_page->mainFrame().eventHandler().hitTestResultAtPoint(point, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowUserAgentShadowContent | HitTestRequest::AllowChildFrameContent);
     2036    auto* hitNode = result.innerNode();
     2037    if (hitNode && hitNode->renderer())
     2038        m_page->focusController().setFocusedFrame(result.innerNodeFrame());
     2039}
     2040
    20302041void WebPage::selectTextWithGranularityAtPoint(const WebCore::IntPoint& point, uint32_t granularity, bool isInteractingWithFocusedElement, CallbackID callbackID)
    20312042{
     2043    setFocusedFrameBeforeSelectingTextAtLocation(point);
     2044
    20322045    auto& frame = m_page->focusController().focusedOrMainFrame();
    20332046    RefPtr<Range> range = rangeForGranularityAtPoint(frame, point, granularity, isInteractingWithFocusedElement);
Note: See TracChangeset for help on using the changeset viewer.