2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2012-08-28 08:24:30 +00:00
|
|
|
#ifndef AccCollector_h_
|
|
|
|
#define AccCollector_h_
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2012-08-28 08:24:30 +00:00
|
|
|
#include "filters.h"
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2012-08-28 08:24:30 +00:00
|
|
|
#include "nscore.h"
|
2010-06-21 13:08:27 +00:00
|
|
|
#include "nsTArray.h"
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
/**
|
|
|
|
* Collect accessible children complying with filter function. Provides quick
|
|
|
|
* access to accessible by index.
|
|
|
|
*/
|
|
|
|
class AccCollector
|
2010-05-20 07:40:25 +00:00
|
|
|
{
|
2010-06-21 13:08:27 +00:00
|
|
|
public:
|
2012-05-29 01:18:45 +00:00
|
|
|
AccCollector(Accessible* aRoot, filters::FilterFuncPtr aFilterFunc);
|
2010-06-21 13:08:27 +00:00
|
|
|
virtual ~AccCollector();
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
/**
|
|
|
|
* Return accessible count within the collection.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t Count();
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
/**
|
|
|
|
* Return an accessible from the collection at the given index.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
Accessible* GetAccessibleAt(uint32_t aIndex);
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
/**
|
|
|
|
* Return index of the given accessible within the collection.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual int32_t GetIndexAt(Accessible* aAccessible);
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Ensure accessible at the given index is stored and return it.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
Accessible* EnsureNGetObject(uint32_t aIndex);
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
/**
|
|
|
|
* Ensure index for the given accessible is stored and return it.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t EnsureNGetIndex(Accessible* aAccessible);
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2010-08-15 11:28:49 +00:00
|
|
|
/**
|
|
|
|
* Append the object to collection.
|
|
|
|
*/
|
2012-05-29 01:18:45 +00:00
|
|
|
virtual void AppendObject(Accessible* aAccessible);
|
2010-08-15 11:28:49 +00:00
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
filters::FilterFuncPtr mFilterFunc;
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* mRoot;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mRootChildIdx;
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
nsTArray<Accessible*> mObjects;
|
2010-06-21 13:08:27 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
AccCollector();
|
|
|
|
AccCollector(const AccCollector&);
|
|
|
|
AccCollector& operator =(const AccCollector&);
|
|
|
|
};
|
|
|
|
|
2010-08-15 11:28:49 +00:00
|
|
|
/**
|
|
|
|
* Collect embedded objects. Provide quick access to accessible by index and
|
|
|
|
* vice versa.
|
|
|
|
*/
|
|
|
|
class EmbeddedObjCollector : public AccCollector
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~EmbeddedObjCollector() { };
|
|
|
|
|
|
|
|
public:
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual int32_t GetIndexAt(Accessible* aAccessible);
|
2010-08-15 11:28:49 +00:00
|
|
|
|
|
|
|
protected:
|
2012-05-29 01:18:45 +00:00
|
|
|
// Make sure it's used by Accessible class only.
|
|
|
|
EmbeddedObjCollector(Accessible* aRoot) :
|
2010-08-15 11:28:49 +00:00
|
|
|
AccCollector(aRoot, filters::GetEmbeddedObject) { }
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
virtual void AppendObject(Accessible* aAccessible);
|
2010-08-15 11:28:49 +00:00
|
|
|
|
2012-08-28 08:24:30 +00:00
|
|
|
friend class Accessible;
|
2010-08-15 11:28:49 +00:00
|
|
|
};
|
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
#endif
|