1 : /* -*- Mode: C++; tab-width: 2; 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 : * Mozilla Foundation.
19 : * Portions created by the Initial Developer are Copyright (C) 2006
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Alexander Surkov <surkov.alexander@gmail.com> (original author)
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either of the GNU General Public License Version 2 or later (the "GPL"),
27 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #ifndef _nsXFormsAccessible_H_
40 : #define _nsXFormsAccessible_H_
41 :
42 : #include "nsHyperTextAccessibleWrap.h"
43 : #include "nsIXFormsUtilityService.h"
44 :
45 : #define NS_NAMESPACE_XFORMS "http://www.w3.org/2002/xforms"
46 :
47 : /**
48 : * Utility class that provides access to nsIXFormsUtilityService.
49 : */
50 : class nsXFormsAccessibleBase
51 : {
52 : public:
53 : nsXFormsAccessibleBase();
54 :
55 : protected:
56 : // Used in GetActionName() methods.
57 : enum { eAction_Click = 0 };
58 :
59 : // Service allows to get some xforms functionality.
60 : static nsIXFormsUtilityService *sXFormsService;
61 : };
62 :
63 :
64 : /**
65 : * Every XForms element that is bindable to XForms model or is able to contain
66 : * XForms hint and XForms label elements should have accessible object. This
67 : * class is base class for accessible objects for these XForms elements.
68 : */
69 : class nsXFormsAccessible : public nsHyperTextAccessibleWrap,
70 : public nsXFormsAccessibleBase
71 0 : {
72 : public:
73 : nsXFormsAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
74 :
75 : // nsIAccessible
76 :
77 : // Returns value of instance node that xforms element is bound to.
78 : NS_IMETHOD GetValue(nsAString& aValue);
79 :
80 : // nsAccessible
81 : // Returns value of child xforms 'hint' element.
82 : virtual void Description(nsString& aDescription);
83 :
84 : // Returns value of child xforms 'label' element.
85 : virtual nsresult GetNameInternal(nsAString& aName);
86 :
87 : // Returns state of xforms element taking into account state of instance node
88 : // that it is bound to.
89 : virtual PRUint64 NativeState();
90 :
91 : // Denies accessible nodes in anonymous content of xforms element by
92 : // always returning false value.
93 : virtual bool CanHaveAnonChildren();
94 :
95 : protected:
96 : // Returns value of first child xforms element by tagname that is bound to
97 : // instance node.
98 : nsresult GetBoundChildElementValue(const nsAString& aTagName,
99 : nsAString& aValue);
100 :
101 : // Cache accessible child item/choices elements. For example, the method is
102 : // used for full appearance select/select1 elements or for their child choices
103 : // element. Note, those select/select1 elements that use native widget
104 : // for representation don't use the method since their item/choices elements
105 : // are hidden and therefore aren't accessible.
106 : //
107 : // @param aContainerNode - node that contains item elements
108 : void CacheSelectChildren(nsIDOMNode *aContainerNode = nsnull);
109 : };
110 :
111 :
112 : /**
113 : * This class is accessible object for XForms elements that provide accessible
114 : * object for itself as well for anonymous content. You should use this class
115 : * if accessible XForms element is complex, i.e. it is composed from elements
116 : * that should be accessible too. Especially for elements that have multiple
117 : * areas that a user can interact with or multiple visual areas. For example,
118 : * objects for XForms input[type="xsd:gMonth"] that contains combobox element
119 : * to choose month. It has an entryfield, a drop-down button and a drop-down
120 : * list, all of which need to be accessible. Another example would be
121 : * an XForms upload element since it is constructed from textfield and
122 : * 'pick up file' and 'clear file' buttons.
123 : */
124 : class nsXFormsContainerAccessible : public nsXFormsAccessible
125 0 : {
126 : public:
127 : nsXFormsContainerAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
128 :
129 : // nsAccessible
130 : virtual mozilla::a11y::role NativeRole();
131 :
132 : // Allows accessible nodes in anonymous content of xforms element by
133 : // always returning true value.
134 : virtual bool CanHaveAnonChildren();
135 : };
136 :
137 :
138 : /**
139 : * The class is base for accessible objects for XForms elements that have
140 : * editable area.
141 : */
142 : class nsXFormsEditableAccessible : public nsXFormsAccessible
143 0 : {
144 : public:
145 : nsXFormsEditableAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
146 :
147 : // nsHyperTextAccessible
148 : virtual already_AddRefed<nsIEditor> GetEditor() const;
149 :
150 : // nsAccessible
151 : virtual PRUint64 NativeState();
152 : };
153 :
154 :
155 : /**
156 : * The class is base for accessible objects for XForms select and XForms
157 : * select1 elements.
158 : */
159 : class nsXFormsSelectableAccessible : public nsXFormsEditableAccessible
160 0 : {
161 : public:
162 : nsXFormsSelectableAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
163 :
164 : // SelectAccessible
165 : virtual bool IsSelect();
166 : virtual already_AddRefed<nsIArray> SelectedItems();
167 : virtual PRUint32 SelectedItemCount();
168 : virtual nsAccessible* GetSelectedItem(PRUint32 aIndex);
169 : virtual bool IsItemSelected(PRUint32 aIndex);
170 : virtual bool AddItemToSelection(PRUint32 aIndex);
171 : virtual bool RemoveItemFromSelection(PRUint32 aIndex);
172 : virtual bool SelectAll();
173 : virtual bool UnselectAll();
174 :
175 : protected:
176 : nsIContent* GetItemByIndex(PRUint32* aIndex,
177 : nsAccessible* aAccessible = nsnull);
178 :
179 : bool mIsSelect1Element;
180 : };
181 :
182 :
183 : /**
184 : * The class is base for accessible objects for XForms item elements.
185 : */
186 : class nsXFormsSelectableItemAccessible : public nsXFormsAccessible
187 0 : {
188 : public:
189 : nsXFormsSelectableItemAccessible(nsIContent* aContent,
190 : nsDocAccessible* aDoc);
191 :
192 : NS_IMETHOD GetValue(nsAString& aValue);
193 : NS_IMETHOD DoAction(PRUint8 aIndex);
194 :
195 : // ActionAccessible
196 : virtual PRUint8 ActionCount();
197 :
198 : protected:
199 : bool IsSelected();
200 : };
201 :
202 : #endif
203 :
|