Bug 1796734 part 1: Clear FocusManager's active item if an Accessible is still focused while the document is shutting down. r=eeejay

See the code comment for further details.
In subsequent patches, IsFocused is refactored to call FocusedAccessible, which asserts that mActiveItem is not defunct.
Without this active item fix, that change would cause accessible/tests/mochitest/actions/test_keys.xhtml to assert.

Differential Revision: https://phabricator.services.mozilla.com/D161887
This commit is contained in:
James Teh 2022-11-18 01:37:06 +00:00
Родитель fa9e8b41cc
Коммит fdf8f1eb26
1 изменённых файлов: 19 добавлений и 4 удалений

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

@ -492,10 +492,25 @@ void DocAccessible::Shutdown() {
for (auto iter = mAccessibleCache.Iter(); !iter.Done(); iter.Next()) {
LocalAccessible* accessible = iter.Data();
MOZ_ASSERT(accessible);
if (accessible && !accessible->IsDefunct()) {
// Unlink parent to avoid its cleaning overhead in shutdown.
accessible->mParent = nullptr;
accessible->Shutdown();
if (accessible) {
// This might have been focused with FocusManager::ActiveItemChanged. In
// that case, we must notify FocusManager so that it clears the active
// item. Otherwise, it will hold on to a defunct Accessible. Normally,
// this happens in UnbindFromDocument, but we don't call that when the
// whole document shuts down.
if (FocusMgr()->WasLastFocused(accessible)) {
FocusMgr()->ActiveItemChanged(nullptr);
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus)) {
logging::ActiveItemChangeCausedBy("doc shutdown", accessible);
}
#endif
}
if (!accessible->IsDefunct()) {
// Unlink parent to avoid its cleaning overhead in shutdown.
accessible->mParent = nullptr;
accessible->Shutdown();
}
}
iter.Remove();
}