1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:expandtab:shiftwidth=2:tabstop=2:
4 /* ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
17 * The Original Code is mozilla.org code.
19 * The Initial Developer of the Original Code is IBM Corporation
20 * Portions created by the Initial Developer are Copyright (C) 2006
21 * the Initial Developer. All Rights Reserved.
24 * Gao, Ming <gaoming@cn.ibm.com>
25 * Aaron Leventhal <aleventh@us.ibm.com>
26 * Alexander Surkov <surkov.alexander@gmail.com>
28 * Alternatively, the contents of this file may be used under the terms of
29 * either the GNU General Public License Version 2 or later (the "GPL"), or
30 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31 * in which case the provisions of the GPL or the LGPL are applicable instead
32 * of those above. If you wish to allow use of your version of this file only
33 * under the terms of either the GPL or the LGPL, and not to allow others to
34 * use your version of this file under the terms of the MPL, indicate your
35 * decision by deleting the provisions above and replace them with the notice
36 * and other provisions required by the GPL or the LGPL. If you do not delete
37 * the provisions above, a recipient may use your version of this file under
38 * the terms of any one of the MPL, the GPL or the LGPL.
40 * ***** END LICENSE BLOCK ***** */
43 #include "AccessibleRole.h"
45 const PRUint32 USE_ROLE_STRING
= 0;
46 const PRUint32 ROLE_WINDOWS_LAST_ENTRY
= 0xffffffff;
48 #ifndef ROLE_SYSTEM_SPLITBUTTON
49 const PRUint32 ROLE_SYSTEM_SPLITBUTTON
= 0x3e; // Not defined in all oleacc.h versions
52 #ifndef ROLE_SYSTEM_IPADDRESS
53 const PRUint32 ROLE_SYSTEM_IPADDRESS
= 0x3f; // Not defined in all oleacc.h versions
56 #ifndef ROLE_SYSTEM_OUTLINEBUTTON
57 const PRUint32 ROLE_SYSTEM_OUTLINEBUTTON
= 0x40; // Not defined in all oleacc.h versions
60 struct WindowsRoleMapItem
66 // Map array from cross platform roles to MSAA/IA2 roles
67 static const WindowsRoleMapItem gWindowsRoleMap
[] = {
68 // nsIAccessibleRole::ROLE_NOTHING
69 { USE_ROLE_STRING
, IA2_ROLE_UNKNOWN
},
71 // nsIAccessibleRole::ROLE_TITLEBAR
72 { ROLE_SYSTEM_TITLEBAR
, ROLE_SYSTEM_TITLEBAR
},
74 // nsIAccessibleRole::ROLE_MENUBAR
75 { ROLE_SYSTEM_MENUBAR
, ROLE_SYSTEM_MENUBAR
},
77 // nsIAccessibleRole::ROLE_SCROLLBAR
78 { ROLE_SYSTEM_SCROLLBAR
, ROLE_SYSTEM_SCROLLBAR
},
80 // nsIAccessibleRole::ROLE_GRIP
81 { ROLE_SYSTEM_GRIP
, ROLE_SYSTEM_GRIP
},
83 // nsIAccessibleRole::ROLE_SOUND
84 { ROLE_SYSTEM_SOUND
, ROLE_SYSTEM_SOUND
},
86 // nsIAccessibleRole::ROLE_CURSOR
87 { ROLE_SYSTEM_CURSOR
, ROLE_SYSTEM_CURSOR
},
89 // nsIAccessibleRole::ROLE_CARET
90 { ROLE_SYSTEM_CARET
, ROLE_SYSTEM_CARET
},
92 // nsIAccessibleRole::ROLE_ALERT
93 { ROLE_SYSTEM_ALERT
, ROLE_SYSTEM_ALERT
},
95 // nsIAccessibleRole::ROLE_WINDOW
96 { ROLE_SYSTEM_WINDOW
, ROLE_SYSTEM_WINDOW
},
98 // nsIAccessibleRole::ROLE_INTERNAL_FRAME
99 { USE_ROLE_STRING
, IA2_ROLE_INTERNAL_FRAME
},
101 // nsIAccessibleRole::ROLE_MENUPOPUP
102 { ROLE_SYSTEM_MENUPOPUP
, ROLE_SYSTEM_MENUPOPUP
},
104 // nsIAccessibleRole::ROLE_MENUITEM
105 { ROLE_SYSTEM_MENUITEM
, ROLE_SYSTEM_MENUITEM
},
107 // nsIAccessibleRole::ROLE_TOOLTIP
108 { ROLE_SYSTEM_TOOLTIP
, ROLE_SYSTEM_TOOLTIP
},
110 // nsIAccessibleRole::ROLE_APPLICATION
111 { ROLE_SYSTEM_APPLICATION
, ROLE_SYSTEM_APPLICATION
},
113 // nsIAccessibleRole::ROLE_DOCUMENT
114 { ROLE_SYSTEM_DOCUMENT
, ROLE_SYSTEM_DOCUMENT
},
116 // nsIAccessibleRole::ROLE_PANE
117 // We used to map to ROLE_SYSTEM_PANE, but JAWS would
118 // not read the accessible name for the contaning pane.
119 // However, JAWS will read the accessible name for a groupbox.
120 // By mapping a PANE to a GROUPING, we get no undesirable effects,
121 // but fortunately JAWS will then read the group's label,
122 // when an inner control gets focused.
123 { ROLE_SYSTEM_GROUPING
, ROLE_SYSTEM_GROUPING
},
125 // nsIAccessibleRole::ROLE_CHART
126 { ROLE_SYSTEM_CHART
, ROLE_SYSTEM_CHART
},
128 // nsIAccessibleRole::ROLE_DIALOG
129 { ROLE_SYSTEM_DIALOG
, ROLE_SYSTEM_DIALOG
},
131 // nsIAccessibleRole::ROLE_BORDER
132 { ROLE_SYSTEM_BORDER
, ROLE_SYSTEM_BORDER
},
134 // nsIAccessibleRole::ROLE_GROUPING
135 { ROLE_SYSTEM_GROUPING
, ROLE_SYSTEM_GROUPING
},
137 // nsIAccessibleRole::ROLE_SEPARATOR
138 { ROLE_SYSTEM_SEPARATOR
, ROLE_SYSTEM_SEPARATOR
},
140 // nsIAccessibleRole::ROLE_TOOLBAR
141 { ROLE_SYSTEM_TOOLBAR
, ROLE_SYSTEM_TOOLBAR
},
143 // nsIAccessibleRole::ROLE_STATUSBAR
144 { ROLE_SYSTEM_STATUSBAR
, ROLE_SYSTEM_STATUSBAR
},
146 // nsIAccessibleRole::ROLE_TABLE
147 { ROLE_SYSTEM_TABLE
, ROLE_SYSTEM_TABLE
},
149 // nsIAccessibleRole::ROLE_COLUMNHEADER,
150 { ROLE_SYSTEM_COLUMNHEADER
, ROLE_SYSTEM_COLUMNHEADER
},
152 // nsIAccessibleRole::ROLE_ROWHEADER
153 { ROLE_SYSTEM_ROWHEADER
, ROLE_SYSTEM_ROWHEADER
},
155 // nsIAccessibleRole::ROLE_COLUMN
156 { ROLE_SYSTEM_COLUMN
, ROLE_SYSTEM_COLUMN
},
158 // nsIAccessibleRole::ROLE_ROW
159 { ROLE_SYSTEM_ROW
, ROLE_SYSTEM_ROW
},
161 // nsIAccessibleRole::ROLE_CELL
162 { ROLE_SYSTEM_CELL
, ROLE_SYSTEM_CELL
},
164 // nsIAccessibleRole::ROLE_LINK
165 { ROLE_SYSTEM_LINK
, ROLE_SYSTEM_LINK
},
167 // nsIAccessibleRole::ROLE_HELPBALLOON
168 { ROLE_SYSTEM_HELPBALLOON
, ROLE_SYSTEM_HELPBALLOON
},
170 // nsIAccessibleRole::ROLE_CHARACTER
171 { ROLE_SYSTEM_CHARACTER
, ROLE_SYSTEM_CHARACTER
},
173 // nsIAccessibleRole::ROLE_LIST
174 { ROLE_SYSTEM_LIST
, ROLE_SYSTEM_LIST
},
176 // nsIAccessibleRole::ROLE_LISTITEM
177 { ROLE_SYSTEM_LISTITEM
, ROLE_SYSTEM_LISTITEM
},
179 // nsIAccessibleRole::ROLE_OUTLINE
180 { ROLE_SYSTEM_OUTLINE
, ROLE_SYSTEM_OUTLINE
},
182 // nsIAccessibleRole::ROLE_OUTLINEITEM
183 { ROLE_SYSTEM_OUTLINEITEM
, ROLE_SYSTEM_OUTLINEITEM
},
185 // nsIAccessibleRole::ROLE_PAGETAB
186 { ROLE_SYSTEM_PAGETAB
, ROLE_SYSTEM_PAGETAB
},
188 // nsIAccessibleRole::ROLE_PROPERTYPAGE
189 { ROLE_SYSTEM_PROPERTYPAGE
, ROLE_SYSTEM_PROPERTYPAGE
},
191 // nsIAccessibleRole::ROLE_INDICATOR
192 { ROLE_SYSTEM_INDICATOR
, ROLE_SYSTEM_INDICATOR
},
194 // nsIAccessibleRole::ROLE_GRAPHIC
195 { ROLE_SYSTEM_GRAPHIC
, ROLE_SYSTEM_GRAPHIC
},
197 // nsIAccessibleRole::ROLE_STATICTEXT
198 { ROLE_SYSTEM_STATICTEXT
, ROLE_SYSTEM_STATICTEXT
},
200 // nsIAccessibleRole::ROLE_TEXT_LEAF
201 { ROLE_SYSTEM_TEXT
, ROLE_SYSTEM_TEXT
},
203 // nsIAccessibleRole::ROLE_PUSHBUTTON
204 { ROLE_SYSTEM_PUSHBUTTON
, ROLE_SYSTEM_PUSHBUTTON
},
206 // nsIAccessibleRole::ROLE_CHECKBUTTON
207 { ROLE_SYSTEM_CHECKBUTTON
, ROLE_SYSTEM_CHECKBUTTON
},
209 // nsIAccessibleRole::ROLE_RADIOBUTTON
210 { ROLE_SYSTEM_RADIOBUTTON
, ROLE_SYSTEM_RADIOBUTTON
},
212 // nsIAccessibleRole::ROLE_COMBOBOX
213 { ROLE_SYSTEM_COMBOBOX
, ROLE_SYSTEM_COMBOBOX
},
215 // nsIAccessibleRole::ROLE_DROPLIST
216 { ROLE_SYSTEM_DROPLIST
, ROLE_SYSTEM_DROPLIST
},
218 // nsIAccessibleRole::ROLE_PROGRESSBAR
219 { ROLE_SYSTEM_PROGRESSBAR
, ROLE_SYSTEM_PROGRESSBAR
},
221 // nsIAccessibleRole::ROLE_DIAL
222 { ROLE_SYSTEM_DIAL
, ROLE_SYSTEM_DIAL
},
224 // nsIAccessibleRole::ROLE_HOTKEYFIELD
225 { ROLE_SYSTEM_HOTKEYFIELD
, ROLE_SYSTEM_HOTKEYFIELD
},
227 // nsIAccessibleRole::ROLE_SLIDER
228 { ROLE_SYSTEM_SLIDER
, ROLE_SYSTEM_SLIDER
},
230 // nsIAccessibleRole::ROLE_SPINBUTTON
231 { ROLE_SYSTEM_SPINBUTTON
, ROLE_SYSTEM_SPINBUTTON
},
233 // nsIAccessibleRole::ROLE_DIAGRAM
234 { ROLE_SYSTEM_DIAGRAM
, ROLE_SYSTEM_DIAGRAM
},
236 // nsIAccessibleRole::ROLE_ANIMATION
237 { ROLE_SYSTEM_ANIMATION
, ROLE_SYSTEM_ANIMATION
},
239 // nsIAccessibleRole::ROLE_EQUATION
240 { ROLE_SYSTEM_EQUATION
, ROLE_SYSTEM_EQUATION
},
242 // nsIAccessibleRole::ROLE_BUTTONDROPDOWN
243 { ROLE_SYSTEM_BUTTONDROPDOWN
, ROLE_SYSTEM_BUTTONDROPDOWN
},
245 // nsIAccessibleRole::ROLE_BUTTONMENU
246 { ROLE_SYSTEM_BUTTONMENU
, ROLE_SYSTEM_BUTTONMENU
},
248 // nsIAccessibleRole::ROLE_BUTTONDROPDOWNGRID
249 { ROLE_SYSTEM_BUTTONDROPDOWNGRID
, ROLE_SYSTEM_BUTTONDROPDOWNGRID
},
251 // nsIAccessibleRole::ROLE_WHITESPACE
252 { ROLE_SYSTEM_WHITESPACE
, ROLE_SYSTEM_WHITESPACE
},
254 // nsIAccessibleRole::ROLE_PAGETABLIST
255 { ROLE_SYSTEM_PAGETABLIST
, ROLE_SYSTEM_PAGETABLIST
},
257 // nsIAccessibleRole::ROLE_CLOCK
258 { ROLE_SYSTEM_CLOCK
, ROLE_SYSTEM_CLOCK
},
260 // nsIAccessibleRole::ROLE_SPLITBUTTON
261 { ROLE_SYSTEM_SPLITBUTTON
, ROLE_SYSTEM_SPLITBUTTON
},
263 // nsIAccessibleRole::ROLE_IPADDRESS
264 { ROLE_SYSTEM_IPADDRESS
, ROLE_SYSTEM_IPADDRESS
},
266 // Make up for Gecko roles that we don't have in MSAA or IA2. When in doubt
267 // map them to USE_ROLE_STRING (IA2_ROLE_UNKNOWN).
269 // nsIAccessibleRole::ROLE_ACCEL_LABEL
270 { ROLE_SYSTEM_STATICTEXT
, ROLE_SYSTEM_STATICTEXT
},
272 // nsIAccessibleRole::ROLE_ARROW
273 { ROLE_SYSTEM_INDICATOR
, ROLE_SYSTEM_INDICATOR
},
275 // nsIAccessibleRole::ROLE_CANVAS
276 { USE_ROLE_STRING
, IA2_ROLE_CANVAS
},
278 // nsIAccessibleRole::ROLE_CHECK_MENU_ITEM
279 { ROLE_SYSTEM_MENUITEM
, IA2_ROLE_CHECK_MENU_ITEM
},
281 // nsIAccessibleRole::ROLE_COLOR_CHOOSER
282 { ROLE_SYSTEM_DIALOG
, IA2_ROLE_COLOR_CHOOSER
},
284 // nsIAccessibleRole::ROLE_DATE_EDITOR
285 { USE_ROLE_STRING
, IA2_ROLE_DATE_EDITOR
},
287 // nsIAccessibleRole::ROLE_DESKTOP_ICON
288 { USE_ROLE_STRING
, IA2_ROLE_DESKTOP_ICON
},
290 // nsIAccessibleRole::ROLE_DESKTOP_FRAME
291 { USE_ROLE_STRING
, IA2_ROLE_DESKTOP_PANE
},
293 // nsIAccessibleRole::ROLE_DIRECTORY_PANE
294 { USE_ROLE_STRING
, IA2_ROLE_DIRECTORY_PANE
},
296 // nsIAccessibleRole::ROLE_FILE_CHOOSER
297 { USE_ROLE_STRING
, IA2_ROLE_FILE_CHOOSER
},
299 // nsIAccessibleRole::ROLE_FONT_CHOOSER
300 { USE_ROLE_STRING
, IA2_ROLE_FONT_CHOOSER
},
302 // nsIAccessibleRole::ROLE_CHROME_WINDOW
303 { ROLE_SYSTEM_APPLICATION
, IA2_ROLE_FRAME
},
305 // nsIAccessibleRole::ROLE_GLASS_PANE
306 { USE_ROLE_STRING
, IA2_ROLE_GLASS_PANE
},
308 // nsIAccessibleRole::ROLE_HTML_CONTAINER
309 { USE_ROLE_STRING
, IA2_ROLE_UNKNOWN
},
311 // nsIAccessibleRole::ROLE_ICON
312 { ROLE_SYSTEM_PUSHBUTTON
, IA2_ROLE_ICON
},
314 // nsIAccessibleRole::ROLE_LABEL
315 { ROLE_SYSTEM_STATICTEXT
, IA2_ROLE_LABEL
},
317 // nsIAccessibleRole::ROLE_LAYERED_PANE
318 { USE_ROLE_STRING
, IA2_ROLE_LAYERED_PANE
},
320 // nsIAccessibleRole::ROLE_OPTION_PANE
321 { USE_ROLE_STRING
, IA2_ROLE_OPTION_PANE
},
323 // nsIAccessibleRole::ROLE_PASSWORD_TEXT
324 { ROLE_SYSTEM_TEXT
, ROLE_SYSTEM_TEXT
},
326 // nsIAccessibleRole::ROLE_POPUP_MENU
327 { ROLE_SYSTEM_MENUPOPUP
, ROLE_SYSTEM_MENUPOPUP
},
329 // nsIAccessibleRole::ROLE_RADIO_MENU_ITEM
330 { ROLE_SYSTEM_MENUITEM
, IA2_ROLE_RADIO_MENU_ITEM
},
332 // nsIAccessibleRole::ROLE_ROOT_PANE
333 { USE_ROLE_STRING
, IA2_ROLE_ROOT_PANE
},
335 // nsIAccessibleRole::ROLE_SCROLL_PANE
336 { USE_ROLE_STRING
, IA2_ROLE_SCROLL_PANE
},
338 // nsIAccessibleRole::ROLE_SPLIT_PANE
339 { USE_ROLE_STRING
, IA2_ROLE_SPLIT_PANE
},
341 // nsIAccessibleRole::ROLE_TABLE_COLUMN_HEADER
342 { ROLE_SYSTEM_COLUMNHEADER
, ROLE_SYSTEM_COLUMNHEADER
},
344 // nsIAccessibleRole::ROLE_TABLE_ROW_HEADER
345 { ROLE_SYSTEM_ROWHEADER
, ROLE_SYSTEM_ROWHEADER
},
347 // nsIAccessibleRole::ROLE_TEAR_OFF_MENU_ITEM
348 { ROLE_SYSTEM_MENUITEM
, IA2_ROLE_TEAR_OFF_MENU
},
350 // nsIAccessibleRole::ROLE_TERMINAL
351 { USE_ROLE_STRING
, IA2_ROLE_TERMINAL
},
353 // nsIAccessibleRole::ROLE_TEXT_CONTAINER
354 { USE_ROLE_STRING
, IA2_ROLE_TEXT_FRAME
},
356 // nsIAccessibleRole::ROLE_TOGGLE_BUTTON
357 { ROLE_SYSTEM_PUSHBUTTON
, IA2_ROLE_TOGGLE_BUTTON
},
359 // nsIAccessibleRole::ROLE_TREE_TABLE
360 { ROLE_SYSTEM_OUTLINE
, ROLE_SYSTEM_OUTLINE
},
362 // nsIAccessibleRole::ROLE_VIEWPORT
363 { ROLE_SYSTEM_PANE
, IA2_ROLE_VIEW_PORT
},
365 // nsIAccessibleRole::ROLE_HEADER
366 { USE_ROLE_STRING
, IA2_ROLE_HEADER
},
368 // nsIAccessibleRole::ROLE_FOOTER
369 { USE_ROLE_STRING
, IA2_ROLE_FOOTER
},
371 // nsIAccessibleRole::ROLE_PARAGRAPH
372 { USE_ROLE_STRING
, IA2_ROLE_PARAGRAPH
},
374 // nsIAccessibleRole::ROLE_RULER
375 { USE_ROLE_STRING
, IA2_ROLE_RULER
},
377 // nsIAccessibleRole::ROLE_AUTOCOMPLETE
378 { ROLE_SYSTEM_COMBOBOX
, ROLE_SYSTEM_COMBOBOX
},
380 // nsIAccessibleRole::ROLE_EDITBAR
381 { ROLE_SYSTEM_TEXT
, IA2_ROLE_EDITBAR
},
383 // nsIAccessibleRole::ROLE_ENTRY
384 { ROLE_SYSTEM_TEXT
, ROLE_SYSTEM_TEXT
},
386 // nsIAccessibleRole::ROLE_CAPTION
387 { USE_ROLE_STRING
, IA2_ROLE_CAPTION
},
389 // nsIAccessibleRole::ROLE_DOCUMENT_FRAME
390 { USE_ROLE_STRING
, IA2_ROLE_UNKNOWN
},
392 // nsIAccessibleRole::ROLE_HEADING
393 { USE_ROLE_STRING
, IA2_ROLE_HEADING
},
395 // nsIAccessibleRole::ROLE_PAGE
396 { USE_ROLE_STRING
, IA2_ROLE_PAGE
},
398 // nsIAccessibleRole::ROLE_SECTION
399 { USE_ROLE_STRING
, IA2_ROLE_SECTION
},
401 // nsIAccessibleRole::ROLE_REDUNDANT_OBJECT
402 { USE_ROLE_STRING
, IA2_ROLE_REDUNDANT_OBJECT
},
404 // nsIAccessibleRole::ROLE_FORM
405 { USE_ROLE_STRING
, IA2_ROLE_FORM
},
407 // nsIAccessibleRole::ROLE_IME
408 { USE_ROLE_STRING
, IA2_ROLE_INPUT_METHOD_WINDOW
},
410 // nsIAccessibleRole::ROLE_APP_ROOT
411 { ROLE_SYSTEM_APPLICATION
, ROLE_SYSTEM_APPLICATION
},
413 // nsIAccessibleRole::ROLE_PARENT_MENUITEM
414 { ROLE_SYSTEM_MENUITEM
, ROLE_SYSTEM_MENUITEM
},
416 // nsIAccessibleRole::ROLE_CALENDAR
417 { ROLE_SYSTEM_CLIENT
, ROLE_SYSTEM_CLIENT
},
419 // nsIAccessibleRole::ROLE_COMBOBOX_LIST
420 { ROLE_SYSTEM_LIST
, ROLE_SYSTEM_LIST
},
422 // nsIAccessibleRole::ROLE_COMBOBOX_OPTION
423 { ROLE_SYSTEM_LISTITEM
, ROLE_SYSTEM_LISTITEM
},
425 // nsIAccessibleRole::ROLE_IMAGE_MAP
426 { ROLE_SYSTEM_GRAPHIC
, ROLE_SYSTEM_GRAPHIC
},
428 // nsIAccessibleRole::ROLE_OPTION
429 { ROLE_SYSTEM_LISTITEM
, ROLE_SYSTEM_LISTITEM
},
431 // nsIAccessibleRole::ROLE_RICH_OPTION
432 { ROLE_SYSTEM_LISTITEM
, ROLE_SYSTEM_LISTITEM
},
434 // nsIAccessibleRole::ROLE_LISTBOX
435 { ROLE_SYSTEM_LIST
, ROLE_SYSTEM_LIST
},
437 // nsIAccessibleRole::ROLE_FLAT_EQUATION
438 { ROLE_SYSTEM_EQUATION
, ROLE_SYSTEM_EQUATION
},
440 // nsIAccessibleRole::ROLE_LAST_ENTRY
441 { ROLE_WINDOWS_LAST_ENTRY
, ROLE_WINDOWS_LAST_ENTRY
}