1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Aaron Leventhal (aaronl@netscape.com)
24 : * Kyle Yuan (kyle.yuan@sun.com)
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 : #ifndef __nsHTMLSelectAccessible_h__
40 : #define __nsHTMLSelectAccessible_h__
41 :
42 : #include "nsHTMLFormControlAccessible.h"
43 : #include "nsIDOMHTMLOptionsCollection.h"
44 : #include "nsIDOMHTMLOptionElement.h"
45 : #include "nsIDOMNode.h"
46 :
47 : class nsIMutableArray;
48 :
49 : /**
50 : * Selects, Listboxes and Comboboxes, are made up of a number of different
51 : * widgets, some of which are shared between the two. This file contains
52 : * all of the widgets for both of the Selects, for HTML only.
53 : *
54 : * Listbox:
55 : * - nsHTMLSelectListAccessible
56 : * - nsHTMLSelectOptionAccessible
57 : *
58 : * Comboboxes:
59 : * - nsHTMLComboboxAccessible
60 : * - nsHTMLComboboxListAccessible [ inserted in accessible tree ]
61 : * - nsHTMLSelectOptionAccessible(s)
62 : */
63 :
64 : /*
65 : * The list that contains all the options in the select.
66 : */
67 : class nsHTMLSelectListAccessible : public nsAccessibleWrap
68 : {
69 : public:
70 :
71 : nsHTMLSelectListAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
72 0 : virtual ~nsHTMLSelectListAccessible() {}
73 :
74 : // nsAccessible
75 : virtual mozilla::a11y::role NativeRole();
76 : virtual PRUint64 NativeState();
77 :
78 : // SelectAccessible
79 : virtual bool IsSelect();
80 : virtual bool SelectAll();
81 : virtual bool UnselectAll();
82 :
83 : // Widgets
84 : virtual bool IsWidget() const;
85 : virtual bool IsActiveWidget() const;
86 : virtual bool AreItemsOperable() const;
87 : virtual nsAccessible* CurrentItem();
88 : virtual void SetCurrentItem(nsAccessible* aItem);
89 :
90 : protected:
91 :
92 : // nsAccessible
93 : virtual void CacheChildren();
94 :
95 : // nsHTMLSelectListAccessible
96 :
97 : /**
98 : * Recursive helper for CacheChildren().
99 : */
100 : void CacheOptSiblings(nsIContent *aParentContent);
101 : };
102 :
103 : /*
104 : * Options inside the select, contained within the list
105 : */
106 : class nsHTMLSelectOptionAccessible : public nsHyperTextAccessibleWrap
107 : {
108 : public:
109 : enum { eAction_Select = 0 };
110 :
111 : nsHTMLSelectOptionAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
112 0 : virtual ~nsHTMLSelectOptionAccessible() {}
113 :
114 : // nsIAccessible
115 : NS_IMETHOD DoAction(PRUint8 index);
116 : NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
117 : NS_IMETHOD SetSelected(bool aSelect);
118 :
119 : // nsAccessible
120 : virtual nsresult GetNameInternal(nsAString& aName);
121 : virtual mozilla::a11y::role NativeRole();
122 : virtual PRUint64 NativeState();
123 :
124 : virtual PRInt32 GetLevelInternal();
125 : virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet,
126 : PRInt32 *aSetSize);
127 :
128 : // ActionAccessible
129 : virtual PRUint8 ActionCount();
130 :
131 : // Widgets
132 : virtual nsAccessible* ContainerWidget() const;
133 :
134 : protected:
135 : // nsAccessible
136 : virtual nsIFrame* GetBoundsFrame();
137 :
138 : private:
139 :
140 : /**
141 : * Get Select element's accessible state
142 : * @param aState, Select element state
143 : * @return Select element content, returns null if not avaliable
144 : */
145 : nsIContent* GetSelectState(PRUint64* aState);
146 : };
147 :
148 : /*
149 : * Opt Groups inside the select, contained within the list
150 : */
151 : class nsHTMLSelectOptGroupAccessible : public nsHTMLSelectOptionAccessible
152 : {
153 : public:
154 :
155 : nsHTMLSelectOptGroupAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
156 0 : virtual ~nsHTMLSelectOptGroupAccessible() {}
157 :
158 : // nsIAccessible
159 : NS_IMETHOD DoAction(PRUint8 index);
160 : NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
161 :
162 : // nsAccessible
163 : virtual mozilla::a11y::role NativeRole();
164 : virtual PRUint64 NativeState();
165 :
166 : // ActionAccessible
167 : virtual PRUint8 ActionCount();
168 :
169 : protected:
170 : // nsAccessible
171 : virtual void CacheChildren();
172 : };
173 :
174 : /** ------------------------------------------------------ */
175 : /** Finally, the Combobox widgets */
176 : /** ------------------------------------------------------ */
177 :
178 : class nsHTMLComboboxListAccessible;
179 :
180 : /*
181 : * A class the represents the HTML Combobox widget.
182 : */
183 : class nsHTMLComboboxAccessible : public nsAccessibleWrap
184 : {
185 : public:
186 : enum { eAction_Click = 0 };
187 :
188 : nsHTMLComboboxAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
189 0 : virtual ~nsHTMLComboboxAccessible() {}
190 :
191 : // nsIAccessible
192 : NS_IMETHOD GetValue(nsAString& _retval);
193 : NS_IMETHOD DoAction(PRUint8 index);
194 : NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
195 :
196 : // nsAccessNode
197 : virtual void Shutdown();
198 :
199 : // nsAccessible
200 : virtual void Description(nsString& aDescription);
201 : virtual mozilla::a11y::role NativeRole();
202 : virtual PRUint64 NativeState();
203 : virtual void InvalidateChildren();
204 :
205 : // ActionAccessible
206 : virtual PRUint8 ActionCount();
207 :
208 : // Widgets
209 : virtual bool IsWidget() const;
210 : virtual bool IsActiveWidget() const;
211 : virtual bool AreItemsOperable() const;
212 : virtual nsAccessible* CurrentItem();
213 : virtual void SetCurrentItem(nsAccessible* aItem);
214 :
215 : protected:
216 : // nsAccessible
217 : virtual void CacheChildren();
218 :
219 : /**
220 : * Return selected option.
221 : */
222 : nsAccessible* SelectedOption() const;
223 :
224 : private:
225 : nsRefPtr<nsHTMLComboboxListAccessible> mListAccessible;
226 : };
227 :
228 : /*
229 : * A class that represents the window that lives to the right
230 : * of the drop down button inside the Select. This is the window
231 : * that is made visible when the button is pressed.
232 : */
233 : class nsHTMLComboboxListAccessible : public nsHTMLSelectListAccessible
234 : {
235 : public:
236 :
237 : nsHTMLComboboxListAccessible(nsIAccessible* aParent,
238 : nsIContent* aContent,
239 : nsDocAccessible* aDoc);
240 0 : virtual ~nsHTMLComboboxListAccessible() {}
241 :
242 : // nsAccessNode
243 : virtual nsIFrame* GetFrame() const;
244 : virtual bool IsPrimaryForNode() const;
245 :
246 : // nsAccessible
247 : virtual PRUint64 NativeState();
248 : virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
249 :
250 : // Widgets
251 : virtual bool IsActiveWidget() const;
252 : virtual bool AreItemsOperable() const;
253 : };
254 :
255 : #endif
|