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 if (const auto it = accessibleElements.find(axid); it == accessibleElements.end()) {
18 accessibleElements[axid] = element;
19 [element retain];
20 return true;
21 } else if (it.value() != element) {
22 auto *oldElement = it.value();
23 // this might invalidate the iterator
24 [oldElement invalidate];
25 [oldElement release];
26
27 accessibleElements[axid] = element;
28 [element retain];
29 return true;
30 }
31 return false;
32}
33
34void QAccessibleCache::removeAccessibleElement(QAccessible::Id axid)
35{
36 // Some QAccessibleInterface instances in the cache didn't get created in
37 // response to a query, but when we emit events. So we might get called with
38 // and axid for which we don't have any element (yet).
39 if (QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *element = elementForId(axid)) {
40 [element invalidate];
41 accessibleElements.remove(axid);
42 [element release];
43 }
44}
45
46QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *QAccessibleCache::elementForId(QAccessible::Id axid) const
47{
48 return accessibleElements.value(axid);
49}
50
51QT_END_NAMESPACE
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QMacAccessibilityElement, NSObject -(void) invalidate;) QT_BEGIN_NAMESPACE bool QAccessibleCache