Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f53873bd7d834857bf3994606867d863fcd6b575
      
https://github.com/WebKit/WebKit/commit/f53873bd7d834857bf3994606867d863fcd6b575
  Author: Wenson Hsieh <wenson_hs...@apple.com>
  Date:   2024-10-02 (Wed, 02 Oct 2024)

  Changed paths:
    M 
LayoutTests/editing/selection/ios/selection-clip-rect-in-overflow-scroller.html
    A 
LayoutTests/editing/selection/ios/selection-hit-testing-in-overflow-scroller-expected.txt
    A 
LayoutTests/editing/selection/ios/selection-hit-testing-in-overflow-scroller.html
    M Source/WebKit/UIProcess/ios/UIKitUtilities.h
    M Source/WebKit/UIProcess/ios/UIKitUtilities.mm
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

  Log Message:
  -----------
  Avoid hit-testing to clipped regions of the selection highlight when 
SelectionHonorsOverflowScrolling is enabled
https://bugs.webkit.org/show_bug.cgi?id=280778
rdar://137126898

Reviewed by Abrar Rahman Protyasha.

Currently, when `SelectionHonorsOverflowScrolling` is enabled, a tap inside of 
the selection bounds
in root view coordinates ignores overflow clipping. This means that if the 
selection is clipped and
inside of a subscrollable region, it's possible to tap outside of the 
subscrollable region and
toggle the edit menu visibility instead of handling the tap as a synthetic 
click.

To fix this, we adjust `-_pointIsInsideSelectionRect:outBoundingRect:` to take 
text selection
highlights inside subscrollable regions into account, and return `NO` in this 
case. See below for
more details.

* 
LayoutTests/editing/selection/ios/selection-clip-rect-in-overflow-scroller.html:

Adjust this existing test to enable `SelectionHonorsOverflowScrolling`, now 
that we no longer set a
selection clip rect when `m_selectionHonorsOverflowScrolling` is `false`.

* 
LayoutTests/editing/selection/ios/selection-hit-testing-in-overflow-scroller-expected.txt:
 Added.
* 
LayoutTests/editing/selection/ios/selection-hit-testing-in-overflow-scroller.html:
 Added.

Add a new layout test to exercise this fix by setting a clipped selection 
inside of an overflow
scroller, and verifying that it's possible to tap (i.e. fire the `click` event 
over) a button that
would otherwise be covered by the selection view if it were parented underneath 
the root view.

* Source/WebKit/UIProcess/ios/UIKitUtilities.h:
* Source/WebKit/UIProcess/ios/UIKitUtilities.mm:
(-[UIView _wk_isAncestorOf:]):
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _pointIsInsideSelectionRect:outBoundingRect:]):

Implement the main fix here — in the case where `pointIsInSelectionRect` is 
`YES` (i.e. the
selection rects in root view coordinates contains the point), additionally use 
`-hitTest:withEvent:`
to check whether the tap actually hit-tests to content that is in the same 
scroll view as the
selection. In the case described above, for example, this would hit-test to the 
content view's
`_interactionViewsContainerView` instead of a child scroll view containing the 
selection.

(-[WKContentView _selectionContainerScrollView]):
(-[WKContentView _selectionContainerViewInternal]):
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::computeSelectionClipRectAndEnclosingScroller const):

When `SelectionHonorsOverflowScrolling` is disabled, don't attempt to set a 
selection clip rect.
While this results in a visually clipped selection rect, hit-testing is still 
broken because it
doesn't take selection clipping into account.

* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h:
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(-[UIScrollView _wtr_visibleBoundsInCoordinateSpace:]):
(WTR::UIScriptControllerIOS::selectionViewBoundsClippedToContentView const):
(WTR::UIScriptControllerIOS::selectionStartGrabberViewRect const):
(WTR::UIScriptControllerIOS::selectionEndGrabberViewRect const):
(WTR::UIScriptControllerIOS::selectionCaretViewRect const):
(WTR::UIScriptControllerIOS::selectionRangeViewRects const):
(WTR::UIScriptControllerIOS::clipSelectionViewRectToContentView const): Deleted.

Teach `UIScriptController`'s selection geometry getters to handle the case 
where the selection is in
a subscrollable region, and `SelectionHonorsOverflowScrolling` is enabled. 
Since we (may) no longer
use `selectionClipRect` in this case, we need to instead return the part of the 
selection rect that
is visible to the user, accounting for child scrollers.

Canonical link: https://commits.webkit.org/284587@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to