Bug 1790317 part 1: Make LocalAccessible::ID return 0 for the document. r=eeejay

For IPC, we use id 0 to refer to the document.
However, LocalAccessible::UniqueID doesn't return 0 for documents.
This meant that when sending IPC messages, we hitherto had to special case the document in each case.

We don't want to mess with LocalAccessible::UniqueID, but since Accessible::ID was only introduced recently, we can set new expectations there.
Thus, this patch changes LocalAccessible::ID to return 0 for documents.
This means that in future, we can just use Accessible::ID when sending IPC messages.
nsAccUtils::GetAccessibleByID has also been updated to handle this.

Differential Revision: https://phabricator.services.mozilla.com/D157081
This commit is contained in:
James Teh 2022-10-04 06:13:51 +00:00
Родитель 1d51c801d1
Коммит cbf1bc1704
2 изменённых файлов: 5 добавлений и 1 удалений

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

@ -473,6 +473,10 @@ Accessible* nsAccUtils::GetAccessibleByID(Accessible* aDoc, uint64_t aID) {
}
if (LocalAccessible* localAcc = aDoc->AsLocal()) {
if (DocAccessible* doc = localAcc->AsDoc()) {
if (!aID) {
// GetAccessibleByUniqueID doesn't treat 0 as the document.
return aDoc;
}
return doc->GetAccessibleByUniqueID(
reinterpret_cast<void*>(static_cast<uintptr_t>(aID)));
}

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

@ -132,7 +132,7 @@ class LocalAccessible : public nsISupports, public Accessible {
void* UniqueID() { return static_cast<void*>(this); }
virtual uint64_t ID() const override {
return reinterpret_cast<uintptr_t>(this);
return IsDoc() ? 0 : reinterpret_cast<uintptr_t>(this);
}
/**