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
This commit is contained in:
James Teh 2020-07-02 17:20:38 +00:00
Родитель b14bb7b621
Коммит b9c87a600d
2 изменённых файлов: 12 добавлений и 10 удалений

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

@ -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<DocAccessibleParent*>(Proxy());
if (!doc->IsTopLevel()) {
MOZ_ASSERT(mID != kNoID, "A non root accessible must have an id");
ReleaseID(mID);
}
}

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

@ -69,8 +69,13 @@ AccessibleWrap* RootAccessibleWrap::FindAccessibleById(
if (!child) {
break;
}
// 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;
}