[webkit-changes] [WebKit/WebKit] b7fc2d: [iOS] Text selection highlight does not honor laye...

Wenson Hsieh noreply at github.com
Thu Oct 17 10:35:42 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b7fc2d972516a068452fd5676e26e8a354841670
      https://github.com/WebKit/WebKit/commit/b7fc2d972516a068452fd5676e26e8a354841670
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2024-10-17 (Thu, 17 Oct 2024)

  Changed paths:
    A LayoutTests/editing/selection/ios/selection-highlight-in-fixed-position-container-expected.txt
    A LayoutTests/editing/selection/ios/selection-highlight-in-fixed-position-container.html
    M LayoutTests/resources/ui-helper.js
    M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
    M Source/WebCore/dom/Position.h
    M Source/WebCore/rendering/RenderLayer.h
    M Source/WebCore/rendering/RenderLayerScrollableArea.h
    M Source/WebCore/rendering/RenderObject.h
    M Source/WebKit/Shared/EditorState.h
    M Source/WebKit/Shared/EditorState.serialization.in
    M Source/WebKit/UIProcess/ios/UIKitUtilities.h
    M Source/WebKit/UIProcess/ios/UIKitUtilities.mm
    M Source/WebKit/UIProcess/ios/WKBaseScrollView.h
    M Source/WebKit/UIProcess/ios/WKBaseScrollView.mm
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.mm
    M Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

  Log Message:
  -----------
  [iOS] Text selection highlight does not honor layer occlusion/clipping
https://bugs.webkit.org/show_bug.cgi?id=281601
rdar://107058373

Reviewed by Abrar Rahman Protyasha.

Currently, the "Selection Honors Overflow Scrolling" flag allows us to slot native selection views
underneath composited subscrollable areas (i.e. `WKChildScrollView`s), by plumbing the enclosing
scrolling node ID over to the UI process via `EditorState` with each layer tree transaction.

While this enables selection UI in subscrollable containers to scroll smoothly along with the
selected content and also fixes occlusion in the case where occluding content is in a compositing
view that covers the selection in a subscrollable container, this approach *doesn't* address the
more general problem of native selection UI appearing over content that should otherwise occlude the
selection, if:

1.  The selection is in the main frame, or
2.  The content that would otherwise occlude the selection is in the same scrollable container as
    the selection.

To fix *most* (not all) of these remaining scenarios, we make further changes to the "Selection
Honors Overflow Scrolling" behavior, such that we no longer propagate a scrolling node ID via
`EditorState` to the UI process; instead, we now propagate the ID of the graphics layer that backs
the selection's `RenderLayer` (or the scrolled contents layer, if appropriate), and then map this ID
to a platform compositing view which we use as the parent for the selection views.

See below for more details.

* LayoutTests/editing/selection/ios/selection-highlight-in-fixed-position-container-expected.txt: Added.
* LayoutTests/editing/selection/ios/selection-highlight-in-fixed-position-container.html: Added.

Add a layout test to verify that a selection inside a fixed-position container stays on screen when
scrolling.

* LayoutTests/resources/ui-helper.js:
(window.UIHelper.async longPressElement):

Make this work when long pressing content inside fixed-position containers, by using
`getBoundingClientRect()`.

* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:

Expose this on `WebCore::Settings` too, so that we don't need to store a flag on `WebPage` when
checking this state.

* Source/WebCore/dom/Position.h:
* Source/WebCore/rendering/RenderLayer.h:
* Source/WebCore/rendering/RenderLayerScrollableArea.h:
* Source/WebCore/rendering/RenderObject.h:

Shuffle around some `WEBCORE_EXPORT`s, some of which are no longer needed.

* Source/WebKit/Shared/EditorState.h:
* Source/WebKit/Shared/EditorState.serialization.in:

Replace the `ScrollingNodeID` with a `PlatformLayerIdentifier`.

* Source/WebKit/UIProcess/ios/UIKitUtilities.h:
* Source/WebKit/UIProcess/ios/UIKitUtilities.mm:
(-[UIView _wk_parentScrollView]):
(-[UIView _wk_isAncestorOf:]): Deleted.

Replace this category helper method with a new one, which finds the ancestor scroller of a given
view.

* Source/WebKit/UIProcess/ios/WKBaseScrollView.h:
* Source/WebKit/UIProcess/ios/WKBaseScrollView.mm:
(-[WKBaseScrollView scrolledContentView]): Deleted.

Remove this now-unused helper method.

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView shouldHideSelectionWhenScrolling]):

Now that we (more) correctly paint native selection UI in fixed-position containers, we can stop
hiding the selection every time we scroll now, when the selection is inside fixed-position content.

(-[WKContentView _pointIsInsideSelectionRect:outBoundingRect:]):

Make a small adjustment here to ensure that hit-testing for the purposes of toggling the edit menu
still honors overflow scrolling clip.

(-[WKContentView _selectionContainerViewInternal]):

Make this grab the corresponding layer tree node for the platform layer ID that encloses the
selection endpoints, and use that as the selection container.

(-[WKContentView _selectionContainerScrollView]): Deleted.
* Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.mm:
(-[WKTextInteractionWrapper prepareToMoveSelectionContainer:]):

Additionally make sure that the selection views are hosted above the tile grid controller container
layer; this is necessary to ensure that selection views show up above selected content, but under
any composited content (fixed/sticky-position banners, z-ordered elements, etc.) that should occlude
it.

* Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::getPlatformEditorStateCommon const):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::computeEnclosingLayerID const):

Add a helper method to search up the layer tree for the closest ancestor backed by a graphics layer.

(WebKit::enclosingScroller): Deleted.
(WebKit::forEachEnclosingScroller): Deleted.
(WebKit::WebPage::computeSelectionClipRectAndEnclosingScroller const): Deleted.

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list