Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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.
20 */
21 class AccCollector
22 {
23 public:
24 AccCollector(Accessible* aRoot, filters::FilterFuncPtr aFilterFunc);
25 virtual ~AccCollector();
27 /**
28 * Return accessible count within the collection.
29 */
30 uint32_t Count();
32 /**
33 * Return an accessible from the collection at the given index.
34 */
35 Accessible* GetAccessibleAt(uint32_t aIndex);
37 /**
38 * Return index of the given accessible within the collection.
39 */
40 virtual int32_t GetIndexAt(Accessible* aAccessible);
42 protected:
43 /**
44 * Ensure accessible at the given index is stored and return it.
45 */
46 Accessible* EnsureNGetObject(uint32_t aIndex);
48 /**
49 * Ensure index for the given accessible is stored and return it.
50 */
51 int32_t EnsureNGetIndex(Accessible* aAccessible);
53 /**
54 * Append the object to collection.
55 */
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&);
68 };
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() { }
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;
90 };
92 } // namespace a11y
93 } // namespace mozilla
95 #endif