From b9c87a600d289bb7df852fe087b71a09b8e7d75c Mon Sep 17 00:00:00 2001 From: James Teh Date: Thu, 2 Jul 2020 17:20:38 +0000 Subject: [PATCH] Bug 1649253: Correctly assign an Android a11y id to OOP iframe documents. r=eeejay The DocProxyAccessibleWrap for an OOP iframe document is always created before we know its parent. Previously, this resulted in the document getting an id of -1, which is only valid for the root document. It also broke subsequent assumptions once the parent was set later. Because we don't have the parent in this case, we can't add the document's id to its parent's hash table. To deal with this, we no longer add any document to its parent's hash table. Instead, when finding an accessible by id, we just check the id of each child document before checking that child document's hash table. Differential Revision: https://phabricator.services.mozilla.com/D81959 --- accessible/android/ProxyAccessibleWrap.h | 15 ++++++--------- accessible/android/RootAccessibleWrap.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/accessible/android/ProxyAccessibleWrap.h b/accessible/android/ProxyAccessibleWrap.h index e04ddc6a529b..27a6dacfc075 100644 --- a/accessible/android/ProxyAccessibleWrap.h +++ b/accessible/android/ProxyAccessibleWrap.h @@ -93,21 +93,18 @@ class DocProxyAccessibleWrap : public ProxyAccessibleWrap { : ProxyAccessibleWrap(aProxy) { mGenericTypes |= eDocument; - if (auto parent = ParentDocument()) { - mID = AcquireID(); - parent->AddID(mID, this); - } else { - // top level + if (aProxy->IsTopLevel()) { mID = kNoID; + } else { + mID = AcquireID(); } } virtual void Shutdown() override { if (mID) { - auto parent = ParentDocument(); - if (parent) { - MOZ_ASSERT(mID != kNoID, "A non root accessible always has a parent"); - parent->RemoveID(mID); + auto doc = static_cast(Proxy()); + if (!doc->IsTopLevel()) { + MOZ_ASSERT(mID != kNoID, "A non root accessible must have an id"); ReleaseID(mID); } } diff --git a/accessible/android/RootAccessibleWrap.cpp b/accessible/android/RootAccessibleWrap.cpp index f474cbf8f567..e39d107777c3 100644 --- a/accessible/android/RootAccessibleWrap.cpp +++ b/accessible/android/RootAccessibleWrap.cpp @@ -69,7 +69,12 @@ AccessibleWrap* RootAccessibleWrap::FindAccessibleById( if (!child) { break; } - acc = FindAccessibleById(child, aID); + // A child document's id is not in its parent document's hash table. + if (child->VirtualViewID() == aID) { + acc = child; + } else { + acc = FindAccessibleById(child, aID); + } } return acc;