Bug 1688490: Make GetNativeFromGeckoAccessible null-safe r=eeejay

Differential Revision: https://phabricator.services.mozilla.com/D103813
This commit is contained in:
Morgan Reschenberg 2021-02-04 19:41:30 +00:00
parent 6b8df6efbe
commit ced0045bea
2 changed files with 9 additions and 5 deletions

View File

@ -27,7 +27,9 @@ namespace a11y {
inline mozAccessible* GetNativeFromGeckoAccessible(
mozilla::a11y::AccessibleOrProxy aAccOrProxy) {
MOZ_ASSERT(!aAccOrProxy.IsNull(), "Cannot get native from null accessible");
if (aAccOrProxy.IsNull()) {
return nil;
}
if (Accessible* acc = aAccOrProxy.AsAccessible()) {
mozAccessible* native = nil;
acc->GetNativeInterface((void**)&native);

View File

@ -263,10 +263,12 @@ using namespace mozilla::a11y;
// we override this method.
AccessibleOrProxy parentAcc = [parent geckoAccessible];
if (!parentAcc.IsNull()) {
mozAccessible* directGrandparent =
GetNativeFromGeckoAccessible(parentAcc.Parent());
if ([directGrandparent isKindOfClass:[MOXWebAreaAccessible class]]) {
return [parent moxIgnoreWithParent:directGrandparent];
AccessibleOrProxy grandparentAcc = parentAcc.Parent();
if (mozAccessible* directGrandparent =
GetNativeFromGeckoAccessible(grandparentAcc)) {
if ([directGrandparent isKindOfClass:[MOXWebAreaAccessible class]]) {
return [parent moxIgnoreWithParent:directGrandparent];
}
}
}