Skip to content

Commit

Permalink
Bug 1755420 part 1: Fix HyperTextAccessibleBase::TextAfterOffset when…
Browse files Browse the repository at this point in the history
… called with BOUNDARY_CHAR and TEXT_OFFSET_CARET. r=morgan

We need to adjust the offset if the caret is at the end of the line in this case.

Differential Revision: https://phabricator.services.mozilla.com/D138752
  • Loading branch information
jcsteh committed Feb 18, 2022
1 parent 8d966fc commit 759cd2a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions accessible/basetypes/HyperTextAccessibleBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ void HyperTextAccessibleBase::TextAfterOffset(

switch (aBoundaryType) {
case nsIAccessibleText::BOUNDARY_CHAR: {
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET &&
adjustedOffset > 0 &&
TextLeafPoint::GetCaret(Acc()).IsCaretAtEndOfLine()) {
--adjustedOffset;
}
uint32_t count = CharacterCount();
if (adjustedOffset >= count) {
*aStartOffset = *aEndOffset = static_cast<int32_t>(count);
Expand Down

0 comments on commit 759cd2a

Please sign in to comment.