2012-05-21 04:12:37 -07: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 00:40:25 -07:00
|
|
|
|
2012-08-28 06:13:59 -07:00
|
|
|
#ifndef mozilla_a11y_AccCollector_h__
|
|
|
|
#define mozilla_a11y_AccCollector_h__
|
2010-05-20 00:40:25 -07:00
|
|
|
|
2012-08-31 03:36:41 -07:00
|
|
|
#include "Filters.h"
|
2010-05-20 00:40:25 -07:00
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
#include "nsTArray.h"
|
2010-05-20 00:40:25 -07:00
|
|
|
|
2012-08-28 06:13:59 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
class Accessible;
|
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
/**
|
|
|
|
* Collect accessible children complying with filter function. Provides quick
|
|
|
|
* access to accessible by index.
|
|
|
|
*/
|
|
|
|
class AccCollector
|
2010-05-20 00:40:25 -07:00
|
|
|
{
|
2010-06-21 06:08:27 -07:00
|
|
|
public:
|
2012-05-28 18:18:45 -07:00
|
|
|
AccCollector(Accessible* aRoot, filters::FilterFuncPtr aFilterFunc);
|
2010-06-21 06:08:27 -07:00
|
|
|
virtual ~AccCollector();
|
2010-05-20 00:40:25 -07:00
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
/**
|
|
|
|
* Return accessible count within the collection.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t Count();
|
2010-05-20 00:40:25 -07:00
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
/**
|
|
|
|
* Return an accessible from the collection at the given index.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
Accessible* GetAccessibleAt(uint32_t aIndex);
|
2010-05-20 00:40:25 -07:00
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
/**
|
|
|
|
* Return index of the given accessible within the collection.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual int32_t GetIndexAt(Accessible* aAccessible);
|
2010-05-20 00:40:25 -07:00
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Ensure accessible at the given index is stored and return it.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
Accessible* EnsureNGetObject(uint32_t aIndex);
|
2010-05-20 00:40:25 -07:00
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
/**
|
|
|
|
* Ensure index for the given accessible is stored and return it.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t EnsureNGetIndex(Accessible* aAccessible);
|
2010-05-20 00:40:25 -07:00
|
|
|
|
2010-08-15 04:28:49 -07:00
|
|
|
/**
|
|
|
|
* Append the object to collection.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
virtual void AppendObject(Accessible* aAccessible);
|
2010-08-15 04:28:49 -07:00
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
filters::FilterFuncPtr mFilterFunc;
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* mRoot;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mRootChildIdx;
|
2010-05-20 00:40:25 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
nsTArray<Accessible*> mObjects;
|
2010-06-21 06:08:27 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
AccCollector();
|
|
|
|
AccCollector(const AccCollector&);
|
|
|
|
AccCollector& operator =(const AccCollector&);
|
|
|
|
};
|
|
|
|
|
2010-08-15 04:28:49 -07:00
|
|
|
/**
|
|
|
|
* Collect embedded objects. Provide quick access to accessible by index and
|
|
|
|
* vice versa.
|
|
|
|
*/
|
2015-03-21 09:28:04 -07:00
|
|
|
class EmbeddedObjCollector final : public AccCollector
|
2010-08-15 04:28:49 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-12-09 09:23:19 -08:00
|
|
|
virtual ~EmbeddedObjCollector() { }
|
2010-08-15 04:28:49 -07:00
|
|
|
|
|
|
|
public:
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual int32_t GetIndexAt(Accessible* aAccessible) override;
|
2010-08-15 04:28:49 -07:00
|
|
|
|
|
|
|
protected:
|
2012-05-28 18:18:45 -07:00
|
|
|
// Make sure it's used by Accessible class only.
|
2014-09-02 09:19:58 -07:00
|
|
|
explicit EmbeddedObjCollector(Accessible* aRoot) :
|
2010-08-15 04:28:49 -07:00
|
|
|
AccCollector(aRoot, filters::GetEmbeddedObject) { }
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void AppendObject(Accessible* aAccessible) override;
|
2010-08-15 04:28:49 -07:00
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
friend class Accessible;
|
2010-08-15 04:28:49 -07:00
|
|
|
};
|
|
|
|
|
2012-08-28 06:13:59 -07:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
#endif
|