office-gobmx/vcl/qt6/QtAccessibleRegistry.cxx
Michael Weghorn 812fe185fb qt a11y: Remember and reuse existing QObject for XAccessible
Previously, a new `QtXAccessible` object was created
for an `XAccessible` each time before
`QAccessible::queryAccessibleInterface` was called,
which is not only unnecessary but also causes
various issues, e.g. it breaks walking the a11y hierarchy
upwards (i.e. from children to parents), since a new
object is created for the parent.

This introduces `QtAccessibleRegistry` that keeps
a mapping between the `XAccessible` and
the associated `QObject`. That mapping is used
to reuse already created objects instead of creating
new ones for the same `XAccessible`.

The entry for an `XAccessible` is removed again from the
map in `QtAccessibleWidget::invalidate`, which gets called
when the `XAccessible` gets disposed,
s. `QtAccessibleEventListener::disposing`.

With this in place, Orca now also nicely announces
only the text of the push buttons themselves in the "Save Document?"
dialog when switching between the buttons using the
Tab key, rather than announcing the whole widget hierarchy
every time (probably because creating a new object every time
prevented Orca from recognizing that the previously selected
pushbutton and the newly selected one are siblings, i.e.
have the same parent object.)

Change-Id: Ic890a387ff016e889f25dba70c82d0d81ae7a9e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138757
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2022-08-24 19:05:35 +02:00

12 lines
438 B
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "../qt5/QtAccessibleRegistry.cxx"
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */