Title: [247027] trunk/Source/WebKit
Revision
247027
Author
wenson_hs...@apple.com
Date
2019-07-01 15:10:44 -0700 (Mon, 01 Jul 2019)

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

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (247026 => 247027)


--- trunk/Source/WebKit/ChangeLog	2019-07-01 22:07:09 UTC (rev 247026)
+++ trunk/Source/WebKit/ChangeLog	2019-07-01 22:10:44 UTC (rev 247027)
@@ -1,3 +1,33 @@
+2019-07-01  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [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):
+
 2019-07-01  Alex Christensen  <achristen...@webkit.org>
 
         Add new decidePolicyForNavigationAction SPI with preferences and userInfo

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (247026 => 247027)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-07-01 22:07:09 UTC (rev 247026)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-07-01 22:10:44 UTC (rev 247027)
@@ -1245,6 +1245,7 @@
     void resetIdempotentTextAutosizingIfNeeded(double previousInitialScale);
     WebCore::VisiblePosition visiblePositionInFocusedNodeForPoint(const WebCore::Frame&, const WebCore::IntPoint&, bool isInteractingWithFocusedElement);
     RefPtr<WebCore::Range> rangeForGranularityAtPoint(WebCore::Frame&, const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithFocusedElement);
+    void setFocusedFrameBeforeSelectingTextAtLocation(const WebCore::IntPoint&);
     void dispatchSyntheticMouseEventsForSelectionGesture(SelectionTouch, const WebCore::IntPoint&);
 
     void sendPositionInformation(InteractionInformationAtPosition&&);

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (247026 => 247027)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-07-01 22:07:09 UTC (rev 247026)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-07-01 22:10:44 UTC (rev 247027)
@@ -1308,6 +1308,9 @@
 
 void WebPage::selectWithGesture(const IntPoint& point, uint32_t granularity, uint32_t gestureType, uint32_t gestureState, bool isInteractingWithFocusedElement, CallbackID callbackID)
 {
+    if (static_cast<GestureRecognizerState>(gestureState) == GestureRecognizerState::Began)
+        setFocusedFrameBeforeSelectingTextAtLocation(point);
+
     auto& frame = m_page->focusController().focusedOrMainFrame();
     VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithFocusedElement);
 
@@ -2027,8 +2030,18 @@
     return blockRect.height() > frame.view()->unobscuredContentRect().height() * factor;
 }
 
+void WebPage::setFocusedFrameBeforeSelectingTextAtLocation(const IntPoint& point)
+{
+    auto result = m_page->mainFrame().eventHandler().hitTestResultAtPoint(point, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowUserAgentShadowContent | HitTestRequest::AllowChildFrameContent);
+    auto* hitNode = result.innerNode();
+    if (hitNode && hitNode->renderer())
+        m_page->focusController().setFocusedFrame(result.innerNodeFrame());
+}
+
 void WebPage::selectTextWithGranularityAtPoint(const WebCore::IntPoint& point, uint32_t granularity, bool isInteractingWithFocusedElement, CallbackID callbackID)
 {
+    setFocusedFrameBeforeSelectingTextAtLocation(point);
+
     auto& frame = m_page->focusController().focusedOrMainFrame();
     RefPtr<Range> range = rangeForGranularityAtPoint(frame, point, granularity, isInteractingWithFocusedElement);
     if (!isInteractingWithFocusedElement) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to