michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_a11y_AccCollector_h__ michael@0: #define mozilla_a11y_AccCollector_h__ michael@0: michael@0: #include "Filters.h" michael@0: michael@0: #include "nsTArray.h" michael@0: michael@0: namespace mozilla { michael@0: namespace a11y { michael@0: michael@0: class Accessible; michael@0: michael@0: /** michael@0: * Collect accessible children complying with filter function. Provides quick michael@0: * access to accessible by index. michael@0: */ michael@0: class AccCollector michael@0: { michael@0: public: michael@0: AccCollector(Accessible* aRoot, filters::FilterFuncPtr aFilterFunc); michael@0: virtual ~AccCollector(); michael@0: michael@0: /** michael@0: * Return accessible count within the collection. michael@0: */ michael@0: uint32_t Count(); michael@0: michael@0: /** michael@0: * Return an accessible from the collection at the given index. michael@0: */ michael@0: Accessible* GetAccessibleAt(uint32_t aIndex); michael@0: michael@0: /** michael@0: * Return index of the given accessible within the collection. michael@0: */ michael@0: virtual int32_t GetIndexAt(Accessible* aAccessible); michael@0: michael@0: protected: michael@0: /** michael@0: * Ensure accessible at the given index is stored and return it. michael@0: */ michael@0: Accessible* EnsureNGetObject(uint32_t aIndex); michael@0: michael@0: /** michael@0: * Ensure index for the given accessible is stored and return it. michael@0: */ michael@0: int32_t EnsureNGetIndex(Accessible* aAccessible); michael@0: michael@0: /** michael@0: * Append the object to collection. michael@0: */ michael@0: virtual void AppendObject(Accessible* aAccessible); michael@0: michael@0: filters::FilterFuncPtr mFilterFunc; michael@0: Accessible* mRoot; michael@0: uint32_t mRootChildIdx; michael@0: michael@0: nsTArray mObjects; michael@0: michael@0: private: michael@0: AccCollector(); michael@0: AccCollector(const AccCollector&); michael@0: AccCollector& operator =(const AccCollector&); michael@0: }; michael@0: michael@0: /** michael@0: * Collect embedded objects. Provide quick access to accessible by index and michael@0: * vice versa. michael@0: */ michael@0: class EmbeddedObjCollector : public AccCollector michael@0: { michael@0: public: michael@0: virtual ~EmbeddedObjCollector() { } michael@0: michael@0: public: michael@0: virtual int32_t GetIndexAt(Accessible* aAccessible); michael@0: michael@0: protected: michael@0: // Make sure it's used by Accessible class only. michael@0: EmbeddedObjCollector(Accessible* aRoot) : michael@0: AccCollector(aRoot, filters::GetEmbeddedObject) { } michael@0: michael@0: virtual void AppendObject(Accessible* aAccessible); michael@0: michael@0: friend class Accessible; michael@0: }; michael@0: michael@0: } // namespace a11y michael@0: } // namespace mozilla michael@0: michael@0: #endif