/src/mozilla-central/accessible/base/EmbeddedObjCollector.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
2 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | | |
5 | | #ifndef mozilla_a11y_EmbeddedObjCollector_h__ |
6 | | #define mozilla_a11y_EmbeddedObjCollector_h__ |
7 | | |
8 | | #include "nsTArray.h" |
9 | | |
10 | | namespace mozilla { |
11 | | namespace a11y { |
12 | | |
13 | | class Accessible; |
14 | | |
15 | | /** |
16 | | * Collect embedded objects. Provide quick access to accessible by index and |
17 | | * vice versa. |
18 | | */ |
19 | | class EmbeddedObjCollector final |
20 | | { |
21 | | public: |
22 | 0 | ~EmbeddedObjCollector() { } |
23 | | |
24 | | /** |
25 | | * Return index of the given accessible within the collection. |
26 | | */ |
27 | | int32_t GetIndexAt(Accessible* aAccessible); |
28 | | |
29 | | /** |
30 | | * Return accessible count within the collection. |
31 | | */ |
32 | | uint32_t Count(); |
33 | | |
34 | | /** |
35 | | * Return an accessible from the collection at the given index. |
36 | | */ |
37 | | Accessible* GetAccessibleAt(uint32_t aIndex); |
38 | | |
39 | | protected: |
40 | | /** |
41 | | * Ensure accessible at the given index is stored and return it. |
42 | | */ |
43 | | Accessible* EnsureNGetObject(uint32_t aIndex); |
44 | | |
45 | | /** |
46 | | * Ensure index for the given accessible is stored and return it. |
47 | | */ |
48 | | int32_t EnsureNGetIndex(Accessible* aAccessible); |
49 | | |
50 | | // Make sure it's used by Accessible class only. |
51 | | explicit EmbeddedObjCollector(Accessible* aRoot) : |
52 | 0 | mRoot(aRoot), mRootChildIdx(0) {} |
53 | | |
54 | | /** |
55 | | * Append the object to collection. |
56 | | */ |
57 | | void AppendObject(Accessible* aAccessible); |
58 | | |
59 | | friend class Accessible; |
60 | | |
61 | | Accessible* mRoot; |
62 | | uint32_t mRootChildIdx; |
63 | | nsTArray<Accessible*> mObjects; |
64 | | }; |
65 | | |
66 | | } // namespace a11y |
67 | | } // namespace mozilla |
68 | | |
69 | | #endif |