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 : /* ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is mozilla.org code.
17 : *
18 : * The Initial Developer of the Original Code is
19 : * Mozilla Foundation.
20 : * Portions created by the Initial Developer are Copyright (C) 2011
21 : * the Initial Developer. All Rights Reserved.
22 : *
23 : * Contributor(s):
24 : * Eitan Isaacson <eitan@monotonous.org> (original author)
25 : *
26 : * Alternatively, the contents of this file may be used under the terms of
27 : * either of the GNU General Public License Version 2 or later (the "GPL"),
28 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 : * in which case the provisions of the GPL or the LGPL are applicable instead
30 : * of those above. If you wish to allow use of your version of this file only
31 : * under the terms of either the GPL or the LGPL, and not to allow others to
32 : * use your version of this file under the terms of the MPL, indicate your
33 : * decision by deleting the provisions above and replace them with the notice
34 : * and other provisions required by the GPL or the LGPL. If you do not delete
35 : * the provisions above, a recipient may use your version of this file under
36 : * the terms of any one of the MPL, the GPL or the LGPL.
37 : *
38 : * ***** END LICENSE BLOCK ***** */
39 :
40 : #ifndef _nsAccessiblePivot_H_
41 : #define _nsAccessiblePivot_H_
42 :
43 : #include "nsIAccessiblePivot.h"
44 :
45 : #include "nsAutoPtr.h"
46 : #include "nsTObserverArray.h"
47 : #include "nsCycleCollectionParticipant.h"
48 :
49 : class nsAccessible;
50 : class nsIAccessibleTraversalRule;
51 :
52 : /**
53 : * Class represents an accessible pivot.
54 : */
55 : class nsAccessiblePivot: public nsIAccessiblePivot
56 0 : {
57 : public:
58 : nsAccessiblePivot(nsAccessible* aRoot);
59 :
60 0 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
61 1464 : NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsAccessiblePivot, nsIAccessiblePivot)
62 :
63 : NS_DECL_NSIACCESSIBLEPIVOT
64 :
65 : /*
66 : * A simple getter for the pivot's position.
67 : */
68 : nsAccessible* Position() { return mPosition; }
69 :
70 : private:
71 : nsAccessiblePivot() MOZ_DELETE;
72 : nsAccessiblePivot(const nsAccessiblePivot&) MOZ_DELETE;
73 : void operator = (const nsAccessiblePivot&) MOZ_DELETE;
74 :
75 : /*
76 : * Notify all observers on a pivot change.
77 : */
78 : void NotifyPivotChanged(nsAccessible* aOldAccessible,
79 : PRInt32 aOldStart, PRInt32 aOldEnd);
80 :
81 : /*
82 : * Check to see that the given accessible is in the pivot's subtree.
83 : */
84 : bool IsRootDescendant(nsAccessible* aAccessible);
85 :
86 :
87 : /*
88 : * Search in preorder for the first accessible to match the rule.
89 : */
90 : nsAccessible* SearchForward(nsAccessible* aAccessible,
91 : nsIAccessibleTraversalRule* aRule,
92 : bool searchCurrent,
93 : nsresult* rv);
94 :
95 : /*
96 : * Reverse search in preorder for the first accessible to match the rule.
97 : */
98 : nsAccessible* SearchBackward(nsAccessible* aAccessible,
99 : nsIAccessibleTraversalRule* aRule,
100 : bool searchCurrent,
101 : nsresult* rv);
102 :
103 : /*
104 : * Update the pivot, and notify observers.
105 : */
106 : void MovePivotInternal(nsAccessible* aPosition);
107 :
108 : /*
109 : * The root accessible.
110 : */
111 : nsRefPtr<nsAccessible> mRoot;
112 :
113 : /*
114 : * The current pivot position.
115 : */
116 : nsRefPtr<nsAccessible> mPosition;
117 :
118 : /*
119 : * The text start offset ofthe pivot.
120 : */
121 : PRInt32 mStartOffset;
122 :
123 : /*
124 : * The text end offset ofthe pivot.
125 : */
126 : PRInt32 mEndOffset;
127 :
128 : /*
129 : * The list of pivot-changed observers.
130 : */
131 : nsTObserverArray<nsCOMPtr<nsIAccessiblePivotObserver> > mObservers;
132 : };
133 :
134 : #endif
|