Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 667eb43d06b329ab64f51ed61d42777ae0b00057 https://github.com/WebKit/WebKit/commit/667eb43d06b329ab64f51ed61d42777ae0b00057 Author: Wenson Hsieh <wenson_hs...@apple.com> Date: 2025-01-26 (Sun, 26 Jan 2025)
Changed paths: A LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-5-expected.txt A LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-5.html M Source/WebCore/editing/Editing.cpp M Source/WebCore/editing/RenderedPosition.h Log Message: ----------- [iOS] [Visual Bidi Selection] Selection sometimes unnecessarily expands when selecting bidi text https://bugs.webkit.org/show_bug.cgi?id=286556 rdar://143264840 Reviewed by Richard Robinson. When selecting the word "iPhone" in the following paragraph when visual bidi selection is enabled: > أُرسلت من الـ iPhone …we currently (incorrectly) expand the selection to include the entire paragraph, in an attempt to make the (already-visually-contiguous) selection visually contiguous. This is due to the fact that, when finding the base (minimum) bidi level in between the selection endpoints using the helper function `forEachRenderedBoxBetween(start, end)`, the `start` offset is after the end of the `e` in `"iPhone"` (LTR), but the end offset is at the beginning of the unrendered `U+202c` (pop directional formatting — i.e. PDF) character at the end of the paragraph. When iterating boxes on the line from left to right, we end up first visiting the box containing `U+202c` on the right edge (offset 21), followed by "iPhone" (from offset 15 to 21). The problem with this is that the contents of the `U+202c` PDF character isn't itself contained in the selection range, but because we include it as an inline box in between the selection endpoints, we end up trying to force visual contiguity by selecting all the content in the paragraph. To fix this, when iterating leaf boxes, we detect cases where either: 1. The first endpoint we encounter (in left-to-right order) has a position that is the rightmost offset in the bidi run, or 2. The last endpoint we encounter has a position that is the leftmost offset in the bidi run …and subsequently avoid applying the iteration callback for these collapsed ranges. * LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-5-expected.txt: Added. * LayoutTests/editing/selection/ios/bidi-visually-contiguous-selection-5.html: Added. Add a layout test to exercise the change. * Source/WebCore/editing/Editing.cpp: (WebCore::forEachRenderedBoxBetween): (WebCore::makeVisuallyContiguousIfNeeded): Drive-by fix: also avoid making the selection "visually contiguous" by collapsing the range. * Source/WebCore/editing/RenderedPosition.h: (WebCore::RenderedPosition::atLeftmostOffsetInBox const): (WebCore::RenderedPosition::atRightmostOffsetInBox const): Canonical link: https://commits.webkit.org/289410@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes