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"
21 * Class represents an accessible pivot.
23 class nsAccessiblePivot MOZ_FINAL
: public nsIAccessiblePivot
26 typedef mozilla::a11y::Accessible Accessible
;
28 explicit nsAccessiblePivot(Accessible
* aRoot
);
30 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
31 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsAccessiblePivot
, nsIAccessiblePivot
)
33 NS_DECL_NSIACCESSIBLEPIVOT
36 * A simple getter for the pivot's position.
38 Accessible
* Position() { return mPosition
; }
42 nsAccessiblePivot() = delete;
43 nsAccessiblePivot(const nsAccessiblePivot
&) = delete;
44 void operator = (const nsAccessiblePivot
&) = delete;
47 * Notify all observers on a pivot change. Return true if it has changed and
48 * observers have been notified.
50 bool NotifyOfPivotChange(Accessible
* aOldAccessible
,
51 int32_t aOldStart
, int32_t aOldEnd
,
52 PivotMoveReason aReason
,
53 bool aIsFromUserInput
);
56 * Check to see that the given accessible is a descendant of given ancestor
58 bool IsDescendantOf(Accessible
* aAccessible
, Accessible
* aAncestor
);
62 * Search in preorder for the first accessible to match the rule.
64 Accessible
* SearchForward(Accessible
* aAccessible
,
65 nsIAccessibleTraversalRule
* aRule
,
70 * Reverse search in preorder for the first accessible to match the rule.
72 Accessible
* SearchBackward(Accessible
* aAccessible
,
73 nsIAccessibleTraversalRule
* aRule
,
78 * Search in preorder for the first text accessible.
80 mozilla::a11y::HyperTextAccessible
* SearchForText(Accessible
* aAccessible
,
84 * Get the effective root for this pivot, either the true root or modal root.
86 Accessible
* GetActiveRoot() const
89 NS_ENSURE_FALSE(mModalRoot
->IsDefunct(), mRoot
);
97 * Update the pivot, and notify observers. Return true if it moved.
99 bool MovePivotInternal(Accessible
* aPosition
, PivotMoveReason aReason
,
100 bool aIsFromUserInput
);
103 * Get initial node we should start a search from with a given rule.
105 * When we do a move operation from one position to another,
106 * the initial position can be inside of a subtree that is ignored by
107 * the given rule. We need to step out of the ignored subtree and start
108 * the search from there.
111 Accessible
* AdjustStartPosition(Accessible
* aAccessible
, RuleCache
& aCache
,
112 uint16_t* aFilterResult
, nsresult
* aResult
);
115 * The root accessible.
117 nsRefPtr
<Accessible
> mRoot
;
120 * The temporary modal root accessible.
122 nsRefPtr
<Accessible
> mModalRoot
;
125 * The current pivot position.
127 nsRefPtr
<Accessible
> mPosition
;
130 * The text start offset ofthe pivot.
132 int32_t mStartOffset
;
135 * The text end offset ofthe pivot.
140 * The list of pivot-changed observers.
142 nsTObserverArray
<nsCOMPtr
<nsIAccessiblePivotObserver
> > mObservers
;