Bug 1789384: Don't ascend past documents in Accessible::GetLevel. r=eeejay

On Android, we access RemoteAccessibles from the UI thread.
It's not safe to access LocalAccessibles on the UI thread.
The a11y code avoids touching LocalAccessibles on the UI thread directly.
However, Accessible::GetLevel was previously walking ancestry, which might hit a LocalAccessible and result in a crash.
To avoid this, don't ascend past a DocAccessible.
Level calculation shouldn't be crossing document boundaries anyway.
Note that we don't have to do this when we simply retrieve the parent (but nothing further) because we only do that for certain roles and the parent of these roles could never be an OuterDoc.

Differential Revision: https://phabricator.services.mozilla.com/D161873
This commit is contained in:
James Teh 2022-11-14 23:04:44 +00:00
Родитель 459f5a723c
Коммит 8fa2bf084a
1 изменённых файлов: 3 добавлений и 3 удалений

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

@ -236,7 +236,7 @@ int32_t Accessible::GetLevel(bool aFast) const {
if (!aFast) {
const Accessible* parent = this;
while ((parent = parent->Parent())) {
while ((parent = parent->Parent()) && !parent->IsDoc()) {
roles::Role parentRole = parent->Role();
if (parentRole == roles::OUTLINE) break;
@ -253,7 +253,7 @@ int32_t Accessible::GetLevel(bool aFast) const {
// Calculate 'level' attribute based on number of parent listitems.
level = 0;
const Accessible* parent = this;
while ((parent = parent->Parent())) {
while ((parent = parent->Parent()) && !parent->IsDoc()) {
roles::Role parentRole = parent->Role();
if (parentRole == roles::LISTITEM) {
@ -335,7 +335,7 @@ int32_t Accessible::GetLevel(bool aFast) const {
if (!aFast) {
const Accessible* parent = this;
while ((parent = parent->Parent())) {
while ((parent = parent->Parent()) && !parent->IsDoc()) {
roles::Role parentRole = parent->Role();
if (parentRole == roles::COMMENT) {
++level;