Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 14147705667fe75a38cb4cbef3b094039e26a7a8
      
https://github.com/WebKit/WebKit/commit/14147705667fe75a38cb4cbef3b094039e26a7a8
  Author: Wenson Hsieh <[email protected]>
  Date:   2025-02-03 (Mon, 03 Feb 2025)

  Changed paths:
    A 
LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-7-expected.txt
    A 
LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-7.html
    M LayoutTests/resources/ui-helper.js
    M Source/WebCore/platform/ios/SelectionGeometry.h
    M Source/WebCore/rendering/RenderObject.cpp

  Log Message:
  -----------
  [iOS] [Visual Bidi Selection] Text sometimes becomes unselected after 
releasing selection handles
https://bugs.webkit.org/show_bug.cgi?id=286936
rdar://142407933

Reviewed by Megan Gardner.

Make a couple of minor adjustments to selection geometry coalescing logic on 
iOS, to mitigate the
case where an RTL selection rect that's adjacent to an LTR selection rect for a 
fully selected LTR
text run results in a coalesced selection rect that only contains the RTL part. 
To illustrate this
scenario, consider the following selection rects (`▦` indicates regions covered 
by the selection
highlight and `S` and `E` denote the start of the RTL run and the end of the 
LTR run, respectively:

▦▦▦▦▦▦▦▦▦▦|▦▦▦▦▦▦▦▦▦▦|
    ltr   E   rtl    S

...when we attempt to make the selection visually contiguous, this currently 
results in the entire
LTR portion appearing unselected (even though it's still logically selected), 
since we fill in the
gap from `S` to `E`:

——————————|▦▦▦▦▦▦▦▦▦▦|
    ltr   E   rtl    S

To fix this, we adjust logic used to coalesce overlapping selection rects, such 
that perfectly-
adjacent selections are coalesced (even if they don't technically intersect). 
This results in the
following coalesced rect:

|▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦▦|
E   ltr       rtl    S

Note that, with this change, we need to also adjust 
`collectSelectionGeometriesInternal`, so that
we avoid (incorrectly) expanding the width of LTR selection rects to become 
adjacent to the end of
neighboring RTL selection rects, which would otherwise result in adjacent LTR 
and RTL text bounds
being coalesced, even if there should be a visual gap in between them.

* 
LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-7-expected.txt:
 Added.
* LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-7.html: 
Added.

Add a layout test to exercise the scenario above.

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

Drive-by fix: the width and height are flipped in this (recently-added) helper 
method.

* Source/WebCore/platform/ios/SelectionGeometry.h:
(WebCore::SelectionGeometry::logicalLeftExtent const):
* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::usesVisuallyContiguousBidiTextSelection):
(WebCore::adjustTextDirectionForCoalescedGeometries):
(WebCore::RenderObject::collectSelectionGeometriesInternal):

If the visual bidi selection setting is enabled, avoid expanding selection rect 
widths eagerly here,
in favor of stitching them together in `collectSelectionGeometries`, if the 
endpoints are adjacent.
See above for mor edetails.

(WebCore::canCoalesceGeometries):
(WebCore::RenderObject::collectSelectionGeometries):

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



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

Reply via email to