RFR: 8304831: TextFlow.hitTest.insertionIndex incorrect with surrogate pairs [v6]

Kevin Rushforth kcr at openjdk.org
Thu May 18 18:34:58 UTC 2023


On Thu, 18 May 2023 09:27:18 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.
>
> Karthik P K has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Add new test. Optimizations to make the tests robust

I'd be interested to know whether the call to `Toolkit::firePulse` makes this test stable. A system test really should not need to call `firePulse` directly. It artificially alters the control flow.

Perhaps a better approach, which we could consider for a follow-up, would be to have a utility method that adds a pulse listener, calls `Platform::requestNextPulse`, and waits on a latch triggered by the pulse listener.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1091#issuecomment-1553464287


More information about the openjfx-dev mailing list