|
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 "nsAutoPtr.h" |
|
14 #include "nsTObserverArray.h" |
|
15 #include "nsCycleCollectionParticipant.h" |
|
16 #include "mozilla/Attributes.h" |
|
17 |
|
18 class RuleCache; |
|
19 |
|
20 /** |
|
21 * Class represents an accessible pivot. |
|
22 */ |
|
23 class nsAccessiblePivot MOZ_FINAL : public nsIAccessiblePivot |
|
24 { |
|
25 public: |
|
26 typedef mozilla::a11y::Accessible Accessible; |
|
27 |
|
28 nsAccessiblePivot(Accessible* aRoot); |
|
29 |
|
30 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
31 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsAccessiblePivot, nsIAccessiblePivot) |
|
32 |
|
33 NS_DECL_NSIACCESSIBLEPIVOT |
|
34 |
|
35 /* |
|
36 * A simple getter for the pivot's position. |
|
37 */ |
|
38 Accessible* Position() { return mPosition; } |
|
39 |
|
40 private: |
|
41 nsAccessiblePivot() MOZ_DELETE; |
|
42 nsAccessiblePivot(const nsAccessiblePivot&) MOZ_DELETE; |
|
43 void operator = (const nsAccessiblePivot&) MOZ_DELETE; |
|
44 |
|
45 /* |
|
46 * Notify all observers on a pivot change. Return true if it has changed and |
|
47 * observers have been notified. |
|
48 */ |
|
49 bool NotifyOfPivotChange(Accessible* aOldAccessible, |
|
50 int32_t aOldStart, int32_t aOldEnd, |
|
51 PivotMoveReason aReason); |
|
52 |
|
53 /* |
|
54 * Check to see that the given accessible is a descendant of given ancestor |
|
55 */ |
|
56 bool IsDescendantOf(Accessible* aAccessible, Accessible* aAncestor); |
|
57 |
|
58 |
|
59 /* |
|
60 * Search in preorder for the first accessible to match the rule. |
|
61 */ |
|
62 Accessible* SearchForward(Accessible* aAccessible, |
|
63 nsIAccessibleTraversalRule* aRule, |
|
64 bool aSearchCurrent, |
|
65 nsresult* aResult); |
|
66 |
|
67 /* |
|
68 * Reverse search in preorder for the first accessible to match the rule. |
|
69 */ |
|
70 Accessible* SearchBackward(Accessible* aAccessible, |
|
71 nsIAccessibleTraversalRule* aRule, |
|
72 bool aSearchCurrent, |
|
73 nsresult* aResult); |
|
74 |
|
75 /* |
|
76 * Search in preorder for the first text accessible. |
|
77 */ |
|
78 mozilla::a11y::HyperTextAccessible* SearchForText(Accessible* aAccessible, |
|
79 bool aBackward); |
|
80 |
|
81 /* |
|
82 * Get the effective root for this pivot, either the true root or modal root. |
|
83 */ |
|
84 Accessible* GetActiveRoot() const |
|
85 { |
|
86 if (mModalRoot) { |
|
87 NS_ENSURE_FALSE(mModalRoot->IsDefunct(), mRoot); |
|
88 return mModalRoot; |
|
89 } |
|
90 |
|
91 return mRoot; |
|
92 } |
|
93 |
|
94 /* |
|
95 * Update the pivot, and notify observers. Return true if it moved. |
|
96 */ |
|
97 bool MovePivotInternal(Accessible* aPosition, PivotMoveReason aReason); |
|
98 |
|
99 /* |
|
100 * Get initial node we should start a search from with a given rule. |
|
101 * |
|
102 * When we do a move operation from one position to another, |
|
103 * the initial position can be inside of a subtree that is ignored by |
|
104 * the given rule. We need to step out of the ignored subtree and start |
|
105 * the search from there. |
|
106 * |
|
107 */ |
|
108 Accessible* AdjustStartPosition(Accessible* aAccessible, RuleCache& aCache, |
|
109 uint16_t* aFilterResult, nsresult* aResult); |
|
110 |
|
111 /* |
|
112 * The root accessible. |
|
113 */ |
|
114 nsRefPtr<Accessible> mRoot; |
|
115 |
|
116 /* |
|
117 * The temporary modal root accessible. |
|
118 */ |
|
119 nsRefPtr<Accessible> mModalRoot; |
|
120 |
|
121 /* |
|
122 * The current pivot position. |
|
123 */ |
|
124 nsRefPtr<Accessible> mPosition; |
|
125 |
|
126 /* |
|
127 * The text start offset ofthe pivot. |
|
128 */ |
|
129 int32_t mStartOffset; |
|
130 |
|
131 /* |
|
132 * The text end offset ofthe pivot. |
|
133 */ |
|
134 int32_t mEndOffset; |
|
135 |
|
136 /* |
|
137 * The list of pivot-changed observers. |
|
138 */ |
|
139 nsTObserverArray<nsCOMPtr<nsIAccessiblePivotObserver> > mObservers; |
|
140 }; |
|
141 |
|
142 #endif |