[webkit-changes] [WebKit/WebKit] 022bfa: [iOS] [Visual Bidi Selection] Support visually-con...

Wenson Hsieh noreply at github.com
Mon Dec 2 07:48:15 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 022bfa3b7e29116c5be21a63ea341445452d0db5
      https://github.com/WebKit/WebKit/commit/022bfa3b7e29116c5be21a63ea341445452d0db5
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2024-12-02 (Mon, 02 Dec 2024)

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

  Log Message:
  -----------
  [iOS] [Visual Bidi Selection] Support visually-contiguous selections in multiline bidi text
https://bugs.webkit.org/show_bug.cgi?id=283729
rdar://140594373

Reviewed by Richard Robinson.

Refactor logic under `collectSelectionGeometries` to correctly extract selection geometries in
visually-contiguous multiline bidi text selections. See below for more details.

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

Add a layout test to exercise this behavior change, by sanity checking the last selection rect's
width in an LTR text run embedded inside of an RTL paragraph.

* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::directionForFirstLine):
(WebCore::directionForLastLine):
(WebCore::makeBidiSelectionVisuallyContiguousIfNeeded):

Rewrite this to handle text selections in both RTL and LTR paragraphs. The current logic only works
for an LTR paragraph that contains bidi text; in contrast, the new logic works for all scenarios by
using the following approach:

1.  Pass through interior text selection geometries (i.e. neither on the first line nor the last
    line) to be a part of the final list.

2.  For all selection geometries on the first line, expand the selection from the start caret
    position to the trailing edge of the first line (i.e. right edge in LTR, left edge for RTL).

3.  For all selection geometries on the last line, expand the selection from the end caret
    position to the leading edge of the last line (i.e. left edge in LTR, right edge for RTL).

(WebCore::adjustTextDirectionForCoalescedGeometries):

Pull this functionality out into a couple of static helper functions (above), so that we can use
them in `makeBidiSelectionVisuallyContiguousIfNeeded`.

(WebCore::RenderObject::collectSelectionGeometries):

Only call `adjustTextDirectionForCoalescedGeometries` if the selection endpoint directions weren't
already adjusted as a part of `makeBidiSelectionVisuallyContiguousIfNeeded`.

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