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

Karthik P K kpk at openjdk.org
Mon Jun 5 11:16:52 UTC 2023


> 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 out of bound check for insertion index

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

Changes:
  - all: https://git.openjdk.org/jfx/pull/1091/files
  - new: https://git.openjdk.org/jfx/pull/1091/files/4d6dd9f3..ea940bf4

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jfx&pr=1091&range=08
 - incr: https://webrevs.openjdk.org/?repo=jfx&pr=1091&range=07-08

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jfx/pull/1091.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1091/head:pull/1091

PR: https://git.openjdk.org/jfx/pull/1091


More information about the openjfx-dev mailing list