accessible/src/base/AccCollector.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:b4e0ea7f02b4
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_AccCollector_h__
6 #define mozilla_a11y_AccCollector_h__
7
8 #include "Filters.h"
9
10 #include "nsTArray.h"
11
12 namespace mozilla {
13 namespace a11y {
14
15 class Accessible;
16
17 /**
18 * Collect accessible children complying with filter function. Provides quick
19 * access to accessible by index.
20 */
21 class AccCollector
22 {
23 public:
24 AccCollector(Accessible* aRoot, filters::FilterFuncPtr aFilterFunc);
25 virtual ~AccCollector();
26
27 /**
28 * Return accessible count within the collection.
29 */
30 uint32_t Count();
31
32 /**
33 * Return an accessible from the collection at the given index.
34 */
35 Accessible* GetAccessibleAt(uint32_t aIndex);
36
37 /**
38 * Return index of the given accessible within the collection.
39 */
40 virtual int32_t GetIndexAt(Accessible* aAccessible);
41
42 protected:
43 /**
44 * Ensure accessible at the given index is stored and return it.
45 */
46 Accessible* EnsureNGetObject(uint32_t aIndex);
47
48 /**
49 * Ensure index for the given accessible is stored and return it.
50 */
51 int32_t EnsureNGetIndex(Accessible* aAccessible);
52
53 /**
54 * Append the object to collection.
55 */
56 virtual void AppendObject(Accessible* aAccessible);
57
58 filters::FilterFuncPtr mFilterFunc;
59 Accessible* mRoot;
60 uint32_t mRootChildIdx;
61
62 nsTArray<Accessible*> mObjects;
63
64 private:
65 AccCollector();
66 AccCollector(const AccCollector&);
67 AccCollector& operator =(const AccCollector&);
68 };
69
70 /**
71 * Collect embedded objects. Provide quick access to accessible by index and
72 * vice versa.
73 */
74 class EmbeddedObjCollector : public AccCollector
75 {
76 public:
77 virtual ~EmbeddedObjCollector() { }
78
79 public:
80 virtual int32_t GetIndexAt(Accessible* aAccessible);
81
82 protected:
83 // Make sure it's used by Accessible class only.
84 EmbeddedObjCollector(Accessible* aRoot) :
85 AccCollector(aRoot, filters::GetEmbeddedObject) { }
86
87 virtual void AppendObject(Accessible* aAccessible);
88
89 friend class Accessible;
90 };
91
92 } // namespace a11y
93 } // namespace mozilla
94
95 #endif

mercurial