RFR: 8304831: TextFlow.hitTest.insertionIndex incorrect with surrogate pairs [v4]
Karthik P K
kpk at openjdk.org
Mon Jun 5 11:42:18 UTC 2023
On Fri, 2 Jun 2023 20:57:06 GMT, Phil Race <prr at openjdk.org> wrote:
>> you are right, it cannot be explained by a null text.
>>
>> so if i understand you correctly, the question is about validity of `insertionIndex += 1` on lines 463 and 469.
>>
>> 463: should it be set to text.length() instead?
>>
>> 469: since text==null, could `insertionIndex = charIndex + 1` be correct?
>>
>> And also, is it possible at all that text == null within PrismTextLayout?
>
> No, because that's after the call to BreakIterator.following(int)
> It is mainly about the assignment on line 456
>> insertionIndex = charIndex;
>
> since that is what gets passed to BreakIterator.following(int)
>
> and charIndex was calculated by
> charIndex = run.getStart() + run.getOffsetAtX(x, trailing);
> so it goes back to that calculation.
> Perhaps a simple validation that charIndex is not out of bounds is all that is needed.
Added check to make sure that insertion index passed to BreakIterator.following(int) is not out of bound.
Added this check after line 456 `insertionIndex = charIndex;`, otherwise insertionIndex remains as -1 and `Hitinfo::getInsertionIndex` will calculate wrong insertionIndex.
Please check the change.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1091#discussion_r1217947206
More information about the openjfx-dev
mailing list