Bug 1782563 - Support END_OF_TEXT offset in TextLeafPoint constructor. r=Jamie

Differential Revision: https://phabricator.services.mozilla.com/D153386
This commit is contained in:
Eitan Isaacson 2022-08-02 16:29:07 +00:00
Родитель 92afd6db93
Коммит d66b7102eb
1 изменённых файлов: 13 добавлений и 3 удалений

Просмотреть файл

@ -439,14 +439,24 @@ TextLeafPoint::TextLeafPoint(Accessible* aAcc, int32_t aOffset) {
if (aOffset != nsIAccessibleText::TEXT_OFFSET_CARET && aAcc->HasChildren()) {
// Find a leaf. This might not necessarily be a TextLeafAccessible; it
// could be an empty container.
for (Accessible* acc = aAcc->FirstChild(); acc; acc = acc->FirstChild()) {
auto GetChild = [&aOffset](Accessible* acc) -> Accessible* {
return aOffset != nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT
? acc->FirstChild()
: acc->LastChild();
};
for (Accessible* acc = GetChild(aAcc); acc; acc = GetChild(acc)) {
mAcc = acc;
}
mOffset = 0;
mOffset = aOffset != nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT
? 0
: nsAccUtils::TextLength(mAcc);
return;
}
mAcc = aAcc;
mOffset = aOffset;
mOffset = aOffset != nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT
? aOffset
: nsAccUtils::TextLength(mAcc);
}
bool TextLeafPoint::operator<(const TextLeafPoint& aPoint) const {