accessible/src/base/TreeWalker.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:47f6e2da7799
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/. */
5
6 #ifndef mozilla_a11y_TreeWalker_h_
7 #define mozilla_a11y_TreeWalker_h_
8
9 #include "mozilla/Attributes.h"
10 #include <stdint.h>
11
12 class nsIContent;
13
14 namespace mozilla {
15 namespace a11y {
16
17 class Accessible;
18 class DocAccessible;
19
20 struct WalkState;
21
22 /**
23 * This class is used to walk the DOM tree to create accessible tree.
24 */
25 class TreeWalker MOZ_FINAL
26 {
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
33 };
34
35 /**
36 * Constructor
37 *
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)
42 */
43 TreeWalker(Accessible* aContext, nsIContent* aNode, uint32_t aFlags = 0);
44 ~TreeWalker();
45
46 /**
47 * Return the next child accessible.
48 *
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.
52 */
53 Accessible* NextChild()
54 {
55 return NextChildInternal(false);
56 }
57
58 private:
59 TreeWalker();
60 TreeWalker(const TreeWalker&);
61 TreeWalker& operator =(const TreeWalker&);
62
63 /**
64 * Return the next child accessible.
65 *
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.
69 */
70 Accessible* NextChildInternal(bool aNoWalkUp);
71
72 /**
73 * Create new state for the given node and push it on top of stack.
74 *
75 * @note State stack is used to navigate up/down the DOM subtree during
76 * accessible children search.
77 */
78 void PushState(nsIContent* aNode);
79
80 /**
81 * Pop state from stack.
82 */
83 void PopState();
84
85 DocAccessible* mDoc;
86 Accessible* mContext;
87 int32_t mChildFilter;
88 uint32_t mFlags;
89 WalkState* mState;
90 };
91
92 } // namespace a11y
93 } // namespace mozilla
94
95 #endif // mozilla_a11y_TreeWalker_h_

mercurial