Skip to content
Snippets Groups Projects
Verified Commit e460aee8 authored by James Teh's avatar James Teh Committed by ma1
Browse files

Bug 1781169: Ensure that the cached start/end containers contain characters...

Bug 1781169: Ensure that the cached start/end containers contain characters before returning them in DocAccessibleParent::SelectionRanges. r=eeejay

In bug 1772170, I added code to ensure that the cached offsets are valid.
However, this didn't account for the possibility that one of the containers contained 0 characters.
In that case, offset 0 is itself invalid.
If there were also no children, this might in GetChildAtOffset being called and returning null, causing a crash when retrieving selection.

Differential Revision: https://phabricator.services.mozilla.com/D154964
parent 2f4a54a3
Branches
Tags
1 merge request!712Bug 41908: Rebased on 102.14
......@@ -1206,11 +1206,12 @@ void DocAccessibleParent::SelectionRanges(nsTArray<TextRange>* aRanges) const {
continue;
}
uint32_t startCount = startAcc->CharacterCount();
if (data.StartOffset() > static_cast<int32_t>(startCount)) {
if (startCount == 0 ||
data.StartOffset() > static_cast<int32_t>(startCount)) {
continue;
}
uint32_t endCount = endAcc->CharacterCount();
if (data.EndOffset() > static_cast<int32_t>(endCount)) {
if (endCount == 0 || data.EndOffset() > static_cast<int32_t>(endCount)) {
continue;
}
aRanges->AppendElement(TextRange(const_cast<DocAccessibleParent*>(this),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment