Bumping manifests a=b2g-bump
[gecko.git] / accessible / base / TreeWalker.h
blobaa993b1679b59c26042af9ccdcd19939330a949a
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_a11y_TreeWalker_h_
7 #define mozilla_a11y_TreeWalker_h_
9 #include "mozilla/Attributes.h"
10 #include <stdint.h>
12 class nsIContent;
14 namespace mozilla {
15 namespace a11y {
17 class Accessible;
18 class DocAccessible;
20 struct WalkState;
22 /**
23 * This class is used to walk the DOM tree to create accessible tree.
25 class TreeWalker MOZ_FINAL
27 public:
28 enum {
29 // used to walk the existing tree of the given node
30 eWalkCache = 1,
31 // used to walk the context tree starting from given node
32 eWalkContextTree = 2 | eWalkCache
35 /**
36 * Constructor
38 * @param aContext [in] container accessible for the given node, used to
39 * define accessible context
40 * @param aNode [in] the node the search will be prepared relative to
41 * @param aFlags [in] flags (see enum above)
43 TreeWalker(Accessible* aContext, nsIContent* aNode, uint32_t aFlags = 0);
44 ~TreeWalker();
46 /**
47 * Return the next child accessible.
49 * @note Returned accessible is bound to the document, if the accessible is
50 * rejected during tree creation then the caller should be unbind it
51 * from the document.
53 Accessible* NextChild()
55 return NextChildInternal(false);
58 private:
59 TreeWalker();
60 TreeWalker(const TreeWalker&);
61 TreeWalker& operator =(const TreeWalker&);
63 /**
64 * Return the next child accessible.
66 * @param aNoWalkUp [in] specifies the walk direction, true means we
67 * shouldn't go up through the tree if we failed find
68 * accessible children.
70 Accessible* NextChildInternal(bool aNoWalkUp);
72 /**
73 * Create new state for the given node and push it on top of stack.
75 * @note State stack is used to navigate up/down the DOM subtree during
76 * accessible children search.
78 void PushState(nsIContent* aNode);
80 /**
81 * Pop state from stack.
83 void PopState();
85 DocAccessible* mDoc;
86 Accessible* mContext;
87 int32_t mChildFilter;
88 uint32_t mFlags;
89 WalkState* mState;
92 } // namespace a11y
93 } // namespace mozilla
95 #endif // mozilla_a11y_TreeWalker_h_