2011-08-10 05:44:00 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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 11:40:25 +04:00
|
|
|
|
2012-08-28 17:13:59 +04:00
|
|
|
#ifndef mozilla_a11y_AccIterator_h__
|
|
|
|
#define mozilla_a11y_AccIterator_h__
|
2010-05-20 11:40:25 +04:00
|
|
|
|
2012-08-28 12:24:30 +04:00
|
|
|
#include "DocAccessible.h"
|
2012-08-31 14:36:41 +04:00
|
|
|
#include "Filters.h"
|
2013-09-11 02:18:59 +04:00
|
|
|
|
|
|
|
class nsITreeView;
|
2012-08-28 17:13:59 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
2010-05-20 11:40:25 +04:00
|
|
|
|
2011-08-10 05:44:00 +04:00
|
|
|
/**
|
|
|
|
* AccIterable is a basic interface for iterators over accessibles.
|
|
|
|
*/
|
|
|
|
class AccIterable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~AccIterable() { }
|
2012-05-29 05:18:45 +04:00
|
|
|
virtual Accessible* Next() = 0;
|
2011-08-10 05:44:00 +04:00
|
|
|
|
|
|
|
private:
|
2012-11-18 06:01:44 +04:00
|
|
|
friend class Relation;
|
2011-08-10 05:44:00 +04:00
|
|
|
nsAutoPtr<AccIterable> mNextIter;
|
|
|
|
};
|
|
|
|
|
2010-05-20 11:40:25 +04:00
|
|
|
/**
|
|
|
|
* Allows to iterate through accessible children or subtree complying with
|
|
|
|
* filter function.
|
|
|
|
*/
|
2011-08-10 05:44:00 +04:00
|
|
|
class AccIterator : public AccIterable
|
2010-05-20 11:40:25 +04:00
|
|
|
{
|
|
|
|
public:
|
2012-08-28 17:13:59 +04:00
|
|
|
AccIterator(Accessible* aRoot, filters::FilterFuncPtr aFilterFunc);
|
2011-08-10 05:44:00 +04:00
|
|
|
virtual ~AccIterator();
|
2010-05-20 11:40:25 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return next accessible complying with filter function. Return the first
|
|
|
|
* accessible for the first time.
|
|
|
|
*/
|
2015-01-15 23:39:04 +03:00
|
|
|
virtual Accessible* Next() MOZ_OVERRIDE;
|
2010-05-20 11:40:25 +04:00
|
|
|
|
|
|
|
private:
|
2010-06-21 17:08:27 +04:00
|
|
|
AccIterator();
|
|
|
|
AccIterator(const AccIterator&);
|
|
|
|
AccIterator& operator =(const AccIterator&);
|
2010-05-20 11:40:25 +04:00
|
|
|
|
|
|
|
struct IteratorState
|
|
|
|
{
|
2014-09-02 20:19:58 +04:00
|
|
|
explicit IteratorState(Accessible* aParent, IteratorState* mParentState = nullptr);
|
2010-05-20 11:40:25 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* mParent;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mIndex;
|
2012-08-28 17:13:59 +04:00
|
|
|
IteratorState* mParentState;
|
2010-05-20 11:40:25 +04:00
|
|
|
};
|
|
|
|
|
2010-06-21 17:08:27 +04:00
|
|
|
filters::FilterFuncPtr mFilterFunc;
|
2012-08-28 17:13:59 +04:00
|
|
|
IteratorState* mState;
|
2010-05-20 11:40:25 +04:00
|
|
|
};
|
|
|
|
|
2010-11-18 05:55:44 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allows to traverse through related accessibles that are pointing to the given
|
|
|
|
* dependent accessible by relation attribute.
|
|
|
|
*/
|
2011-08-10 05:44:00 +04:00
|
|
|
class RelatedAccIterator : public AccIterable
|
2010-11-18 05:55:44 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
* @param aDocument [in] the document accessible the related
|
|
|
|
* & accessibles belong to.
|
|
|
|
* @param aDependentContent [in] the content of dependent accessible that
|
|
|
|
* relations were requested for
|
|
|
|
* @param aRelAttr [in] relation attribute that relations are
|
|
|
|
* pointed by
|
|
|
|
*/
|
2012-05-27 13:01:40 +04:00
|
|
|
RelatedAccIterator(DocAccessible* aDocument, nsIContent* aDependentContent,
|
2010-11-18 05:55:44 +03:00
|
|
|
nsIAtom* aRelAttr);
|
|
|
|
|
2011-08-10 05:44:00 +04:00
|
|
|
virtual ~RelatedAccIterator() { }
|
|
|
|
|
2010-11-18 05:55:44 +03:00
|
|
|
/**
|
|
|
|
* Return next related accessible for the given dependent accessible.
|
|
|
|
*/
|
2015-01-15 23:39:04 +03:00
|
|
|
virtual Accessible* Next() MOZ_OVERRIDE;
|
2010-11-18 05:55:44 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
RelatedAccIterator();
|
|
|
|
RelatedAccIterator(const RelatedAccIterator&);
|
|
|
|
RelatedAccIterator& operator = (const RelatedAccIterator&);
|
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* mDocument;
|
2010-11-18 05:55:44 +03:00
|
|
|
nsIAtom* mRelAttr;
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible::AttrRelProviderArray* mProviders;
|
2010-11-18 05:55:44 +03:00
|
|
|
nsIContent* mBindingParent;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mIndex;
|
2010-11-18 05:55:44 +03:00
|
|
|
};
|
|
|
|
|
2010-11-20 05:37:18 +03:00
|
|
|
|
|
|
|
/**
|
2011-09-29 07:13:08 +04:00
|
|
|
* Used to iterate through HTML labels associated with the given accessible.
|
2010-11-20 05:37:18 +03:00
|
|
|
*/
|
2011-08-10 05:44:00 +04:00
|
|
|
class HTMLLabelIterator : public AccIterable
|
2010-11-20 05:37:18 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum LabelFilter {
|
|
|
|
eAllLabels,
|
|
|
|
eSkipAncestorLabel
|
|
|
|
};
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
HTMLLabelIterator(DocAccessible* aDocument, const Accessible* aAccessible,
|
2010-11-20 05:37:18 +03:00
|
|
|
LabelFilter aFilter = eAllLabels);
|
|
|
|
|
2011-08-10 05:44:00 +04:00
|
|
|
virtual ~HTMLLabelIterator() { }
|
|
|
|
|
2010-11-20 05:37:18 +03:00
|
|
|
/**
|
|
|
|
* Return next label accessible associated with the given element.
|
|
|
|
*/
|
2015-01-15 23:39:04 +03:00
|
|
|
virtual Accessible* Next() MOZ_OVERRIDE;
|
2010-11-20 05:37:18 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
HTMLLabelIterator();
|
|
|
|
HTMLLabelIterator(const HTMLLabelIterator&);
|
|
|
|
HTMLLabelIterator& operator = (const HTMLLabelIterator&);
|
|
|
|
|
|
|
|
RelatedAccIterator mRelIter;
|
2011-09-29 07:13:08 +04:00
|
|
|
// XXX: replace it on weak reference (bug 678429), it's safe to use raw
|
|
|
|
// pointer now because iterators life cycle is short.
|
2012-05-29 05:18:45 +04:00
|
|
|
const Accessible* mAcc;
|
2010-11-20 05:37:18 +03:00
|
|
|
LabelFilter mLabelFilter;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to iterate through HTML outputs associated with the given element.
|
|
|
|
*/
|
2011-08-10 05:44:00 +04:00
|
|
|
class HTMLOutputIterator : public AccIterable
|
2010-11-20 05:37:18 +03:00
|
|
|
{
|
|
|
|
public:
|
2012-05-27 13:01:40 +04:00
|
|
|
HTMLOutputIterator(DocAccessible* aDocument, nsIContent* aElement);
|
2011-08-10 05:44:00 +04:00
|
|
|
virtual ~HTMLOutputIterator() { }
|
2010-11-20 05:37:18 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return next output accessible associated with the given element.
|
|
|
|
*/
|
2015-01-15 23:39:04 +03:00
|
|
|
virtual Accessible* Next() MOZ_OVERRIDE;
|
2010-11-20 05:37:18 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
HTMLOutputIterator();
|
|
|
|
HTMLOutputIterator(const HTMLOutputIterator&);
|
|
|
|
HTMLOutputIterator& operator = (const HTMLOutputIterator&);
|
|
|
|
|
|
|
|
RelatedAccIterator mRelIter;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to iterate through XUL labels associated with the given element.
|
|
|
|
*/
|
2011-08-10 05:44:00 +04:00
|
|
|
class XULLabelIterator : public AccIterable
|
2010-11-20 05:37:18 +03:00
|
|
|
{
|
|
|
|
public:
|
2012-05-27 13:01:40 +04:00
|
|
|
XULLabelIterator(DocAccessible* aDocument, nsIContent* aElement);
|
2011-08-10 05:44:00 +04:00
|
|
|
virtual ~XULLabelIterator() { }
|
2010-11-20 05:37:18 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return next label accessible associated with the given element.
|
|
|
|
*/
|
2015-01-15 23:39:04 +03:00
|
|
|
virtual Accessible* Next() MOZ_OVERRIDE;
|
2010-11-20 05:37:18 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
XULLabelIterator();
|
|
|
|
XULLabelIterator(const XULLabelIterator&);
|
|
|
|
XULLabelIterator& operator = (const XULLabelIterator&);
|
|
|
|
|
|
|
|
RelatedAccIterator mRelIter;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to iterate through XUL descriptions associated with the given element.
|
|
|
|
*/
|
2011-08-10 05:44:00 +04:00
|
|
|
class XULDescriptionIterator : public AccIterable
|
2010-11-20 05:37:18 +03:00
|
|
|
{
|
|
|
|
public:
|
2012-05-27 13:01:40 +04:00
|
|
|
XULDescriptionIterator(DocAccessible* aDocument, nsIContent* aElement);
|
2011-08-10 05:44:00 +04:00
|
|
|
virtual ~XULDescriptionIterator() { }
|
2010-11-20 05:37:18 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return next description accessible associated with the given element.
|
|
|
|
*/
|
2015-01-15 23:39:04 +03:00
|
|
|
virtual Accessible* Next() MOZ_OVERRIDE;
|
2010-11-20 05:37:18 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
XULDescriptionIterator();
|
|
|
|
XULDescriptionIterator(const XULDescriptionIterator&);
|
|
|
|
XULDescriptionIterator& operator = (const XULDescriptionIterator&);
|
|
|
|
|
|
|
|
RelatedAccIterator mRelIter;
|
|
|
|
};
|
|
|
|
|
2011-08-10 05:44:00 +04:00
|
|
|
/**
|
|
|
|
* Used to iterate through IDs, elements or accessibles pointed by IDRefs
|
|
|
|
* attribute. Note, any method used to iterate through IDs, elements, or
|
|
|
|
* accessibles moves iterator to next position.
|
|
|
|
*/
|
|
|
|
class IDRefsIterator : public AccIterable
|
|
|
|
{
|
|
|
|
public:
|
2012-05-27 13:01:40 +04:00
|
|
|
IDRefsIterator(DocAccessible* aDoc, nsIContent* aContent,
|
2012-03-23 09:26:52 +04:00
|
|
|
nsIAtom* aIDRefsAttr);
|
2011-08-10 05:44:00 +04:00
|
|
|
virtual ~IDRefsIterator() { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return next ID.
|
|
|
|
*/
|
|
|
|
const nsDependentSubstring NextID();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return next element.
|
|
|
|
*/
|
|
|
|
nsIContent* NextElem();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the element with the given ID.
|
|
|
|
*/
|
|
|
|
nsIContent* GetElem(const nsDependentSubstring& aID);
|
|
|
|
|
|
|
|
// AccIterable
|
2015-01-15 23:39:04 +03:00
|
|
|
virtual Accessible* Next() MOZ_OVERRIDE;
|
2011-08-10 05:44:00 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
IDRefsIterator();
|
|
|
|
IDRefsIterator(const IDRefsIterator&);
|
|
|
|
IDRefsIterator operator = (const IDRefsIterator&);
|
|
|
|
|
|
|
|
nsString mIDs;
|
2012-03-13 20:06:21 +04:00
|
|
|
nsIContent* mContent;
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* mDoc;
|
2011-08-10 05:44:00 +04:00
|
|
|
nsAString::index_type mCurrIdx;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Iterator that points to a single accessible returning it on the first call
|
|
|
|
* to Next().
|
|
|
|
*/
|
|
|
|
class SingleAccIterator : public AccIterable
|
|
|
|
{
|
|
|
|
public:
|
2014-09-02 20:19:58 +04:00
|
|
|
explicit SingleAccIterator(Accessible* aTarget): mAcc(aTarget) { }
|
2011-08-10 05:44:00 +04:00
|
|
|
virtual ~SingleAccIterator() { }
|
|
|
|
|
2015-01-15 23:39:04 +03:00
|
|
|
virtual Accessible* Next() MOZ_OVERRIDE;
|
2011-08-10 05:44:00 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
SingleAccIterator();
|
|
|
|
SingleAccIterator(const SingleAccIterator&);
|
|
|
|
SingleAccIterator& operator = (const SingleAccIterator&);
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
nsRefPtr<Accessible> mAcc;
|
2011-08-10 05:44:00 +04:00
|
|
|
};
|
|
|
|
|
2013-02-26 11:17:10 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to iterate items of the given item container.
|
|
|
|
*/
|
|
|
|
class ItemIterator : public AccIterable
|
|
|
|
{
|
|
|
|
public:
|
2014-09-02 20:19:58 +04:00
|
|
|
explicit ItemIterator(Accessible* aItemContainer) :
|
2013-02-26 11:17:10 +04:00
|
|
|
mContainer(aItemContainer), mAnchor(nullptr) { }
|
|
|
|
virtual ~ItemIterator() { }
|
|
|
|
|
2015-01-15 23:39:04 +03:00
|
|
|
virtual Accessible* Next() MOZ_OVERRIDE;
|
2013-02-26 11:17:10 +04:00
|
|
|
|
|
|
|
private:
|
2015-01-07 02:35:02 +03:00
|
|
|
ItemIterator() = delete;
|
|
|
|
ItemIterator(const ItemIterator&) = delete;
|
|
|
|
ItemIterator& operator = (const ItemIterator&) = delete;
|
2013-02-26 11:17:10 +04:00
|
|
|
|
|
|
|
Accessible* mContainer;
|
|
|
|
Accessible* mAnchor;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to iterate through XUL tree items of the same level.
|
|
|
|
*/
|
|
|
|
class XULTreeItemIterator : public AccIterable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
XULTreeItemIterator(XULTreeAccessible* aXULTree, nsITreeView* aTreeView,
|
|
|
|
int32_t aRowIdx);
|
|
|
|
virtual ~XULTreeItemIterator() { }
|
|
|
|
|
2015-01-15 23:39:04 +03:00
|
|
|
virtual Accessible* Next() MOZ_OVERRIDE;
|
2013-02-26 11:17:10 +04:00
|
|
|
|
|
|
|
private:
|
2015-01-07 02:35:02 +03:00
|
|
|
XULTreeItemIterator() = delete;
|
|
|
|
XULTreeItemIterator(const XULTreeItemIterator&) = delete;
|
|
|
|
XULTreeItemIterator& operator = (const XULTreeItemIterator&) = delete;
|
2013-02-26 11:17:10 +04:00
|
|
|
|
|
|
|
XULTreeAccessible* mXULTree;
|
|
|
|
nsITreeView* mTreeView;
|
|
|
|
int32_t mRowCount;
|
|
|
|
int32_t mContainerLevel;
|
|
|
|
int32_t mCurrRowIdx;
|
|
|
|
};
|
|
|
|
|
2012-08-28 17:13:59 +04:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2010-05-20 11:40:25 +04:00
|
|
|
#endif
|