Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qaccessiblecache_mac.mm
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include <QtCore/private/qcore_mac_p.h>
6
7// qcocoaaccessibilityelement.h in platform plugin
8QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QMacAccessibilityElement, NSObject
9- (void)invalidate;
10)
11
12QT_BEGIN_NAMESPACE
13
14bool QAccessibleCache::insertElement(QAccessible::Id axid,
15 QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *element) const
16{
17 auto *oldElement = accessibleElements.value(axid);
18 if (oldElement == element)
19 return false;
20
21 // Update the map before invalidating and releasing the old element, as
22 // that might re-enter the cache.
23 [element retain];
24 accessibleElements.insert(axid, element);
25 if (oldElement) {
26 [oldElement invalidate];
27 [oldElement release];
28 }
29 return true;
30}
31
32void QAccessibleCache::removeAccessibleElement(QAccessible::Id axid)
33{
34 // Some QAccessibleInterface instances in the cache didn't get created in
35 // response to a query, but when we emit events. So we might get called with
36 // and axid for which we don't have any element (yet).
37 // Remove the element from the map before invalidating and releasing it,
38 // as that might re-enter the cache.
39 if (QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *element = accessibleElements.take(axid)) {
40 [element invalidate];
41 [element release];
42 }
43}
44
45QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *QAccessibleCache::elementForId(QAccessible::Id axid) const
46{
47 return accessibleElements.value(axid);
48}
49
50QT_END_NAMESPACE
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QMacAccessibilityElement, NSObject -(void) invalidate;) QT_BEGIN_NAMESPACE bool QAccessibleCache