Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 08a51bcc0dfde7f741158d1705b202e1da805339
      
https://github.com/WebKit/WebKit/commit/08a51bcc0dfde7f741158d1705b202e1da805339
  Author: Wenson Hsieh <[email protected]>
  Date:   2025-01-28 (Tue, 28 Jan 2025)

  Changed paths:
    A 
LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-6-expected.txt
    A 
LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-6.html
    M LayoutTests/resources/ui-helper.js
    M Source/WebCore/editing/Editing.cpp

  Log Message:
  -----------
  [iOS] [Visual Bidi Selection] Selection sometimes shrinks when selecting a 
paragraph that ends with RLE character
https://bugs.webkit.org/show_bug.cgi?id=286582
rdar://143265072

Reviewed by Abrar Rahman Protyasha.

Fix a corner case in how we select the closest bidi text boundary when making a 
selected text range
both visually and logically contiguous, which causes the selection to snap to 
the (visually)
farthest boundary instead of the closer one. See below (`findBidiBoundary`) for 
more details.

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

Add a layout test to exercise this change by selecting from the first Arabic 
word in the paragraph,
to the end of `iPhone`; verify that the entire paragraph remains selected.

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

Add a `UIHelper` method to compute the overall bounding rect of the selection.

* Source/WebCore/editing/Editing.cpp:
(WebCore::findBidiBoundary):

Implement the main fix here — if the left boundary point is visually closer, we 
currently choose the
right boundary point and vice versa. This works for the most part, where the 
selection direction is
opposite of the direction of the bidi text run that contains the new boundaries 
(since selecting the
left boundary will have the effect of visually selecting to the right boundary 
and vice versa).
However, in the case where the direction *matches* the direction of the bidi 
text run containing the
extent, this reversal doesn't happen, so moving the selection extent to the 
left/right boundaries
will actually visually select to the left/right boundaries, respectively.

To account for this, we consider the selection direction when determining which 
bidi boundary point
to snap to after ending range adjustment.

(WebCore::makeVisuallyContiguousIfNeeded):

Pass in the direction of the selected text on the first and/or last line (see 
above).

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