Bumping manifests a=b2g-bump
[gecko.git] / accessible / base / AccCollector.h
blob7cd1c5b74cf476251872304c76aea9129f71fdcb
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/. */
5 #ifndef mozilla_a11y_AccCollector_h__
6 #define mozilla_a11y_AccCollector_h__
8 #include "Filters.h"
10 #include "nsTArray.h"
12 namespace mozilla {
13 namespace a11y {
15 class Accessible;
17 /**
18 * Collect accessible children complying with filter function. Provides quick
19 * access to accessible by index.
21 class AccCollector
23 public:
24 AccCollector(Accessible* aRoot, filters::FilterFuncPtr aFilterFunc);
25 virtual ~AccCollector();
27 /**
28 * Return accessible count within the collection.
30 uint32_t Count();
32 /**
33 * Return an accessible from the collection at the given index.
35 Accessible* GetAccessibleAt(uint32_t aIndex);
37 /**
38 * Return index of the given accessible within the collection.
40 virtual int32_t GetIndexAt(Accessible* aAccessible);
42 protected:
43 /**
44 * Ensure accessible at the given index is stored and return it.
46 Accessible* EnsureNGetObject(uint32_t aIndex);
48 /**
49 * Ensure index for the given accessible is stored and return it.
51 int32_t EnsureNGetIndex(Accessible* aAccessible);
53 /**
54 * Append the object to collection.
56 virtual void AppendObject(Accessible* aAccessible);
58 filters::FilterFuncPtr mFilterFunc;
59 Accessible* mRoot;
60 uint32_t mRootChildIdx;
62 nsTArray<Accessible*> mObjects;
64 private:
65 AccCollector();
66 AccCollector(const AccCollector&);
67 AccCollector& operator =(const AccCollector&);
70 /**
71 * Collect embedded objects. Provide quick access to accessible by index and
72 * vice versa.
74 class EmbeddedObjCollector MOZ_FINAL : public AccCollector
76 public:
77 virtual ~EmbeddedObjCollector() { }
79 public:
80 virtual int32_t GetIndexAt(Accessible* aAccessible);
82 protected:
83 // Make sure it's used by Accessible class only.
84 EmbeddedObjCollector(Accessible* aRoot) :
85 AccCollector(aRoot, filters::GetEmbeddedObject) { }
87 virtual void AppendObject(Accessible* aAccessible);
89 friend class Accessible;
92 } // namespace a11y
93 } // namespace mozilla
95 #endif