Skip to content
Snippets Groups Projects
Verified Commit dc46a58f authored by James Teh's avatar James Teh Committed by Pier Angelo Vendrame
Browse files

Bug 1772170: Ensure cached Accessibles and offsets are valid before returning...

Bug 1772170: Ensure cached Accessibles and offsets are valid before returning them in DocAccessibleParent::SelectionRanges. r=eeejay

Differential Revision: https://phabricator.services.mozilla.com/D148745
parent dfb83cd2
Branches
Tags
1 merge request!768Bug 42090: Rebase release release onto 102.15.1esr
......@@ -1195,11 +1195,26 @@ DocAccessiblePlatformExtParent* DocAccessibleParent::GetPlatformExtension() {
void DocAccessibleParent::SelectionRanges(nsTArray<TextRange>* aRanges) const {
for (const auto& data : mTextSelections) {
aRanges->AppendElement(
TextRange(const_cast<DocAccessibleParent*>(this),
const_cast<RemoteAccessible*>(GetAccessible(data.StartID())),
data.StartOffset(),
const_cast<RemoteAccessible*>(GetAccessible(data.EndID())),
// Selection ranges should usually be in sync with the tree. However, tree
// and selection updates happen using separate IPDL calls, so it's possible
// for a client selection query to arrive between them. Thus, we validate
// the Accessibles and offsets here.
auto* startAcc =
const_cast<RemoteAccessible*>(GetAccessible(data.StartID()));
auto* endAcc = const_cast<RemoteAccessible*>(GetAccessible(data.EndID()));
if (!startAcc || !endAcc) {
continue;
}
uint32_t startCount = startAcc->CharacterCount();
if (data.StartOffset() > static_cast<int32_t>(startCount)) {
continue;
}
uint32_t endCount = endAcc->CharacterCount();
if (data.EndOffset() > static_cast<int32_t>(endCount)) {
continue;
}
aRanges->AppendElement(TextRange(const_cast<DocAccessibleParent*>(this),
startAcc, data.StartOffset(), endAcc,
data.EndOffset()));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment