qaccessiblecache.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/accessible/qaccessiblecache.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qaccessiblecache_p.h"-
41-
42#ifndef QT_NO_ACCESSIBILITY-
43-
44QT_BEGIN_NAMESPACE-
45-
46/*!-
47 \class QAccessibleCache-
48 \internal-
49 \brief Maintains a cache of accessible interfaces.-
50*/-
51-
52Q_GLOBAL_STATIC(QAccessibleCache, qAccessibleCache)
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
53-
54QAccessibleCache *QAccessibleCache::instance()-
55{-
56 return qAccessibleCache;
never executed: return qAccessibleCache;
0
57}-
58-
59/*-
60 The ID is always in the range [INT_MAX+1, UINT_MAX].-
61 This makes it easy on windows to reserve the positive integer range-
62 for the index of a child and not clash with the unique ids.-
63*/-
64QAccessible::Id QAccessibleCache::acquireId() const-
65{-
66 static const QAccessible::Id FirstId = QAccessible::Id(INT_MAX) + 1;-
67 static QAccessible::Id lastUsedId = FirstId;-
68-
69 while (idToInterface.contains(lastUsedId)) {
idToInterface....ns(lastUsedId)Description
TRUEnever evaluated
FALSEnever evaluated
0
70 // (wrap back when when we reach UINT_MAX - 1)-
71 // -1 because on Android -1 is taken for the "View" so just avoid it completely for consistency-
72 if (lastUsedId == UINT_MAX - 1)
lastUsedId == ...* 2U + 1U) - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
73 lastUsedId = FirstId;
never executed: lastUsedId = FirstId;
0
74 else-
75 ++lastUsedId;
never executed: ++lastUsedId;
0
76 }-
77-
78 return lastUsedId;
never executed: return lastUsedId;
0
79}-
80-
81QAccessibleInterface *QAccessibleCache::interfaceForId(QAccessible::Id id) const-
82{-
83 return idToInterface.value(id);
never executed: return idToInterface.value(id);
0
84}-
85-
86QAccessible::Id QAccessibleCache::idForInterface(QAccessibleInterface *iface) const-
87{-
88 return interfaceToId.value(iface);
never executed: return interfaceToId.value(iface);
0
89}-
90-
91QAccessible::Id QAccessibleCache::insert(QObject *object, QAccessibleInterface *iface) const-
92{-
93 Q_ASSERT(iface);-
94 Q_UNUSED(object)-
95-
96 // object might be 0-
97 Q_ASSERT(!objectToId.contains(object));-
98 Q_ASSERT_X(!interfaceToId.contains(iface), "", "Accessible interface inserted into cache twice!");-
99-
100 QAccessible::Id id = acquireId();-
101 QObject *obj = iface->object();-
102 Q_ASSERT(object == obj);-
103 if (obj) {
objDescription
TRUEnever evaluated
FALSEnever evaluated
0
104 objectToId.insert(obj, id);-
105 connect(obj, &QObject::destroyed, this, &QAccessibleCache::objectDestroyed);-
106 }
never executed: end of block
0
107 idToInterface.insert(id, iface);-
108 interfaceToId.insert(iface, id);-
109 return id;
never executed: return id;
0
110}-
111-
112void QAccessibleCache::objectDestroyed(QObject* obj)-
113{-
114 QAccessible::Id id = objectToId.value(obj);-
115 if (id) {
idDescription
TRUEnever evaluated
FALSEnever evaluated
0
116 Q_ASSERT_X(idToInterface.contains(id), "", "QObject with accessible interface deleted, where interface not in cache!");-
117 deleteInterface(id, obj);-
118 }
never executed: end of block
0
119}
never executed: end of block
0
120-
121void QAccessibleCache::deleteInterface(QAccessible::Id id, QObject *obj)-
122{-
123 QAccessibleInterface *iface = idToInterface.take(id);-
124 interfaceToId.take(iface);-
125 if (!obj)
!objDescription
TRUEnever evaluated
FALSEnever evaluated
0
126 obj = iface->object();
never executed: obj = iface->object();
0
127 if (obj)
objDescription
TRUEnever evaluated
FALSEnever evaluated
0
128 objectToId.remove(obj);
never executed: objectToId.remove(obj);
0
129 delete iface;-
130-
131#ifdef Q_OS_MAC-
132 removeCocoaElement(id);-
133#endif-
134}
never executed: end of block
0
135-
136QT_END_NAMESPACE-
137-
138#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9