RFR: 8304831: TextFlow.hitTest.insertionIndex incorrect with surrogate pairs [v4]
Andy Goryachev
angorya at openjdk.org
Thu Jun 1 22:57:17 UTC 2023
On Thu, 1 Jun 2023 20:55:33 GMT, Phil Race <prr at openjdk.org> wrote:
>> Assuming line 473 is the one still there today, it looks to me as if that would be reached if you had the caret on an empty line that isn't the last line.
>
> Regarding
> "If we can initialize insertionIndex to a positive value, then the buggy code in HitInfo.getInsertionIndex()
> will never get executed, and we can remove it later (in JDK-8302511)."
>
> it seems to me that this new code has been pretty much copied from the supposedly buggy code there ..
> I'm not sure that code is actually buggy (comments over in that bug), rather that the instance was constructed
> with bad data.
>
> But maybe this code here also needs to make sure it won't cause AIOB
The main issue is that insertion index was not computed in the PrismTextLayout, supposedly to allow for delaying the computation until it's needed (if needed at all). A good intention, but the execution had two issues:
1. HitInfo obtained in TextFlow had its 'text' field set to null (TextFlow:204), disabling any possibility of computing the index correctly
2. The code that computed the index had an issue in that if an exception happened, it left the object in an inconsistent state, leading to other problems down the road, and more exceptions (incl. AIOB)
What we did here is to compute the insertion index correctly at the source.
I've also checked that in the case of an empty line the insertion index is correct in both cases (at the last line and in the middle of a document).
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1091#discussion_r1213756660
More information about the openjfx-dev
mailing list