2010-02-21 00:55:04 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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-02-21 00:55:04 +00:00
|
|
|
|
2012-11-19 09:20:09 +00:00
|
|
|
#ifndef mozilla_a11y_TreeWalker_h_
|
|
|
|
#define mozilla_a11y_TreeWalker_h_
|
2010-02-21 00:55:04 +00:00
|
|
|
|
2014-02-15 15:21:40 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-09-10 22:18:59 +00:00
|
|
|
#include <stdint.h>
|
2013-03-22 00:05:20 +00:00
|
|
|
|
|
|
|
class nsIContent;
|
2010-02-21 00:55:04 +00:00
|
|
|
|
2012-11-18 02:01:44 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
class Accessible;
|
2012-05-27 09:01:40 +00:00
|
|
|
class DocAccessible;
|
2012-11-18 02:01:44 +00:00
|
|
|
|
2010-02-21 00:55:04 +00:00
|
|
|
struct WalkState;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class is used to walk the DOM tree to create accessible tree.
|
|
|
|
*/
|
2014-02-15 15:21:40 +00:00
|
|
|
class TreeWalker MOZ_FINAL
|
2010-02-21 00:55:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-02-15 15:21:40 +00: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-21 00:55:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the next child accessible.
|
2011-03-31 09:30:58 +00: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-21 00:55:04 +00:00
|
|
|
*/
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* NextChild()
|
2010-02-21 00:55:04 +00:00
|
|
|
{
|
2011-03-31 09:30:58 +00:00
|
|
|
return NextChildInternal(false);
|
2010-02-21 00:55:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-11-19 09:20:09 +00:00
|
|
|
TreeWalker();
|
|
|
|
TreeWalker(const TreeWalker&);
|
|
|
|
TreeWalker& operator =(const TreeWalker&);
|
2010-02-21 00:55:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the next child accessible.
|
|
|
|
*
|
|
|
|
* @param aNoWalkUp [in] specifies the walk direction, true means we
|
|
|
|
* shouldn't go up through the tree if we failed find
|
|
|
|
* accessible children.
|
|
|
|
*/
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* NextChildInternal(bool aNoWalkUp);
|
2010-02-21 00:55:04 +00: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-02-15 15:21:40 +00:00
|
|
|
void PushState(nsIContent* aNode);
|
2010-02-21 00:55:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Pop state from stack.
|
|
|
|
*/
|
|
|
|
void PopState();
|
|
|
|
|
2012-05-27 09:01:40 +00:00
|
|
|
DocAccessible* mDoc;
|
2012-11-17 15:27:03 +00:00
|
|
|
Accessible* mContext;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mChildFilter;
|
2014-02-15 15:21:40 +00:00
|
|
|
uint32_t mFlags;
|
2010-02-21 00:55:04 +00:00
|
|
|
WalkState* mState;
|
|
|
|
};
|
|
|
|
|
2012-11-19 09:20:09 +00:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_a11y_TreeWalker_h_
|