2010-02-20 16:55:04 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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-02-20 16:55:04 -08:00
|
|
|
|
2012-11-19 01:20:09 -08:00
|
|
|
#ifndef mozilla_a11y_TreeWalker_h_
|
|
|
|
#define mozilla_a11y_TreeWalker_h_
|
2010-02-20 16:55:04 -08:00
|
|
|
|
2014-02-15 07:21:40 -08:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-09-10 15:18:59 -07:00
|
|
|
#include <stdint.h>
|
2014-08-11 23:02:28 -07:00
|
|
|
#include "mozilla/dom/ChildIterator.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2013-03-21 17:05:20 -07:00
|
|
|
|
|
|
|
class nsIContent;
|
2010-02-20 16:55:04 -08:00
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
class Accessible;
|
2012-05-27 02:01:40 -07:00
|
|
|
class DocAccessible;
|
2012-11-17 18:01:44 -08:00
|
|
|
|
2010-02-20 16:55:04 -08:00
|
|
|
/**
|
|
|
|
* This class is used to walk the DOM tree to create accessible tree.
|
|
|
|
*/
|
2014-02-15 07:21:40 -08:00
|
|
|
class TreeWalker MOZ_FINAL
|
2010-02-20 16:55:04 -08:00
|
|
|
{
|
|
|
|
public:
|
2014-02-15 07:21:40 -08:00
|
|
|
enum {
|
|
|
|
// used to walk the existing tree of the given node
|
|
|
|
eWalkCache = 1,
|
|
|
|
// used to walk the context tree starting from given node
|
|
|
|
eWalkContextTree = 2 | eWalkCache
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param aContext [in] container accessible for the given node, used to
|
|
|
|
* define accessible context
|
|
|
|
* @param aNode [in] the node the search will be prepared relative to
|
|
|
|
* @param aFlags [in] flags (see enum above)
|
|
|
|
*/
|
|
|
|
TreeWalker(Accessible* aContext, nsIContent* aNode, uint32_t aFlags = 0);
|
|
|
|
~TreeWalker();
|
2010-02-20 16:55:04 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the next child accessible.
|
2011-03-31 02:30:58 -07:00
|
|
|
*
|
|
|
|
* @note Returned accessible is bound to the document, if the accessible is
|
|
|
|
* rejected during tree creation then the caller should be unbind it
|
|
|
|
* from the document.
|
2010-02-20 16:55:04 -08:00
|
|
|
*/
|
2014-08-11 23:02:28 -07:00
|
|
|
Accessible* NextChild();
|
2010-02-20 16:55:04 -08:00
|
|
|
|
|
|
|
private:
|
2012-11-19 01:20:09 -08:00
|
|
|
TreeWalker();
|
|
|
|
TreeWalker(const TreeWalker&);
|
|
|
|
TreeWalker& operator =(const TreeWalker&);
|
2010-02-20 16:55:04 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create new state for the given node and push it on top of stack.
|
|
|
|
*
|
|
|
|
* @note State stack is used to navigate up/down the DOM subtree during
|
|
|
|
* accessible children search.
|
|
|
|
*/
|
2014-08-11 23:02:28 -07:00
|
|
|
dom::AllChildrenIterator* PushState(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
return mStateStack.AppendElement(dom::AllChildrenIterator(aContent,
|
|
|
|
mChildFilter));
|
|
|
|
}
|
2010-02-20 16:55:04 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Pop state from stack.
|
|
|
|
*/
|
2014-08-11 23:02:28 -07:00
|
|
|
dom::AllChildrenIterator* PopState();
|
2010-02-20 16:55:04 -08:00
|
|
|
|
2012-05-27 02:01:40 -07:00
|
|
|
DocAccessible* mDoc;
|
2012-11-17 07:27:03 -08:00
|
|
|
Accessible* mContext;
|
2014-08-11 23:02:28 -07:00
|
|
|
nsIContent* mAnchorNode;
|
|
|
|
nsAutoTArray<dom::AllChildrenIterator, 20> mStateStack;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mChildFilter;
|
2014-02-15 07:21:40 -08:00
|
|
|
uint32_t mFlags;
|
2010-02-20 16:55:04 -08:00
|
|
|
};
|
|
|
|
|
2012-11-19 01:20:09 -08:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_a11y_TreeWalker_h_
|