Bug 1789396: Null check acc before calling AsLocal() in RemoteAccessibleBase::BoundsWithOffset. r=morgan

We expect acc to be a local OuterDocAccessible.
However, the OuterDocAccessible might die before the top level DocAccessibleParent, in which case acc will be null.
In this case, the DocAccessibleParent is about to die anyway, so it doesn't matter that the bounds we return are slightly wrong (since they can't take the OuterDoc into account).

Differential Revision: https://phabricator.services.mozilla.com/D156773
This commit is contained in:
James Teh 2022-09-08 23:47:01 +00:00
Родитель ecfd7cff79
Коммит ea7dd2e2cd
1 изменённых файлов: 4 добавлений и 1 удалений

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

@ -614,7 +614,10 @@ LayoutDeviceIntRect RemoteAccessibleBase<Derived>::BoundsWithOffset(
// This block is not thread safe because it queries a LocalAccessible. // This block is not thread safe because it queries a LocalAccessible.
// It is also not needed in Android since the only local accessible is // It is also not needed in Android since the only local accessible is
// the outer doc browser that has an offset of 0. // the outer doc browser that has an offset of 0.
if (LocalAccessible* localAcc = const_cast<Accessible*>(acc)->AsLocal()) { // acc could be null if the OuterDocAccessible died before the top level
// DocAccessibleParent.
if (LocalAccessible* localAcc =
acc ? const_cast<Accessible*>(acc)->AsLocal() : nullptr) {
// LocalAccessible::Bounds returns screen-relative bounds in // LocalAccessible::Bounds returns screen-relative bounds in
// dev pixels. // dev pixels.
LayoutDeviceIntRect localBounds = localAcc->Bounds(); LayoutDeviceIntRect localBounds = localAcc->Bounds();