Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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/. */
7 #ifndef _nsAccessiblePivot_H_
8 #define _nsAccessiblePivot_H_
10 #include "nsIAccessiblePivot.h"
12 #include "Accessible-inl.h"
13 #include "nsAutoPtr.h"
14 #include "nsTObserverArray.h"
15 #include "nsCycleCollectionParticipant.h"
16 #include "mozilla/Attributes.h"
18 class RuleCache;
20 /**
21 * Class represents an accessible pivot.
22 */
23 class nsAccessiblePivot MOZ_FINAL : public nsIAccessiblePivot
24 {
25 public:
26 typedef mozilla::a11y::Accessible Accessible;
28 nsAccessiblePivot(Accessible* aRoot);
30 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
31 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsAccessiblePivot, nsIAccessiblePivot)
33 NS_DECL_NSIACCESSIBLEPIVOT
35 /*
36 * A simple getter for the pivot's position.
37 */
38 Accessible* Position() { return mPosition; }
40 private:
41 nsAccessiblePivot() MOZ_DELETE;
42 nsAccessiblePivot(const nsAccessiblePivot&) MOZ_DELETE;
43 void operator = (const nsAccessiblePivot&) MOZ_DELETE;
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);
53 /*
54 * Check to see that the given accessible is a descendant of given ancestor
55 */
56 bool IsDescendantOf(Accessible* aAccessible, Accessible* aAncestor);
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);
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);
75 /*
76 * Search in preorder for the first text accessible.
77 */
78 mozilla::a11y::HyperTextAccessible* SearchForText(Accessible* aAccessible,
79 bool aBackward);
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 }
91 return mRoot;
92 }
94 /*
95 * Update the pivot, and notify observers. Return true if it moved.
96 */
97 bool MovePivotInternal(Accessible* aPosition, PivotMoveReason aReason);
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);
111 /*
112 * The root accessible.
113 */
114 nsRefPtr<Accessible> mRoot;
116 /*
117 * The temporary modal root accessible.
118 */
119 nsRefPtr<Accessible> mModalRoot;
121 /*
122 * The current pivot position.
123 */
124 nsRefPtr<Accessible> mPosition;
126 /*
127 * The text start offset ofthe pivot.
128 */
129 int32_t mStartOffset;
131 /*
132 * The text end offset ofthe pivot.
133 */
134 int32_t mEndOffset;
136 /*
137 * The list of pivot-changed observers.
138 */
139 nsTObserverArray<nsCOMPtr<nsIAccessiblePivotObserver> > mObservers;
140 };
142 #endif