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) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://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 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qaccessiblecache_p.h"-
35-
36#ifndef QT_NO_ACCESSIBILITY-
37-
38QT_BEGIN_NAMESPACE-
39-
40/*!-
41 \class QAccessibleCache-
42 \internal-
43 \brief Maintains a cache of accessible interfaces.-
44*/-
45-
46Q_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
47-
48QAccessibleCache *QAccessibleCache::instance()-
49{-
50 return qAccessibleCache;
never executed: return qAccessibleCache;
0
51}-
52-
53/*-
54 The ID is always in the range [INT_MAX+1, UINT_MAX].-
55 This makes it easy on windows to reserve the positive integer range-
56 for the index of a child and not clash with the unique ids.-
57*/-
58QAccessible::Id QAccessibleCache::acquireId() const-
59{-
60 static const QAccessible::Id FirstId = QAccessible::Id(INT_MAX) + 1;-
61 static QAccessible::Id lastUsedId = FirstId;-
62-
63 while (idToInterface.contains(lastUsedId)) {
idToInterface....ns(lastUsedId)Description
TRUEnever evaluated
FALSEnever evaluated
0
64 // (wrap back when when we reach UINT_MAX - 1)-
65 // -1 because on Android -1 is taken for the "View" so just avoid it completely for consistency-
66 if (lastUsedId == UINT_MAX - 1)
lastUsedId == ...* 2U + 1U) - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
67 lastUsedId = FirstId;
never executed: lastUsedId = FirstId;
0
68 else-
69 ++lastUsedId;
never executed: ++lastUsedId;
0
70 }-
71-
72 return lastUsedId;
never executed: return lastUsedId;
0
73}-
74-
75QAccessibleInterface *QAccessibleCache::interfaceForId(QAccessible::Id id) const-
76{-
77 return idToInterface.value(id);
never executed: return idToInterface.value(id);
0
78}-
79-
80QAccessible::Id QAccessibleCache::idForInterface(QAccessibleInterface *iface) const-
81{-
82 return interfaceToId.value(iface);
never executed: return interfaceToId.value(iface);
0
83}-
84-
85QAccessible::Id QAccessibleCache::insert(QObject *object, QAccessibleInterface *iface) const-
86{-
87 Q_ASSERT(iface);-
88 Q_UNUSED(object)-
89-
90 // object might be 0-
91 Q_ASSERT(!objectToId.contains(object));-
92 Q_ASSERT_X(!interfaceToId.contains(iface), "", "Accessible interface inserted into cache twice!");-
93-
94 QAccessible::Id id = acquireId();-
95 QObject *obj = iface->object();-
96 Q_ASSERT(object == obj);-
97 if (obj) {
objDescription
TRUEnever evaluated
FALSEnever evaluated
0
98 objectToId.insert(obj, id);-
99 connect(obj, &QObject::destroyed, this, &QAccessibleCache::objectDestroyed);-
100 }
never executed: end of block
0
101 idToInterface.insert(id, iface);-
102 interfaceToId.insert(iface, id);-
103 return id;
never executed: return id;
0
104}-
105-
106void QAccessibleCache::objectDestroyed(QObject* obj)-
107{-
108 QAccessible::Id id = objectToId.value(obj);-
109 if (id) {
idDescription
TRUEnever evaluated
FALSEnever evaluated
0
110 Q_ASSERT_X(idToInterface.contains(id), "", "QObject with accessible interface deleted, where interface not in cache!");-
111 deleteInterface(id, obj);-
112 }
never executed: end of block
0
113}
never executed: end of block
0
114-
115void QAccessibleCache::deleteInterface(QAccessible::Id id, QObject *obj)-
116{-
117 QAccessibleInterface *iface = idToInterface.take(id);-
118 interfaceToId.take(iface);-
119 if (!obj)
!objDescription
TRUEnever evaluated
FALSEnever evaluated
0
120 obj = iface->object();
never executed: obj = iface->object();
0
121 if (obj)
objDescription
TRUEnever evaluated
FALSEnever evaluated
0
122 objectToId.remove(obj);
never executed: objectToId.remove(obj);
0
123 delete iface;-
124-
125#ifdef Q_OS_MAC-
126 removeCocoaElement(id);-
127#endif-
128}
never executed: end of block
0
129-
130QT_END_NAMESPACE-
131-
132#endif-
Source codeSwitch to Preprocessed file

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