Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6f849acb124ba787747bbd501cd289145cdf7a22
      
https://github.com/WebKit/WebKit/commit/6f849acb124ba787747bbd501cd289145cdf7a22
  Author: Wenson Hsieh <[email protected]>
  Date:   2024-11-26 (Tue, 26 Nov 2024)

  Changed paths:
    A 
LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-2-expected.txt
    A 
LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-2.html
    M Source/WebCore/editing/Editing.cpp
    M Source/WebCore/editing/Editing.h
    M Source/WebCore/rendering/RenderObject.cpp
    M Source/WebCore/rendering/RenderObject.h

  Log Message:
  -----------
  [iOS] Selection handles sometimes unnecessarily flip when extending selection 
over bidi text
https://bugs.webkit.org/show_bug.cgi?id=283683
rdar://140550161

Reviewed by Richard Robinson.

Currently, selection handles sometimes show up on the wrong side when adjusting 
the text selection
in bidi text. This is because:

-   The side on which selection handles are rendered is determined by whether a 
selection rect that
    contains either the start or end is marked LTR or RTL.

-   In the process of coalescing selection rects that span bidi text, this 
information can be lost,
    if LTR selection geometries are coalesced into RTL selections or vice versa.

To fix this, we add a second step after coalescing selection rects to adjust 
text directions of the
selection endpoints, computed based on the direction of the minimum bidi level 
that contains either
the whole selection (for a single-line selection) or the selected parts of the 
first and last lines
(for a multi-line selection).

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

Add a layout test to exercise this change.

* Source/WebCore/editing/Editing.cpp:
(WebCore::advanceInDirection):
(WebCore::forEachRenderedBoxBetween):

Pull out logic to iterate over leaf text boxes between the two given rendered 
positions (inclusive)
into a static helper, which we can use in a couple of places below.

(WebCore::positionsForRange):
(WebCore::primaryDirectionForSingleLineRange):

Add a new helper function to return the "primary direction" of a range that 
spans a single line,
i.e. the direction of the text box with the minimum bidi level in the text 
range.

(WebCore::adjustToVisuallyContiguousRange):
* Source/WebCore/editing/Editing.h:
* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::adjustTextDirectionForCoalescedGeometries):
(WebCore::RenderObject::collectSelectionGeometriesInternal):
(WebCore::RenderObject::collectSelectionGeometries):
* Source/WebCore/rendering/RenderObject.h:

Canonical link: https://commits.webkit.org/287106@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