Bug 1905065: When a caret is at the end of a line, have TextLeafPoint::FindBoundary return no character for BOUNDARY_CLUSTER. a=RyanVM

We already did this for BOUNDARY_CHAR, but i neglected to update this for cluster in bug 855184.
Without this, FindBoundary with BOUNDARY_CLUSTER on a caret TextLeafPoint when the caret is at the end of a line would return the last cluster instead of no character.

Differential Revision: https://phabricator.services.mozilla.com/D215178
This commit is contained in:
James Teh 2024-06-30 18:06:02 +00:00
parent 7a4cae215f
commit e68d2c191f

View file

@ -1049,7 +1049,8 @@ TextLeafPoint TextLeafPoint::FindBoundary(AccessibleTextBoundary aBoundaryType,
nsDirection aDirection,
BoundaryFlags aFlags) const {
if (IsCaret()) {
if (aBoundaryType == nsIAccessibleText::BOUNDARY_CHAR) {
if (aBoundaryType == nsIAccessibleText::BOUNDARY_CHAR ||
aBoundaryType == nsIAccessibleText::BOUNDARY_CLUSTER) {
if (IsCaretAtEndOfLine()) {
// The caret is at the end of the line. Return no character.
return ActualizeCaret(/* aAdjustAtEndOfLine */ false);