RFR: 8304831: TextFlow.hitTest.insertionIndex incorrect with surrogate pairs
Andy Goryachev
angorya at openjdk.org
Fri Apr 21 16:32:56 UTC 2023
On Fri, 14 Apr 2023 07:35:33 GMT, Karthik P K <kpk at openjdk.org> wrote:
> Since surrogate pairs are internally considered as 2 characters and text field is null in `HitInfo` when `getInsertionIndex` is invoked from `TextFlow`, wrong insertion index was returned.
>
> Updated code to calculate insertion index in `getHitInfo` method of `PrismTextLayout` class when `hitTest` of trailing side of surrogate pair is requested. Since text runs are processed in this method already, calculating the insertion index in this method looks better than calculating in `getInsertionIndex` of `HitInfo` method.
> The latter approach also requires the text to be sent to `HitInfo` as parameter from the `hitTest` method of `TextFlow`. If the number of `Text` nodes in `TextFlow` are very large, processing all the `Text` nodes on each `hitTest` method invocation might cause performance issue. Hence implemented first approach.
>
> Added system test to validate the fix.
could you please check with the Monkey Tester?
I could be doing something wrong.
I still see the problem in the Monkey Tester. Open TextFlow page, select Emojis text, 48 size, and slowly move the mouse across the text. You can see the insertionIndex differ between Text and TextFlow (and incorrect in the latter case).
See here, the vertical line is where the mouse is (middle of the heart symbol):

tests/system/src/test/java/test/robot/javafx/scene/TextFlowSurrogatePairInsertionIndexTest.java line 109:
> 107: }
> 108:
> 109: @Test
would it be possible to add another test, where the cursor is moved across an emoji character one pixel at a time, making sure that insertionIndex monotonically increases?
as a variant, move across a text string with multiple emojis?
-------------
PR Review: https://git.openjdk.org/jfx/pull/1091#pullrequestreview-1396026013
PR Comment: https://git.openjdk.org/jfx/pull/1091#issuecomment-1518069929
PR Review Comment: https://git.openjdk.org/jfx/pull/1091#discussion_r1173937470
More information about the openjfx-dev
mailing list