/src/mozilla-central/accessible/base/nsAccessiblePivot.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef _nsAccessiblePivot_H_ |
8 | | #define _nsAccessiblePivot_H_ |
9 | | |
10 | | #include "nsIAccessiblePivot.h" |
11 | | |
12 | | #include "Accessible-inl.h" |
13 | | #include "nsTObserverArray.h" |
14 | | #include "nsCycleCollectionParticipant.h" |
15 | | #include "mozilla/Attributes.h" |
16 | | |
17 | | class RuleCache; |
18 | | |
19 | | /** |
20 | | * Class represents an accessible pivot. |
21 | | */ |
22 | | class nsAccessiblePivot final : public nsIAccessiblePivot |
23 | | { |
24 | | public: |
25 | | typedef mozilla::a11y::Accessible Accessible; |
26 | | |
27 | | explicit nsAccessiblePivot(Accessible* aRoot); |
28 | | |
29 | | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
30 | | NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsAccessiblePivot, nsIAccessiblePivot) |
31 | | |
32 | | NS_DECL_NSIACCESSIBLEPIVOT |
33 | | |
34 | | /* |
35 | | * A simple getter for the pivot's position. |
36 | | */ |
37 | 0 | Accessible* Position() { return mPosition; } |
38 | | |
39 | 0 | int32_t StartOffset() { return mStartOffset; } |
40 | | |
41 | 0 | int32_t EndOffset() { return mEndOffset; } |
42 | | |
43 | | private: |
44 | | ~nsAccessiblePivot(); |
45 | | nsAccessiblePivot() = delete; |
46 | | nsAccessiblePivot(const nsAccessiblePivot&) = delete; |
47 | | void operator = (const nsAccessiblePivot&) = delete; |
48 | | |
49 | | /* |
50 | | * Notify all observers on a pivot change. Return true if it has changed and |
51 | | * observers have been notified. |
52 | | */ |
53 | | bool NotifyOfPivotChange(Accessible* aOldAccessible, |
54 | | int32_t aOldStart, int32_t aOldEnd, |
55 | | PivotMoveReason aReason, |
56 | | TextBoundaryType aBoundaryType, |
57 | | bool aIsFromUserInput); |
58 | | |
59 | | /* |
60 | | * Check to see that the given accessible is a descendant of given ancestor |
61 | | */ |
62 | | bool IsDescendantOf(Accessible* aAccessible, Accessible* aAncestor); |
63 | | |
64 | | |
65 | | /* |
66 | | * Search in preorder for the first accessible to match the rule. |
67 | | */ |
68 | | Accessible* SearchForward(Accessible* aAccessible, |
69 | | nsIAccessibleTraversalRule* aRule, |
70 | | bool aSearchCurrent, |
71 | | nsresult* aResult); |
72 | | |
73 | | /* |
74 | | * Reverse search in preorder for the first accessible to match the rule. |
75 | | */ |
76 | | Accessible* SearchBackward(Accessible* aAccessible, |
77 | | nsIAccessibleTraversalRule* aRule, |
78 | | bool aSearchCurrent, |
79 | | nsresult* aResult); |
80 | | |
81 | | /* |
82 | | * Search in preorder for the first text accessible. |
83 | | */ |
84 | | mozilla::a11y::HyperTextAccessible* SearchForText(Accessible* aAccessible, |
85 | | bool aBackward); |
86 | | |
87 | | /* |
88 | | * Get the effective root for this pivot, either the true root or modal root. |
89 | | */ |
90 | | Accessible* GetActiveRoot() const |
91 | 0 | { |
92 | 0 | if (mModalRoot) { |
93 | 0 | NS_ENSURE_FALSE(mModalRoot->IsDefunct(), mRoot); |
94 | 0 | return mModalRoot; |
95 | 0 | } |
96 | 0 | |
97 | 0 | return mRoot; |
98 | 0 | } |
99 | | |
100 | | /* |
101 | | * Update the pivot, and notify observers. Return true if it moved. |
102 | | */ |
103 | | bool MovePivotInternal(Accessible* aPosition, PivotMoveReason aReason, |
104 | | bool aIsFromUserInput); |
105 | | |
106 | | /* |
107 | | * Get initial node we should start a search from with a given rule. |
108 | | * |
109 | | * When we do a move operation from one position to another, |
110 | | * the initial position can be inside of a subtree that is ignored by |
111 | | * the given rule. We need to step out of the ignored subtree and start |
112 | | * the search from there. |
113 | | * |
114 | | */ |
115 | | Accessible* AdjustStartPosition(Accessible* aAccessible, RuleCache& aCache, |
116 | | uint16_t* aFilterResult, nsresult* aResult); |
117 | | |
118 | | /* |
119 | | * The root accessible. |
120 | | */ |
121 | | RefPtr<Accessible> mRoot; |
122 | | |
123 | | /* |
124 | | * The temporary modal root accessible. |
125 | | */ |
126 | | RefPtr<Accessible> mModalRoot; |
127 | | |
128 | | /* |
129 | | * The current pivot position. |
130 | | */ |
131 | | RefPtr<Accessible> mPosition; |
132 | | |
133 | | /* |
134 | | * The text start offset ofthe pivot. |
135 | | */ |
136 | | int32_t mStartOffset; |
137 | | |
138 | | /* |
139 | | * The text end offset ofthe pivot. |
140 | | */ |
141 | | int32_t mEndOffset; |
142 | | |
143 | | /* |
144 | | * The list of pivot-changed observers. |
145 | | */ |
146 | | nsTObserverArray<nsCOMPtr<nsIAccessiblePivotObserver> > mObservers; |
147 | | }; |
148 | | |
149 | | #endif |