accessible/src/base/ARIAMap.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:expandtab:shiftwidth=2:tabstop=2:
michael@0 3 */
michael@0 4 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 5 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 7
michael@0 8 #include "ARIAMap.h"
michael@0 9
michael@0 10 #include "nsAccUtils.h"
michael@0 11 #include "nsCoreUtils.h"
michael@0 12 #include "Role.h"
michael@0 13 #include "States.h"
michael@0 14
michael@0 15 #include "nsAttrName.h"
michael@0 16 #include "nsWhitespaceTokenizer.h"
michael@0 17
michael@0 18 using namespace mozilla;
michael@0 19 using namespace mozilla::a11y;
michael@0 20 using namespace mozilla::a11y::aria;
michael@0 21
michael@0 22 static const uint32_t kGenericAccType = 0;
michael@0 23
michael@0 24 /**
michael@0 25 * This list of WAI-defined roles are currently hardcoded.
michael@0 26 * Eventually we will most likely be loading an RDF resource that contains this information
michael@0 27 * Using RDF will also allow for role extensibility. See bug 280138.
michael@0 28 *
michael@0 29 * Definition of nsRoleMapEntry contains comments explaining this table.
michael@0 30 *
michael@0 31 * When no nsIAccessibleRole enum mapping exists for an ARIA role, the
michael@0 32 * role will be exposed via the object attribute "xml-roles".
michael@0 33 * In addition, in MSAA, the unmapped role will also be exposed as a BSTR string role.
michael@0 34 *
michael@0 35 * There are no nsIAccessibleRole enums for the following landmark roles:
michael@0 36 * banner, contentinfo, main, navigation, note, search, secondary, seealso, breadcrumbs
michael@0 37 */
michael@0 38
michael@0 39 static nsRoleMapEntry sWAIRoleMaps[] =
michael@0 40 {
michael@0 41 { // alert
michael@0 42 &nsGkAtoms::alert,
michael@0 43 roles::ALERT,
michael@0 44 kUseMapRole,
michael@0 45 eNoValue,
michael@0 46 eNoAction,
michael@0 47 eNoLiveAttr,
michael@0 48 kGenericAccType,
michael@0 49 kNoReqStates
michael@0 50 },
michael@0 51 { // alertdialog
michael@0 52 &nsGkAtoms::alertdialog,
michael@0 53 roles::DIALOG,
michael@0 54 kUseMapRole,
michael@0 55 eNoValue,
michael@0 56 eNoAction,
michael@0 57 eNoLiveAttr,
michael@0 58 kGenericAccType,
michael@0 59 kNoReqStates
michael@0 60 },
michael@0 61 { // application
michael@0 62 &nsGkAtoms::application,
michael@0 63 roles::APPLICATION,
michael@0 64 kUseMapRole,
michael@0 65 eNoValue,
michael@0 66 eNoAction,
michael@0 67 eNoLiveAttr,
michael@0 68 kGenericAccType,
michael@0 69 kNoReqStates
michael@0 70 },
michael@0 71 { // article
michael@0 72 &nsGkAtoms::article,
michael@0 73 roles::DOCUMENT,
michael@0 74 kUseMapRole,
michael@0 75 eNoValue,
michael@0 76 eNoAction,
michael@0 77 eNoLiveAttr,
michael@0 78 kGenericAccType,
michael@0 79 kNoReqStates,
michael@0 80 eReadonlyUntilEditable
michael@0 81 },
michael@0 82 { // button
michael@0 83 &nsGkAtoms::button,
michael@0 84 roles::PUSHBUTTON,
michael@0 85 kUseMapRole,
michael@0 86 eNoValue,
michael@0 87 ePressAction,
michael@0 88 eNoLiveAttr,
michael@0 89 eButton,
michael@0 90 kNoReqStates
michael@0 91 // eARIAPressed is auto applied on any button
michael@0 92 },
michael@0 93 { // checkbox
michael@0 94 &nsGkAtoms::checkbox,
michael@0 95 roles::CHECKBUTTON,
michael@0 96 kUseMapRole,
michael@0 97 eNoValue,
michael@0 98 eCheckUncheckAction,
michael@0 99 eNoLiveAttr,
michael@0 100 kGenericAccType,
michael@0 101 kNoReqStates,
michael@0 102 eARIACheckableMixed,
michael@0 103 eARIAReadonly
michael@0 104 },
michael@0 105 { // columnheader
michael@0 106 &nsGkAtoms::columnheader,
michael@0 107 roles::COLUMNHEADER,
michael@0 108 kUseMapRole,
michael@0 109 eNoValue,
michael@0 110 eSortAction,
michael@0 111 eNoLiveAttr,
michael@0 112 eTableCell,
michael@0 113 kNoReqStates,
michael@0 114 eARIASelectableIfDefined,
michael@0 115 eARIAReadonlyOrEditableIfDefined
michael@0 116 },
michael@0 117 { // combobox
michael@0 118 &nsGkAtoms::combobox,
michael@0 119 roles::COMBOBOX,
michael@0 120 kUseMapRole,
michael@0 121 eNoValue,
michael@0 122 eOpenCloseAction,
michael@0 123 eNoLiveAttr,
michael@0 124 kGenericAccType,
michael@0 125 states::COLLAPSED | states::HASPOPUP,
michael@0 126 eARIAAutoComplete,
michael@0 127 eARIAReadonly
michael@0 128 },
michael@0 129 { // dialog
michael@0 130 &nsGkAtoms::dialog,
michael@0 131 roles::DIALOG,
michael@0 132 kUseMapRole,
michael@0 133 eNoValue,
michael@0 134 eNoAction,
michael@0 135 eNoLiveAttr,
michael@0 136 kGenericAccType,
michael@0 137 kNoReqStates
michael@0 138 },
michael@0 139 { // directory
michael@0 140 &nsGkAtoms::directory,
michael@0 141 roles::LIST,
michael@0 142 kUseMapRole,
michael@0 143 eNoValue,
michael@0 144 eNoAction,
michael@0 145 eNoLiveAttr,
michael@0 146 eList,
michael@0 147 kNoReqStates
michael@0 148 },
michael@0 149 { // document
michael@0 150 &nsGkAtoms::document,
michael@0 151 roles::DOCUMENT,
michael@0 152 kUseMapRole,
michael@0 153 eNoValue,
michael@0 154 eNoAction,
michael@0 155 eNoLiveAttr,
michael@0 156 kGenericAccType,
michael@0 157 kNoReqStates,
michael@0 158 eReadonlyUntilEditable
michael@0 159 },
michael@0 160 { // form
michael@0 161 &nsGkAtoms::form,
michael@0 162 roles::FORM,
michael@0 163 kUseMapRole,
michael@0 164 eNoValue,
michael@0 165 eNoAction,
michael@0 166 eNoLiveAttr,
michael@0 167 kGenericAccType,
michael@0 168 kNoReqStates
michael@0 169 },
michael@0 170 { // grid
michael@0 171 &nsGkAtoms::grid,
michael@0 172 roles::TABLE,
michael@0 173 kUseMapRole,
michael@0 174 eNoValue,
michael@0 175 eNoAction,
michael@0 176 eNoLiveAttr,
michael@0 177 eSelect | eTable,
michael@0 178 kNoReqStates,
michael@0 179 eARIAMultiSelectable,
michael@0 180 eARIAReadonlyOrEditable,
michael@0 181 eFocusableUntilDisabled
michael@0 182 },
michael@0 183 { // gridcell
michael@0 184 &nsGkAtoms::gridcell,
michael@0 185 roles::GRID_CELL,
michael@0 186 kUseMapRole,
michael@0 187 eNoValue,
michael@0 188 eNoAction,
michael@0 189 eNoLiveAttr,
michael@0 190 eTableCell,
michael@0 191 kNoReqStates,
michael@0 192 eARIASelectable,
michael@0 193 eARIAReadonlyOrEditableIfDefined
michael@0 194 },
michael@0 195 { // group
michael@0 196 &nsGkAtoms::group,
michael@0 197 roles::GROUPING,
michael@0 198 kUseMapRole,
michael@0 199 eNoValue,
michael@0 200 eNoAction,
michael@0 201 eNoLiveAttr,
michael@0 202 kGenericAccType,
michael@0 203 kNoReqStates
michael@0 204 },
michael@0 205 { // heading
michael@0 206 &nsGkAtoms::heading,
michael@0 207 roles::HEADING,
michael@0 208 kUseMapRole,
michael@0 209 eNoValue,
michael@0 210 eNoAction,
michael@0 211 eNoLiveAttr,
michael@0 212 kGenericAccType,
michael@0 213 kNoReqStates
michael@0 214 },
michael@0 215 { // img
michael@0 216 &nsGkAtoms::img,
michael@0 217 roles::GRAPHIC,
michael@0 218 kUseMapRole,
michael@0 219 eNoValue,
michael@0 220 eNoAction,
michael@0 221 eNoLiveAttr,
michael@0 222 kGenericAccType,
michael@0 223 kNoReqStates
michael@0 224 },
michael@0 225 { // key
michael@0 226 &nsGkAtoms::key,
michael@0 227 roles::KEY,
michael@0 228 kUseMapRole,
michael@0 229 eNoValue,
michael@0 230 ePressAction,
michael@0 231 eNoLiveAttr,
michael@0 232 kGenericAccType,
michael@0 233 kNoReqStates,
michael@0 234 eARIAPressed
michael@0 235 },
michael@0 236 { // link
michael@0 237 &nsGkAtoms::link,
michael@0 238 roles::LINK,
michael@0 239 kUseMapRole,
michael@0 240 eNoValue,
michael@0 241 eJumpAction,
michael@0 242 eNoLiveAttr,
michael@0 243 kGenericAccType,
michael@0 244 states::LINKED
michael@0 245 },
michael@0 246 { // list
michael@0 247 &nsGkAtoms::list,
michael@0 248 roles::LIST,
michael@0 249 kUseMapRole,
michael@0 250 eNoValue,
michael@0 251 eNoAction,
michael@0 252 eNoLiveAttr,
michael@0 253 eList,
michael@0 254 states::READONLY
michael@0 255 },
michael@0 256 { // listbox
michael@0 257 &nsGkAtoms::listbox,
michael@0 258 roles::LISTBOX,
michael@0 259 kUseMapRole,
michael@0 260 eNoValue,
michael@0 261 eNoAction,
michael@0 262 eNoLiveAttr,
michael@0 263 eListControl | eSelect,
michael@0 264 kNoReqStates,
michael@0 265 eARIAMultiSelectable,
michael@0 266 eARIAReadonly,
michael@0 267 eFocusableUntilDisabled
michael@0 268 },
michael@0 269 { // listitem
michael@0 270 &nsGkAtoms::listitem,
michael@0 271 roles::LISTITEM,
michael@0 272 kUseMapRole,
michael@0 273 eNoValue,
michael@0 274 eNoAction, // XXX: should depend on state, parent accessible
michael@0 275 eNoLiveAttr,
michael@0 276 kGenericAccType,
michael@0 277 states::READONLY
michael@0 278 },
michael@0 279 { // log
michael@0 280 &nsGkAtoms::log_,
michael@0 281 roles::NOTHING,
michael@0 282 kUseNativeRole,
michael@0 283 eNoValue,
michael@0 284 eNoAction,
michael@0 285 ePoliteLiveAttr,
michael@0 286 kGenericAccType,
michael@0 287 kNoReqStates
michael@0 288 },
michael@0 289 { // marquee
michael@0 290 &nsGkAtoms::marquee,
michael@0 291 roles::ANIMATION,
michael@0 292 kUseMapRole,
michael@0 293 eNoValue,
michael@0 294 eNoAction,
michael@0 295 eOffLiveAttr,
michael@0 296 kGenericAccType,
michael@0 297 kNoReqStates
michael@0 298 },
michael@0 299 { // math
michael@0 300 &nsGkAtoms::math,
michael@0 301 roles::FLAT_EQUATION,
michael@0 302 kUseMapRole,
michael@0 303 eNoValue,
michael@0 304 eNoAction,
michael@0 305 eNoLiveAttr,
michael@0 306 kGenericAccType,
michael@0 307 kNoReqStates
michael@0 308 },
michael@0 309 { // menu
michael@0 310 &nsGkAtoms::menu,
michael@0 311 roles::MENUPOPUP,
michael@0 312 kUseMapRole,
michael@0 313 eNoValue,
michael@0 314 eNoAction, // XXX: technically accessibles of menupopup role haven't
michael@0 315 // any action, but menu can be open or close.
michael@0 316 eNoLiveAttr,
michael@0 317 kGenericAccType,
michael@0 318 kNoReqStates
michael@0 319 },
michael@0 320 { // menubar
michael@0 321 &nsGkAtoms::menubar,
michael@0 322 roles::MENUBAR,
michael@0 323 kUseMapRole,
michael@0 324 eNoValue,
michael@0 325 eNoAction,
michael@0 326 eNoLiveAttr,
michael@0 327 kGenericAccType,
michael@0 328 kNoReqStates
michael@0 329 },
michael@0 330 { // menuitem
michael@0 331 &nsGkAtoms::menuitem,
michael@0 332 roles::MENUITEM,
michael@0 333 kUseMapRole,
michael@0 334 eNoValue,
michael@0 335 eClickAction,
michael@0 336 eNoLiveAttr,
michael@0 337 kGenericAccType,
michael@0 338 kNoReqStates,
michael@0 339 eARIACheckedMixed
michael@0 340 },
michael@0 341 { // menuitemcheckbox
michael@0 342 &nsGkAtoms::menuitemcheckbox,
michael@0 343 roles::CHECK_MENU_ITEM,
michael@0 344 kUseMapRole,
michael@0 345 eNoValue,
michael@0 346 eClickAction,
michael@0 347 eNoLiveAttr,
michael@0 348 kGenericAccType,
michael@0 349 kNoReqStates,
michael@0 350 eARIACheckableMixed
michael@0 351 },
michael@0 352 { // menuitemradio
michael@0 353 &nsGkAtoms::menuitemradio,
michael@0 354 roles::RADIO_MENU_ITEM,
michael@0 355 kUseMapRole,
michael@0 356 eNoValue,
michael@0 357 eClickAction,
michael@0 358 eNoLiveAttr,
michael@0 359 kGenericAccType,
michael@0 360 kNoReqStates,
michael@0 361 eARIACheckableBool
michael@0 362 },
michael@0 363 { // note
michael@0 364 &nsGkAtoms::note_,
michael@0 365 roles::NOTE,
michael@0 366 kUseMapRole,
michael@0 367 eNoValue,
michael@0 368 eNoAction,
michael@0 369 eNoLiveAttr,
michael@0 370 kGenericAccType,
michael@0 371 kNoReqStates
michael@0 372 },
michael@0 373 { // option
michael@0 374 &nsGkAtoms::option,
michael@0 375 roles::OPTION,
michael@0 376 kUseMapRole,
michael@0 377 eNoValue,
michael@0 378 eSelectAction,
michael@0 379 eNoLiveAttr,
michael@0 380 kGenericAccType,
michael@0 381 kNoReqStates,
michael@0 382 eARIASelectable,
michael@0 383 eARIACheckedMixed
michael@0 384 },
michael@0 385 { // presentation
michael@0 386 &nsGkAtoms::presentation,
michael@0 387 roles::NOTHING,
michael@0 388 kUseMapRole,
michael@0 389 eNoValue,
michael@0 390 eNoAction,
michael@0 391 eNoLiveAttr,
michael@0 392 kGenericAccType,
michael@0 393 kNoReqStates
michael@0 394 },
michael@0 395 { // progressbar
michael@0 396 &nsGkAtoms::progressbar,
michael@0 397 roles::PROGRESSBAR,
michael@0 398 kUseMapRole,
michael@0 399 eHasValueMinMax,
michael@0 400 eNoAction,
michael@0 401 eNoLiveAttr,
michael@0 402 kGenericAccType,
michael@0 403 states::READONLY,
michael@0 404 eIndeterminateIfNoValue
michael@0 405 },
michael@0 406 { // radio
michael@0 407 &nsGkAtoms::radio,
michael@0 408 roles::RADIOBUTTON,
michael@0 409 kUseMapRole,
michael@0 410 eNoValue,
michael@0 411 eSelectAction,
michael@0 412 eNoLiveAttr,
michael@0 413 kGenericAccType,
michael@0 414 kNoReqStates,
michael@0 415 eARIACheckableBool
michael@0 416 },
michael@0 417 { // radiogroup
michael@0 418 &nsGkAtoms::radiogroup,
michael@0 419 roles::GROUPING,
michael@0 420 kUseMapRole,
michael@0 421 eNoValue,
michael@0 422 eNoAction,
michael@0 423 eNoLiveAttr,
michael@0 424 kGenericAccType,
michael@0 425 kNoReqStates
michael@0 426 },
michael@0 427 { // region
michael@0 428 &nsGkAtoms::region,
michael@0 429 roles::PANE,
michael@0 430 kUseMapRole,
michael@0 431 eNoValue,
michael@0 432 eNoAction,
michael@0 433 eNoLiveAttr,
michael@0 434 kGenericAccType,
michael@0 435 kNoReqStates
michael@0 436 },
michael@0 437 { // row
michael@0 438 &nsGkAtoms::row,
michael@0 439 roles::ROW,
michael@0 440 kUseMapRole,
michael@0 441 eNoValue,
michael@0 442 eNoAction,
michael@0 443 eNoLiveAttr,
michael@0 444 eTableRow,
michael@0 445 kNoReqStates,
michael@0 446 eARIASelectable
michael@0 447 },
michael@0 448 { // rowgroup
michael@0 449 &nsGkAtoms::rowgroup,
michael@0 450 roles::GROUPING,
michael@0 451 kUseMapRole,
michael@0 452 eNoValue,
michael@0 453 eNoAction,
michael@0 454 eNoLiveAttr,
michael@0 455 kGenericAccType,
michael@0 456 kNoReqStates
michael@0 457 },
michael@0 458 { // rowheader
michael@0 459 &nsGkAtoms::rowheader,
michael@0 460 roles::ROWHEADER,
michael@0 461 kUseMapRole,
michael@0 462 eNoValue,
michael@0 463 eSortAction,
michael@0 464 eNoLiveAttr,
michael@0 465 eTableCell,
michael@0 466 kNoReqStates,
michael@0 467 eARIASelectableIfDefined,
michael@0 468 eARIAReadonlyOrEditableIfDefined
michael@0 469 },
michael@0 470 { // scrollbar
michael@0 471 &nsGkAtoms::scrollbar,
michael@0 472 roles::SCROLLBAR,
michael@0 473 kUseMapRole,
michael@0 474 eHasValueMinMax,
michael@0 475 eNoAction,
michael@0 476 eNoLiveAttr,
michael@0 477 kGenericAccType,
michael@0 478 kNoReqStates,
michael@0 479 eARIAOrientation,
michael@0 480 eARIAReadonly
michael@0 481 },
michael@0 482 { // separator
michael@0 483 &nsGkAtoms::separator_,
michael@0 484 roles::SEPARATOR,
michael@0 485 kUseMapRole,
michael@0 486 eNoValue,
michael@0 487 eNoAction,
michael@0 488 eNoLiveAttr,
michael@0 489 kGenericAccType,
michael@0 490 kNoReqStates,
michael@0 491 eARIAOrientation
michael@0 492 },
michael@0 493 { // slider
michael@0 494 &nsGkAtoms::slider,
michael@0 495 roles::SLIDER,
michael@0 496 kUseMapRole,
michael@0 497 eHasValueMinMax,
michael@0 498 eNoAction,
michael@0 499 eNoLiveAttr,
michael@0 500 kGenericAccType,
michael@0 501 kNoReqStates,
michael@0 502 eARIAOrientation,
michael@0 503 eARIAReadonly
michael@0 504 },
michael@0 505 { // spinbutton
michael@0 506 &nsGkAtoms::spinbutton,
michael@0 507 roles::SPINBUTTON,
michael@0 508 kUseMapRole,
michael@0 509 eHasValueMinMax,
michael@0 510 eNoAction,
michael@0 511 eNoLiveAttr,
michael@0 512 kGenericAccType,
michael@0 513 kNoReqStates,
michael@0 514 eARIAReadonly
michael@0 515 },
michael@0 516 { // status
michael@0 517 &nsGkAtoms::status,
michael@0 518 roles::STATUSBAR,
michael@0 519 kUseMapRole,
michael@0 520 eNoValue,
michael@0 521 eNoAction,
michael@0 522 ePoliteLiveAttr,
michael@0 523 kGenericAccType,
michael@0 524 kNoReqStates
michael@0 525 },
michael@0 526 { // tab
michael@0 527 &nsGkAtoms::tab,
michael@0 528 roles::PAGETAB,
michael@0 529 kUseMapRole,
michael@0 530 eNoValue,
michael@0 531 eSwitchAction,
michael@0 532 eNoLiveAttr,
michael@0 533 kGenericAccType,
michael@0 534 kNoReqStates,
michael@0 535 eARIASelectable
michael@0 536 },
michael@0 537 { // tablist
michael@0 538 &nsGkAtoms::tablist,
michael@0 539 roles::PAGETABLIST,
michael@0 540 kUseMapRole,
michael@0 541 eNoValue,
michael@0 542 eNoAction,
michael@0 543 eNoLiveAttr,
michael@0 544 eSelect,
michael@0 545 kNoReqStates
michael@0 546 },
michael@0 547 { // tabpanel
michael@0 548 &nsGkAtoms::tabpanel,
michael@0 549 roles::PROPERTYPAGE,
michael@0 550 kUseMapRole,
michael@0 551 eNoValue,
michael@0 552 eNoAction,
michael@0 553 eNoLiveAttr,
michael@0 554 kGenericAccType,
michael@0 555 kNoReqStates
michael@0 556 },
michael@0 557 { // textbox
michael@0 558 &nsGkAtoms::textbox,
michael@0 559 roles::ENTRY,
michael@0 560 kUseMapRole,
michael@0 561 eNoValue,
michael@0 562 eActivateAction,
michael@0 563 eNoLiveAttr,
michael@0 564 kGenericAccType,
michael@0 565 kNoReqStates,
michael@0 566 eARIAAutoComplete,
michael@0 567 eARIAMultiline,
michael@0 568 eARIAReadonlyOrEditable
michael@0 569 },
michael@0 570 { // timer
michael@0 571 &nsGkAtoms::timer,
michael@0 572 roles::NOTHING,
michael@0 573 kUseNativeRole,
michael@0 574 eNoValue,
michael@0 575 eNoAction,
michael@0 576 eOffLiveAttr,
michael@0 577 kNoReqStates
michael@0 578 },
michael@0 579 { // toolbar
michael@0 580 &nsGkAtoms::toolbar,
michael@0 581 roles::TOOLBAR,
michael@0 582 kUseMapRole,
michael@0 583 eNoValue,
michael@0 584 eNoAction,
michael@0 585 eNoLiveAttr,
michael@0 586 kGenericAccType,
michael@0 587 kNoReqStates
michael@0 588 },
michael@0 589 { // tooltip
michael@0 590 &nsGkAtoms::tooltip,
michael@0 591 roles::TOOLTIP,
michael@0 592 kUseMapRole,
michael@0 593 eNoValue,
michael@0 594 eNoAction,
michael@0 595 eNoLiveAttr,
michael@0 596 kGenericAccType,
michael@0 597 kNoReqStates
michael@0 598 },
michael@0 599 { // tree
michael@0 600 &nsGkAtoms::tree,
michael@0 601 roles::OUTLINE,
michael@0 602 kUseMapRole,
michael@0 603 eNoValue,
michael@0 604 eNoAction,
michael@0 605 eNoLiveAttr,
michael@0 606 eSelect,
michael@0 607 kNoReqStates,
michael@0 608 eARIAReadonly,
michael@0 609 eARIAMultiSelectable,
michael@0 610 eFocusableUntilDisabled
michael@0 611 },
michael@0 612 { // treegrid
michael@0 613 &nsGkAtoms::treegrid,
michael@0 614 roles::TREE_TABLE,
michael@0 615 kUseMapRole,
michael@0 616 eNoValue,
michael@0 617 eNoAction,
michael@0 618 eNoLiveAttr,
michael@0 619 eSelect | eTable,
michael@0 620 kNoReqStates,
michael@0 621 eARIAReadonlyOrEditable,
michael@0 622 eARIAMultiSelectable,
michael@0 623 eFocusableUntilDisabled
michael@0 624 },
michael@0 625 { // treeitem
michael@0 626 &nsGkAtoms::treeitem,
michael@0 627 roles::OUTLINEITEM,
michael@0 628 kUseMapRole,
michael@0 629 eNoValue,
michael@0 630 eActivateAction, // XXX: should expose second 'expand/collapse' action based
michael@0 631 // on states
michael@0 632 eNoLiveAttr,
michael@0 633 kGenericAccType,
michael@0 634 kNoReqStates,
michael@0 635 eARIASelectable,
michael@0 636 eARIACheckedMixed
michael@0 637 }
michael@0 638 };
michael@0 639
michael@0 640 static nsRoleMapEntry sLandmarkRoleMap = {
michael@0 641 &nsGkAtoms::_empty,
michael@0 642 roles::NOTHING,
michael@0 643 kUseNativeRole,
michael@0 644 eNoValue,
michael@0 645 eNoAction,
michael@0 646 eNoLiveAttr,
michael@0 647 kGenericAccType,
michael@0 648 kNoReqStates
michael@0 649 };
michael@0 650
michael@0 651 nsRoleMapEntry aria::gEmptyRoleMap = {
michael@0 652 &nsGkAtoms::_empty,
michael@0 653 roles::NOTHING,
michael@0 654 kUseMapRole,
michael@0 655 eNoValue,
michael@0 656 eNoAction,
michael@0 657 eNoLiveAttr,
michael@0 658 kGenericAccType,
michael@0 659 kNoReqStates
michael@0 660 };
michael@0 661
michael@0 662 /**
michael@0 663 * Universal (Global) states:
michael@0 664 * The following state rules are applied to any accessible element,
michael@0 665 * whether there is an ARIA role or not:
michael@0 666 */
michael@0 667 static const EStateRule sWAIUnivStateMap[] = {
michael@0 668 eARIABusy,
michael@0 669 eARIADisabled,
michael@0 670 eARIAExpanded, // Currently under spec review but precedent exists
michael@0 671 eARIAHasPopup, // Note this is technically a "property"
michael@0 672 eARIAInvalid,
michael@0 673 eARIARequired, // XXX not global, Bug 553117
michael@0 674 eARIANone
michael@0 675 };
michael@0 676
michael@0 677
michael@0 678 /**
michael@0 679 * ARIA attribute map for attribute characteristics.
michael@0 680 * @note ARIA attributes that don't have any flags are not included here.
michael@0 681 */
michael@0 682
michael@0 683 struct AttrCharacteristics
michael@0 684 {
michael@0 685 nsIAtom** attributeName;
michael@0 686 const uint8_t characteristics;
michael@0 687 };
michael@0 688
michael@0 689 static const AttrCharacteristics gWAIUnivAttrMap[] = {
michael@0 690 {&nsGkAtoms::aria_activedescendant, ATTR_BYPASSOBJ },
michael@0 691 {&nsGkAtoms::aria_atomic, ATTR_BYPASSOBJ_IF_FALSE | ATTR_VALTOKEN | ATTR_GLOBAL },
michael@0 692 {&nsGkAtoms::aria_busy, ATTR_VALTOKEN | ATTR_GLOBAL },
michael@0 693 {&nsGkAtoms::aria_checked, ATTR_BYPASSOBJ | ATTR_VALTOKEN }, /* exposes checkable obj attr */
michael@0 694 {&nsGkAtoms::aria_controls, ATTR_BYPASSOBJ | ATTR_GLOBAL },
michael@0 695 {&nsGkAtoms::aria_describedby, ATTR_BYPASSOBJ | ATTR_GLOBAL },
michael@0 696 {&nsGkAtoms::aria_disabled, ATTR_BYPASSOBJ | ATTR_VALTOKEN | ATTR_GLOBAL },
michael@0 697 {&nsGkAtoms::aria_dropeffect, ATTR_VALTOKEN | ATTR_GLOBAL },
michael@0 698 {&nsGkAtoms::aria_expanded, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
michael@0 699 {&nsGkAtoms::aria_flowto, ATTR_BYPASSOBJ | ATTR_GLOBAL },
michael@0 700 {&nsGkAtoms::aria_grabbed, ATTR_VALTOKEN | ATTR_GLOBAL },
michael@0 701 {&nsGkAtoms::aria_haspopup, ATTR_BYPASSOBJ | ATTR_VALTOKEN | ATTR_GLOBAL },
michael@0 702 {&nsGkAtoms::aria_hidden, ATTR_BYPASSOBJ_IF_FALSE | ATTR_VALTOKEN | ATTR_GLOBAL },
michael@0 703 {&nsGkAtoms::aria_invalid, ATTR_BYPASSOBJ | ATTR_VALTOKEN | ATTR_GLOBAL },
michael@0 704 {&nsGkAtoms::aria_label, ATTR_BYPASSOBJ | ATTR_GLOBAL },
michael@0 705 {&nsGkAtoms::aria_labelledby, ATTR_BYPASSOBJ | ATTR_GLOBAL },
michael@0 706 {&nsGkAtoms::aria_level, ATTR_BYPASSOBJ }, /* handled via groupPosition */
michael@0 707 {&nsGkAtoms::aria_live, ATTR_VALTOKEN | ATTR_GLOBAL },
michael@0 708 {&nsGkAtoms::aria_multiline, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
michael@0 709 {&nsGkAtoms::aria_multiselectable, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
michael@0 710 {&nsGkAtoms::aria_owns, ATTR_BYPASSOBJ | ATTR_GLOBAL },
michael@0 711 {&nsGkAtoms::aria_orientation, ATTR_VALTOKEN },
michael@0 712 {&nsGkAtoms::aria_posinset, ATTR_BYPASSOBJ }, /* handled via groupPosition */
michael@0 713 {&nsGkAtoms::aria_pressed, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
michael@0 714 {&nsGkAtoms::aria_readonly, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
michael@0 715 {&nsGkAtoms::aria_relevant, ATTR_BYPASSOBJ | ATTR_GLOBAL },
michael@0 716 {&nsGkAtoms::aria_required, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
michael@0 717 {&nsGkAtoms::aria_selected, ATTR_BYPASSOBJ | ATTR_VALTOKEN },
michael@0 718 {&nsGkAtoms::aria_setsize, ATTR_BYPASSOBJ }, /* handled via groupPosition */
michael@0 719 {&nsGkAtoms::aria_sort, ATTR_VALTOKEN },
michael@0 720 {&nsGkAtoms::aria_valuenow, ATTR_BYPASSOBJ },
michael@0 721 {&nsGkAtoms::aria_valuemin, ATTR_BYPASSOBJ },
michael@0 722 {&nsGkAtoms::aria_valuemax, ATTR_BYPASSOBJ },
michael@0 723 {&nsGkAtoms::aria_valuetext, ATTR_BYPASSOBJ }
michael@0 724 };
michael@0 725
michael@0 726 nsRoleMapEntry*
michael@0 727 aria::GetRoleMap(nsINode* aNode)
michael@0 728 {
michael@0 729 nsIContent* content = nsCoreUtils::GetRoleContent(aNode);
michael@0 730 nsAutoString roles;
michael@0 731 if (!content ||
michael@0 732 !content->GetAttr(kNameSpaceID_None, nsGkAtoms::role, roles) ||
michael@0 733 roles.IsEmpty()) {
michael@0 734 // We treat role="" as if the role attribute is absent (per aria spec:8.1.1)
michael@0 735 return nullptr;
michael@0 736 }
michael@0 737
michael@0 738 nsWhitespaceTokenizer tokenizer(roles);
michael@0 739 while (tokenizer.hasMoreTokens()) {
michael@0 740 // Do a binary search through table for the next role in role list
michael@0 741 const nsDependentSubstring role = tokenizer.nextToken();
michael@0 742 uint32_t low = 0;
michael@0 743 uint32_t high = ArrayLength(sWAIRoleMaps);
michael@0 744 while (low < high) {
michael@0 745 uint32_t idx = (low + high) / 2;
michael@0 746 int32_t compare = Compare(role, sWAIRoleMaps[idx].ARIARoleString());
michael@0 747 if (compare == 0)
michael@0 748 return sWAIRoleMaps + idx;
michael@0 749
michael@0 750 if (compare < 0)
michael@0 751 high = idx;
michael@0 752 else
michael@0 753 low = idx + 1;
michael@0 754 }
michael@0 755 }
michael@0 756
michael@0 757 // Always use some entry if there is a non-empty role string
michael@0 758 // To ensure an accessible object is created
michael@0 759 return &sLandmarkRoleMap;
michael@0 760 }
michael@0 761
michael@0 762 uint64_t
michael@0 763 aria::UniversalStatesFor(mozilla::dom::Element* aElement)
michael@0 764 {
michael@0 765 uint64_t state = 0;
michael@0 766 uint32_t index = 0;
michael@0 767 while (MapToState(sWAIUnivStateMap[index], aElement, &state))
michael@0 768 index++;
michael@0 769
michael@0 770 return state;
michael@0 771 }
michael@0 772
michael@0 773 uint8_t
michael@0 774 aria::AttrCharacteristicsFor(nsIAtom* aAtom)
michael@0 775 {
michael@0 776 for (uint32_t i = 0; i < ArrayLength(gWAIUnivAttrMap); i++)
michael@0 777 if (*gWAIUnivAttrMap[i].attributeName == aAtom)
michael@0 778 return gWAIUnivAttrMap[i].characteristics;
michael@0 779
michael@0 780 return 0;
michael@0 781 }
michael@0 782
michael@0 783 ////////////////////////////////////////////////////////////////////////////////
michael@0 784 // AttrIterator class
michael@0 785
michael@0 786 bool
michael@0 787 AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue)
michael@0 788 {
michael@0 789 while (mAttrIdx < mAttrCount) {
michael@0 790 const nsAttrName* attr = mContent->GetAttrNameAt(mAttrIdx);
michael@0 791 mAttrIdx++;
michael@0 792 if (attr->NamespaceEquals(kNameSpaceID_None)) {
michael@0 793 nsIAtom* attrAtom = attr->Atom();
michael@0 794 nsDependentAtomString attrStr(attrAtom);
michael@0 795 if (!StringBeginsWith(attrStr, NS_LITERAL_STRING("aria-")))
michael@0 796 continue; // Not ARIA
michael@0 797
michael@0 798 uint8_t attrFlags = aria::AttrCharacteristicsFor(attrAtom);
michael@0 799 if (attrFlags & ATTR_BYPASSOBJ)
michael@0 800 continue; // No need to handle exposing as obj attribute here
michael@0 801
michael@0 802 if ((attrFlags & ATTR_VALTOKEN) &&
michael@0 803 !nsAccUtils::HasDefinedARIAToken(mContent, attrAtom))
michael@0 804 continue; // only expose token based attributes if they are defined
michael@0 805
michael@0 806 if ((attrFlags & ATTR_BYPASSOBJ_IF_FALSE) &&
michael@0 807 mContent->AttrValueIs(kNameSpaceID_None, attrAtom,
michael@0 808 nsGkAtoms::_false, eCaseMatters)) {
michael@0 809 continue; // only expose token based attribute if value is not 'false'.
michael@0 810 }
michael@0 811
michael@0 812 nsAutoString value;
michael@0 813 if (mContent->GetAttr(kNameSpaceID_None, attrAtom, value)) {
michael@0 814 aAttrName.Assign(Substring(attrStr, 5));
michael@0 815 aAttrValue.Assign(value);
michael@0 816 return true;
michael@0 817 }
michael@0 818 }
michael@0 819 }
michael@0 820
michael@0 821 return false;
michael@0 822 }
michael@0 823

mercurial