Bug 1838782: Add null checks in HyperTextAccessibleBase::OffsetAtPoint. r=morgan

1. nsAccUtils::DocumentFor might return null if the Accessible is being moved and a client queried it during the move.
2. ChildAtPoint might return null if the point can't be located at all.

Differential Revision: https://phabricator.services.mozilla.com/D181213
This commit is contained in:
James Teh 2023-06-20 22:02:40 +00:00
Родитель 436fca2fe4
Коммит 987c8e49d5
1 изменённых файлов: 6 добавлений и 4 удалений

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

@ -298,10 +298,12 @@ int32_t HyperTextAccessibleBase::OffsetAtPoint(int32_t aX, int32_t aY,
if (aCoordType != nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE) {
p = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordType, thisAcc);
}
Accessible* hittestMatch = nsAccUtils::DocumentFor(thisAcc)->ChildAtPoint(
p.x, p.y, Accessible::EWhichChildAtPoint::DeepestChild);
if (thisAcc == hittestMatch->Parent()) {
return 0;
if (Accessible* doc = nsAccUtils::DocumentFor(thisAcc)) {
Accessible* hittestMatch = doc->ChildAtPoint(
p.x, p.y, Accessible::EWhichChildAtPoint::DeepestChild);
if (hittestMatch && thisAcc == hittestMatch->Parent()) {
return 0;
}
}
return -1;
}