mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1796734 part 2: Don't try to get the focused LocalAccessible from the Android UI thread. r=morgan
IN subsequent patches, IsFocused will be called when querying the state of a RemoteAccessible and IsFocused calls FocusedAccessible. A RemoteAccessible can be queried from the Android UI thread (which is different to Gecko's main thread), but it's not safe to deal with LocalAccessibles off the main thread. Therefore, don't try to call FocusedLocalAccessible in this case. Differential Revision: https://phabricator.services.mozilla.com/D162177
This commit is contained in:
parent
fdf8f1eb26
commit
26de9d77df
@ -28,6 +28,7 @@ FocusManager::FocusManager() {}
|
||||
FocusManager::~FocusManager() {}
|
||||
|
||||
LocalAccessible* FocusManager::FocusedLocalAccessible() const {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (mActiveItem) {
|
||||
if (mActiveItem->IsDefunct()) {
|
||||
MOZ_ASSERT_UNREACHABLE("Stored active item is unbound from document");
|
||||
@ -49,9 +50,23 @@ LocalAccessible* FocusManager::FocusedLocalAccessible() const {
|
||||
}
|
||||
|
||||
Accessible* FocusManager::FocusedAccessible() const {
|
||||
#if defined(ANDROID)
|
||||
// It's not safe to call FocusedLocalAccessible() except on the main thread.
|
||||
// Android might query RemoteAccessibles on the UI thread, which might call
|
||||
// FocusedAccessible(). Never try to get the focused LocalAccessible in this
|
||||
// case.
|
||||
if (NS_IsMainThread()) {
|
||||
if (Accessible* focusedAcc = FocusedLocalAccessible()) {
|
||||
return focusedAcc;
|
||||
}
|
||||
} else {
|
||||
nsAccessibilityService::GetAndroidMonitor().AssertCurrentThreadOwns();
|
||||
}
|
||||
#else
|
||||
if (Accessible* focusedAcc = FocusedLocalAccessible()) {
|
||||
return focusedAcc;
|
||||
}
|
||||
#endif // defined(ANDROID)
|
||||
|
||||
if (!XRE_IsParentProcess()) {
|
||||
// DocAccessibleParent's don't exist in the content
|
||||
|
Loading…
Reference in New Issue
Block a user