EmbeddedObjCollector.h (1627B)
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 LocalAccessible; 14 15 /** 16 * Collect embedded objects. Provide quick access to accessible by index and 17 * vice versa. 18 */ 19 class EmbeddedObjCollector final { 20 public: 21 ~EmbeddedObjCollector() {} 22 23 /** 24 * Return index of the given accessible within the collection. 25 */ 26 int32_t GetIndexAt(LocalAccessible* aAccessible); 27 28 /** 29 * Return accessible count within the collection. 30 */ 31 uint32_t Count(); 32 33 /** 34 * Return an accessible from the collection at the given index. 35 */ 36 LocalAccessible* GetAccessibleAt(uint32_t aIndex); 37 38 protected: 39 /** 40 * Ensure accessible at the given index is stored and return it. 41 */ 42 LocalAccessible* EnsureNGetObject(uint32_t aIndex); 43 44 /** 45 * Ensure index for the given accessible is stored and return it. 46 */ 47 int32_t EnsureNGetIndex(LocalAccessible* aAccessible); 48 49 // Make sure it's used by LocalAccessible class only. 50 explicit EmbeddedObjCollector(LocalAccessible* aRoot) 51 : mRoot(aRoot), mRootChildIdx(0) {} 52 53 /** 54 * Append the object to collection. 55 */ 56 void AppendObject(LocalAccessible* aAccessible); 57 58 friend class LocalAccessible; 59 60 LocalAccessible* mRoot; 61 uint32_t mRootChildIdx; 62 nsTArray<LocalAccessible*> mObjects; 63 }; 64 65 } // namespace a11y 66 } // namespace mozilla 67 68 #endif