Bug 1819160 - Hold a reference to registering session in DocAccessibleParent. r=Jamie

This should fully eliminate the case where remote accessibles fail to
unregister because of the outer PresShell's lifecycle.

Differential Revision: https://phabricator.services.mozilla.com/D172473
This commit is contained in:
Eitan Isaacson 2023-03-16 19:16:30 +00:00
Родитель 0bcdd24a3b
Коммит 87e86c8f87
4 изменённых файлов: 20 добавлений и 3 удалений

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

@ -273,9 +273,12 @@ RefPtr<SessionAccessibility> SessionAccessibility::GetInstanceFor(
return GetInstanceFor(doc->GetPresShell());
}
} else {
DocAccessibleParent* remoteDoc = aAccessible->AsRemote()->Document();
if (remoteDoc->mSessionAccessibility) {
return remoteDoc->mSessionAccessibility;
}
dom::CanonicalBrowsingContext* cbc =
static_cast<dom::BrowserParent*>(
aAccessible->AsRemote()->Document()->Manager())
static_cast<dom::BrowserParent*>(remoteDoc->Manager())
->GetBrowsingContext()
->Top();
dom::BrowserParent* bp = cbc->GetBrowserParent();
@ -286,7 +289,10 @@ RefPtr<SessionAccessibility> SessionAccessibility::GetInstanceFor(
if (auto element = bp->GetOwnerElement()) {
if (auto doc = element->OwnerDoc()) {
if (nsPresContext* presContext = doc->GetPresContext()) {
return GetInstanceFor(presContext->PresShell());
RefPtr<SessionAccessibility> sessionAcc =
GetInstanceFor(presContext->PresShell());
remoteDoc->mSessionAccessibility = sessionAcc;
return sessionAcc;
}
} else {
MOZ_ASSERT_UNREACHABLE(
@ -1080,6 +1086,7 @@ void SessionAccessibility::UnregisterAccessible(Accessible* aAccessible) {
}
RefPtr<SessionAccessibility> sessionAcc = GetInstanceFor(aAccessible);
MOZ_ASSERT(sessionAcc, "Need SessionAccessibility to unregister Accessible!");
if (sessionAcc) {
Accessible* registeredAcc =
sessionAcc->mIDToAccessibleMap.Get(virtualViewID);

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

@ -31,6 +31,7 @@
#endif
#if defined(ANDROID)
# include "mozilla/a11y/SessionAccessibility.h"
# define ACQUIRE_ANDROID_LOCK \
MonitorAutoLock mal(nsAccessibilityService::GetAndroidMonitor());
#else

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

@ -29,6 +29,10 @@ class xpcAccessibleGeneric;
class DocAccessiblePlatformExtParent;
#endif
#ifdef ANDROID
class SessionAccessibility;
#endif
/*
* These objects live in the main process and comunicate with and represent
* an accessible document in a content process.
@ -354,6 +358,10 @@ class DocAccessibleParent : public RemoteAccessible,
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) override;
#ifdef ANDROID
RefPtr<SessionAccessibility> mSessionAccessibility;
#endif
private:
~DocAccessibleParent();

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

@ -27,6 +27,7 @@ else:
elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
LOCAL_INCLUDES += [
"/accessible/android",
"/widget/android",
]
else:
LOCAL_INCLUDES += [