blob: 6b41867105fc1ac12488bae85e98de4f496bbcff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qaccessiblecache_p.h"
#include <QtCore/private/qcore_mac_p.h>
// qcocoaaccessibilityelement.h in platform plugin
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QMacAccessibilityElement, NSObject
- (void)invalidate;
)
QT_BEGIN_NAMESPACE
bool QAccessibleCache::insertElement(QAccessible::Id axid,
QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *element) const
{
if (const auto it = accessibleElements.find(axid); it == accessibleElements.end()) {
accessibleElements[axid] = element;
[element retain];
return true;
} else if (it.value() != element) {
auto *oldElement = it.value();
// this might invalidate the iterator
[oldElement invalidate];
[oldElement release];
accessibleElements[axid] = element;
[element retain];
return true;
}
return false;
}
void QAccessibleCache::removeAccessibleElement(QAccessible::Id axid)
{
// Some QAccessibleInterface instances in the cache didn't get created in
// response to a query, but when we emit events. So we might get called with
// and axid for which we don't have any element (yet).
if (QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *element = elementForId(axid)) {
[element invalidate];
accessibleElements.remove(axid);
[element release];
}
}
QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *QAccessibleCache::elementForId(QAccessible::Id axid) const
{
return accessibleElements.value(axid);
}
QT_END_NAMESPACE
|