2012-10-02 00:33:26 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2015-09-02 19:44:30 +03:00
|
|
|
/* exported TraversalRules, TraversalHelper */
|
2014-05-01 08:33:37 +04:00
|
|
|
|
2017-08-01 19:13:27 +03:00
|
|
|
"use strict";
|
2012-10-02 00:33:26 +04:00
|
|
|
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cu = Components.utils;
|
|
|
|
|
2017-08-01 19:13:27 +03:00
|
|
|
this.EXPORTED_SYMBOLS = ["TraversalRules", "TraversalHelper"]; // jshint ignore:line
|
2012-10-02 00:33:26 +04:00
|
|
|
|
2018-01-30 08:17:48 +03:00
|
|
|
Cu.import("resource://gre/modules/accessibility/Utils.jsm");
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "Roles", // jshint ignore:line
|
2017-08-01 19:13:27 +03:00
|
|
|
"resource://gre/modules/accessibility/Constants.jsm");
|
2018-01-30 08:17:48 +03:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "Filters", // jshint ignore:line
|
2017-08-01 19:13:27 +03:00
|
|
|
"resource://gre/modules/accessibility/Constants.jsm");
|
2018-01-30 08:17:48 +03:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "States", // jshint ignore:line
|
2017-08-01 19:13:27 +03:00
|
|
|
"resource://gre/modules/accessibility/Constants.jsm");
|
2018-01-30 08:17:48 +03:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "Prefilters", // jshint ignore:line
|
2017-08-01 19:13:27 +03:00
|
|
|
"resource://gre/modules/accessibility/Constants.jsm");
|
2012-10-02 00:33:26 +04:00
|
|
|
|
2017-08-01 19:13:27 +03:00
|
|
|
var gSkipEmptyImages = new PrefCache("accessibility.accessfu.skip_empty_images");
|
2013-06-18 00:25:24 +04:00
|
|
|
|
2015-09-02 19:44:30 +03:00
|
|
|
function BaseTraversalRule(aRoles, aMatchFunc, aPreFilter, aContainerRule) {
|
2013-10-14 23:56:19 +04:00
|
|
|
this._explicitMatchRoles = new Set(aRoles);
|
2012-10-02 00:33:26 +04:00
|
|
|
this._matchRoles = aRoles;
|
2015-08-31 19:45:02 +03:00
|
|
|
if (aRoles.length) {
|
|
|
|
if (aRoles.indexOf(Roles.LABEL) < 0) {
|
|
|
|
this._matchRoles.push(Roles.LABEL);
|
|
|
|
}
|
|
|
|
if (aRoles.indexOf(Roles.INTERNAL_FRAME) < 0) {
|
|
|
|
// Used for traversing in to child OOP frames.
|
|
|
|
this._matchRoles.push(Roles.INTERNAL_FRAME);
|
|
|
|
}
|
2014-10-15 01:42:51 +04:00
|
|
|
}
|
2014-05-01 08:33:37 +04:00
|
|
|
this._matchFunc = aMatchFunc || function() { return Filters.MATCH; };
|
2014-01-30 03:08:53 +04:00
|
|
|
this.preFilter = aPreFilter || gSimplePreFilter;
|
2015-09-02 19:44:30 +03:00
|
|
|
this.containerRule = aContainerRule;
|
2012-10-02 00:33:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
BaseTraversalRule.prototype = {
|
2015-08-31 19:45:02 +03:00
|
|
|
getMatchRoles: function BaseTraversalRule_getmatchRoles(aRoles) {
|
|
|
|
aRoles.value = this._matchRoles;
|
|
|
|
return aRoles.value.length;
|
2012-10-02 00:33:26 +04:00
|
|
|
},
|
|
|
|
|
2017-08-01 21:08:02 +03:00
|
|
|
match: function BaseTraversalRule_match(aAccessible) {
|
2013-10-14 23:56:19 +04:00
|
|
|
let role = aAccessible.role;
|
2013-11-19 22:17:43 +04:00
|
|
|
if (role == Roles.INTERNAL_FRAME) {
|
2013-05-21 22:16:50 +04:00
|
|
|
return (Utils.getMessageManager(aAccessible.DOMNode)) ?
|
2017-08-01 19:15:51 +03:00
|
|
|
Filters.MATCH | Filters.IGNORE_SUBTREE : Filters.IGNORE;
|
2012-10-02 00:33:26 +04:00
|
|
|
}
|
|
|
|
|
2015-08-31 19:45:02 +03:00
|
|
|
let matchResult =
|
|
|
|
(this._explicitMatchRoles.has(role) || !this._explicitMatchRoles.size) ?
|
|
|
|
this._matchFunc(aAccessible) : Filters.IGNORE;
|
2012-10-02 00:33:26 +04:00
|
|
|
|
2013-10-14 23:56:19 +04:00
|
|
|
// If we are on a label that nests a checkbox/radio we should land on it.
|
|
|
|
// It is a bigger touch target, and it reduces clutter.
|
2013-11-19 22:17:43 +04:00
|
|
|
if (role == Roles.LABEL && !(matchResult & Filters.IGNORE_SUBTREE)) {
|
2013-10-14 23:56:19 +04:00
|
|
|
let control = Utils.getEmbeddedControl(aAccessible);
|
|
|
|
if (control && this._explicitMatchRoles.has(control.role)) {
|
2013-11-19 22:17:43 +04:00
|
|
|
matchResult = this._matchFunc(control) | Filters.IGNORE_SUBTREE;
|
2013-10-14 23:56:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return matchResult;
|
2012-10-02 00:33:26 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
|
|
|
|
};
|
|
|
|
|
|
|
|
var gSimpleTraversalRoles =
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.MENUITEM,
|
|
|
|
Roles.LINK,
|
|
|
|
Roles.PAGETAB,
|
|
|
|
Roles.GRAPHIC,
|
|
|
|
Roles.STATICTEXT,
|
|
|
|
Roles.TEXT_LEAF,
|
|
|
|
Roles.PUSHBUTTON,
|
|
|
|
Roles.CHECKBUTTON,
|
|
|
|
Roles.RADIOBUTTON,
|
|
|
|
Roles.COMBOBOX,
|
|
|
|
Roles.PROGRESSBAR,
|
|
|
|
Roles.BUTTONDROPDOWN,
|
|
|
|
Roles.BUTTONMENU,
|
|
|
|
Roles.CHECK_MENU_ITEM,
|
|
|
|
Roles.PASSWORD_TEXT,
|
|
|
|
Roles.RADIO_MENU_ITEM,
|
|
|
|
Roles.TOGGLE_BUTTON,
|
|
|
|
Roles.ENTRY,
|
|
|
|
Roles.KEY,
|
|
|
|
Roles.HEADER,
|
|
|
|
Roles.HEADING,
|
|
|
|
Roles.SLIDER,
|
|
|
|
Roles.SPINBUTTON,
|
|
|
|
Roles.OPTION,
|
2014-05-01 08:33:37 +04:00
|
|
|
Roles.LISTITEM,
|
2014-09-26 00:28:34 +04:00
|
|
|
Roles.GRID_CELL,
|
|
|
|
Roles.COLUMNHEADER,
|
2015-01-24 09:21:20 +03:00
|
|
|
Roles.ROWHEADER,
|
2015-05-29 18:55:53 +03:00
|
|
|
Roles.STATUSBAR,
|
2015-07-13 12:53:00 +03:00
|
|
|
Roles.SWITCH,
|
|
|
|
Roles.MATHML_MATH];
|
2012-10-02 00:33:26 +04:00
|
|
|
|
2014-01-30 03:08:53 +04:00
|
|
|
var gSimpleMatchFunc = function gSimpleMatchFunc(aAccessible) {
|
2014-05-01 08:33:37 +04:00
|
|
|
// An object is simple, if it either has a single child lineage,
|
|
|
|
// or has a flat subtree.
|
|
|
|
function isSingleLineage(acc) {
|
|
|
|
for (let child = acc; child; child = child.firstChild) {
|
2014-09-25 17:57:22 +04:00
|
|
|
if (Utils.visibleChildCount(child) > 1) {
|
2014-01-30 03:08:53 +04:00
|
|
|
return false;
|
2013-07-27 01:09:17 +04:00
|
|
|
}
|
2014-01-30 03:08:53 +04:00
|
|
|
}
|
2014-05-01 08:33:37 +04:00
|
|
|
return true;
|
|
|
|
}
|
2013-07-27 01:09:17 +04:00
|
|
|
|
2014-05-01 08:33:37 +04:00
|
|
|
function isFlatSubtree(acc) {
|
|
|
|
for (let child = acc.firstChild; child; child = child.nextSibling) {
|
2014-05-20 23:01:22 +04:00
|
|
|
// text leafs inherit the actionCount of any ancestor that has a click
|
|
|
|
// listener.
|
|
|
|
if ([Roles.TEXT_LEAF, Roles.STATICTEXT].indexOf(child.role) >= 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-09-25 17:57:22 +04:00
|
|
|
if (Utils.visibleChildCount(child) > 0 || child.actionCount > 0) {
|
2014-05-01 08:33:37 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2014-01-30 03:08:53 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aAccessible.role) {
|
|
|
|
case Roles.COMBOBOX:
|
|
|
|
// We don't want to ignore the subtree because this is often
|
|
|
|
// where the list box hangs out.
|
|
|
|
return Filters.MATCH;
|
|
|
|
case Roles.TEXT_LEAF:
|
|
|
|
{
|
|
|
|
// Nameless text leaves are boring, skip them.
|
|
|
|
let name = aAccessible.name;
|
2014-05-01 08:33:37 +04:00
|
|
|
return (name && name.trim()) ? Filters.MATCH : Filters.IGNORE;
|
2012-10-02 00:33:26 +04:00
|
|
|
}
|
2014-01-30 03:08:53 +04:00
|
|
|
case Roles.STATICTEXT:
|
2014-05-01 08:33:37 +04:00
|
|
|
// Ignore prefix static text in list items. They are typically bullets or numbers.
|
|
|
|
return Utils.isListItemDecorator(aAccessible) ?
|
|
|
|
Filters.IGNORE : Filters.MATCH;
|
2014-01-30 03:08:53 +04:00
|
|
|
case Roles.GRAPHIC:
|
|
|
|
return TraversalRules._shouldSkipImage(aAccessible);
|
|
|
|
case Roles.HEADER:
|
|
|
|
case Roles.HEADING:
|
2014-09-26 00:28:34 +04:00
|
|
|
case Roles.COLUMNHEADER:
|
|
|
|
case Roles.ROWHEADER:
|
2015-01-24 09:21:20 +03:00
|
|
|
case Roles.STATUSBAR:
|
2014-02-04 04:57:20 +04:00
|
|
|
if ((aAccessible.childCount > 0 || aAccessible.name) &&
|
2014-05-01 08:33:37 +04:00
|
|
|
(isSingleLineage(aAccessible) || isFlatSubtree(aAccessible))) {
|
2014-02-04 04:57:20 +04:00
|
|
|
return Filters.MATCH | Filters.IGNORE_SUBTREE;
|
2014-05-01 08:33:37 +04:00
|
|
|
}
|
|
|
|
return Filters.IGNORE;
|
2014-09-26 00:28:34 +04:00
|
|
|
case Roles.GRID_CELL:
|
|
|
|
return isSingleLineage(aAccessible) || isFlatSubtree(aAccessible) ?
|
|
|
|
Filters.MATCH | Filters.IGNORE_SUBTREE : Filters.IGNORE;
|
2014-05-01 08:33:37 +04:00
|
|
|
case Roles.LISTITEM:
|
|
|
|
{
|
|
|
|
let item = aAccessible.childCount === 2 &&
|
|
|
|
aAccessible.firstChild.role === Roles.STATICTEXT ?
|
|
|
|
aAccessible.lastChild : aAccessible;
|
|
|
|
return isSingleLineage(item) || isFlatSubtree(item) ?
|
|
|
|
Filters.MATCH | Filters.IGNORE_SUBTREE : Filters.IGNORE;
|
2014-02-04 04:57:20 +04:00
|
|
|
}
|
2014-01-30 03:08:53 +04:00
|
|
|
default:
|
|
|
|
// Ignore the subtree, if there is one. So that we don't land on
|
|
|
|
// the same content that was already presented by its parent.
|
|
|
|
return Filters.MATCH |
|
|
|
|
Filters.IGNORE_SUBTREE;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-04-17 09:02:40 +04:00
|
|
|
var gSimplePreFilter = Prefilters.DEFUNCT |
|
|
|
|
Prefilters.INVISIBLE |
|
|
|
|
Prefilters.ARIA_HIDDEN |
|
|
|
|
Prefilters.TRANSPARENT;
|
2014-01-30 03:08:53 +04:00
|
|
|
|
2014-05-01 08:33:37 +04:00
|
|
|
this.TraversalRules = { // jshint ignore:line
|
2014-01-30 03:08:53 +04:00
|
|
|
Simple: new BaseTraversalRule(gSimpleTraversalRoles, gSimpleMatchFunc),
|
|
|
|
|
|
|
|
SimpleOnScreen: new BaseTraversalRule(
|
|
|
|
gSimpleTraversalRoles, gSimpleMatchFunc,
|
2014-04-17 09:02:40 +04:00
|
|
|
Prefilters.DEFUNCT | Prefilters.INVISIBLE | Prefilters.ARIA_HIDDEN |
|
|
|
|
Prefilters.TRANSPARENT | Prefilters.OFFSCREEN),
|
2012-10-02 00:33:26 +04:00
|
|
|
|
|
|
|
Anchor: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.LINK],
|
2017-08-01 21:08:02 +03:00
|
|
|
function Anchor_match(aAccessible) {
|
2012-10-02 00:33:26 +04:00
|
|
|
// We want to ignore links, only focus named anchors.
|
2014-01-28 04:35:13 +04:00
|
|
|
if (Utils.getState(aAccessible).contains(States.LINKED)) {
|
2013-11-19 22:17:43 +04:00
|
|
|
return Filters.IGNORE;
|
2012-10-02 00:33:26 +04:00
|
|
|
}
|
2017-08-01 21:08:02 +03:00
|
|
|
return Filters.MATCH;
|
|
|
|
|
2012-10-02 00:33:26 +04:00
|
|
|
}),
|
|
|
|
|
|
|
|
Button: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.PUSHBUTTON,
|
|
|
|
Roles.SPINBUTTON,
|
|
|
|
Roles.TOGGLE_BUTTON,
|
|
|
|
Roles.BUTTONDROPDOWN,
|
|
|
|
Roles.BUTTONDROPDOWNGRID]),
|
2012-10-02 00:33:26 +04:00
|
|
|
|
|
|
|
Combobox: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.COMBOBOX,
|
|
|
|
Roles.LISTBOX]),
|
2012-10-02 00:33:26 +04:00
|
|
|
|
2013-07-12 00:42:11 +04:00
|
|
|
Landmark: new BaseTraversalRule(
|
|
|
|
[],
|
|
|
|
function Landmark_match(aAccessible) {
|
2013-11-19 22:17:43 +04:00
|
|
|
return Utils.getLandmarkName(aAccessible) ? Filters.MATCH :
|
|
|
|
Filters.IGNORE;
|
2015-09-02 19:44:30 +03:00
|
|
|
}, null, true),
|
2013-07-12 00:42:11 +04:00
|
|
|
|
2015-09-04 20:04:19 +03:00
|
|
|
/* A rule for Android's section navigation, lands on landmarks, regions, and
|
|
|
|
on headings to aid navigation of traditionally structured documents */
|
|
|
|
Section: new BaseTraversalRule(
|
|
|
|
[],
|
|
|
|
function Section_match(aAccessible) {
|
|
|
|
if (aAccessible.role === Roles.HEADING) {
|
|
|
|
return Filters.MATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
let matchedRole = Utils.matchRoles(aAccessible, [
|
2017-08-01 19:13:27 +03:00
|
|
|
"banner",
|
|
|
|
"complementary",
|
|
|
|
"contentinfo",
|
|
|
|
"main",
|
|
|
|
"navigation",
|
|
|
|
"search",
|
|
|
|
"region"
|
2015-09-04 20:04:19 +03:00
|
|
|
]);
|
|
|
|
|
|
|
|
return matchedRole ? Filters.MATCH : Filters.IGNORE;
|
|
|
|
}, null, true),
|
|
|
|
|
2012-10-02 00:33:26 +04:00
|
|
|
Entry: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.ENTRY,
|
|
|
|
Roles.PASSWORD_TEXT]),
|
2012-10-02 00:33:26 +04:00
|
|
|
|
|
|
|
FormElement: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.PUSHBUTTON,
|
|
|
|
Roles.SPINBUTTON,
|
|
|
|
Roles.TOGGLE_BUTTON,
|
|
|
|
Roles.BUTTONDROPDOWN,
|
|
|
|
Roles.BUTTONDROPDOWNGRID,
|
|
|
|
Roles.COMBOBOX,
|
|
|
|
Roles.LISTBOX,
|
|
|
|
Roles.ENTRY,
|
|
|
|
Roles.PASSWORD_TEXT,
|
|
|
|
Roles.PAGETAB,
|
|
|
|
Roles.RADIOBUTTON,
|
|
|
|
Roles.RADIO_MENU_ITEM,
|
|
|
|
Roles.SLIDER,
|
|
|
|
Roles.CHECKBUTTON,
|
2015-05-29 18:55:53 +03:00
|
|
|
Roles.CHECK_MENU_ITEM,
|
|
|
|
Roles.SWITCH]),
|
2012-10-02 00:33:26 +04:00
|
|
|
|
|
|
|
Graphic: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.GRAPHIC],
|
2013-06-18 00:25:24 +04:00
|
|
|
function Graphic_match(aAccessible) {
|
|
|
|
return TraversalRules._shouldSkipImage(aAccessible);
|
|
|
|
}),
|
2012-10-02 00:33:26 +04:00
|
|
|
|
|
|
|
Heading: new BaseTraversalRule(
|
2014-02-04 04:57:20 +04:00
|
|
|
[Roles.HEADING],
|
|
|
|
function Heading_match(aAccessible) {
|
|
|
|
return aAccessible.childCount > 0 ? Filters.MATCH : Filters.IGNORE;
|
|
|
|
}),
|
2012-10-02 00:33:26 +04:00
|
|
|
|
|
|
|
ListItem: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.LISTITEM,
|
|
|
|
Roles.TERM]),
|
2012-10-02 00:33:26 +04:00
|
|
|
|
|
|
|
Link: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.LINK],
|
2017-08-01 21:08:02 +03:00
|
|
|
function Link_match(aAccessible) {
|
2012-10-02 00:33:26 +04:00
|
|
|
// We want to ignore anchors, only focus real links.
|
2014-01-28 04:35:13 +04:00
|
|
|
if (Utils.getState(aAccessible).contains(States.LINKED)) {
|
2013-11-19 22:17:43 +04:00
|
|
|
return Filters.MATCH;
|
2012-10-02 00:33:26 +04:00
|
|
|
}
|
2017-08-01 21:08:02 +03:00
|
|
|
return Filters.IGNORE;
|
|
|
|
|
2012-10-02 00:33:26 +04:00
|
|
|
}),
|
|
|
|
|
2015-09-14 20:52:43 +03:00
|
|
|
/* For TalkBack's "Control" granularity. Form conrols and links */
|
|
|
|
Control: new BaseTraversalRule(
|
|
|
|
[Roles.PUSHBUTTON,
|
|
|
|
Roles.SPINBUTTON,
|
|
|
|
Roles.TOGGLE_BUTTON,
|
|
|
|
Roles.BUTTONDROPDOWN,
|
|
|
|
Roles.BUTTONDROPDOWNGRID,
|
|
|
|
Roles.COMBOBOX,
|
|
|
|
Roles.LISTBOX,
|
|
|
|
Roles.ENTRY,
|
|
|
|
Roles.PASSWORD_TEXT,
|
|
|
|
Roles.PAGETAB,
|
|
|
|
Roles.RADIOBUTTON,
|
|
|
|
Roles.RADIO_MENU_ITEM,
|
|
|
|
Roles.SLIDER,
|
|
|
|
Roles.CHECKBUTTON,
|
|
|
|
Roles.CHECK_MENU_ITEM,
|
|
|
|
Roles.SWITCH,
|
|
|
|
Roles.LINK,
|
|
|
|
Roles.MENUITEM],
|
2017-08-01 21:08:02 +03:00
|
|
|
function Control_match(aAccessible) {
|
2015-09-14 20:52:43 +03:00
|
|
|
// We want to ignore anchors, only focus real links.
|
|
|
|
if (aAccessible.role == Roles.LINK &&
|
|
|
|
!Utils.getState(aAccessible).contains(States.LINKED)) {
|
|
|
|
return Filters.IGNORE;
|
|
|
|
}
|
|
|
|
return Filters.MATCH;
|
|
|
|
}),
|
|
|
|
|
2012-10-02 00:33:26 +04:00
|
|
|
List: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.LIST,
|
2015-09-02 19:44:30 +03:00
|
|
|
Roles.DEFINITION_LIST],
|
|
|
|
null, null, true),
|
2012-10-02 00:33:26 +04:00
|
|
|
|
|
|
|
PageTab: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.PAGETAB]),
|
2012-10-02 00:33:26 +04:00
|
|
|
|
2013-07-25 01:52:57 +04:00
|
|
|
Paragraph: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.PARAGRAPH,
|
|
|
|
Roles.SECTION],
|
2013-07-25 01:52:57 +04:00
|
|
|
function Paragraph_match(aAccessible) {
|
|
|
|
for (let child = aAccessible.firstChild; child; child = child.nextSibling) {
|
2013-11-19 22:17:43 +04:00
|
|
|
if (child.role === Roles.TEXT_LEAF) {
|
|
|
|
return Filters.MATCH | Filters.IGNORE_SUBTREE;
|
2013-07-25 01:52:57 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-19 22:17:43 +04:00
|
|
|
return Filters.IGNORE;
|
2013-07-25 01:52:57 +04:00
|
|
|
}),
|
|
|
|
|
2012-10-02 00:33:26 +04:00
|
|
|
RadioButton: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.RADIOBUTTON,
|
|
|
|
Roles.RADIO_MENU_ITEM]),
|
2012-10-02 00:33:26 +04:00
|
|
|
|
|
|
|
Separator: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.SEPARATOR]),
|
2012-10-02 00:33:26 +04:00
|
|
|
|
|
|
|
Table: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.TABLE]),
|
2012-10-02 00:33:26 +04:00
|
|
|
|
|
|
|
Checkbox: new BaseTraversalRule(
|
2013-11-19 22:17:43 +04:00
|
|
|
[Roles.CHECKBUTTON,
|
2015-05-29 18:55:53 +03:00
|
|
|
Roles.CHECK_MENU_ITEM,
|
|
|
|
Roles.SWITCH /* A type of checkbox that represents on/off values */]),
|
2013-06-18 00:25:24 +04:00
|
|
|
|
|
|
|
_shouldSkipImage: function _shouldSkipImage(aAccessible) {
|
2017-08-01 19:13:27 +03:00
|
|
|
if (gSkipEmptyImages.value && aAccessible.name === "") {
|
2013-11-19 22:17:43 +04:00
|
|
|
return Filters.IGNORE;
|
2013-06-18 00:25:24 +04:00
|
|
|
}
|
2013-11-19 22:17:43 +04:00
|
|
|
return Filters.MATCH;
|
2013-06-18 00:25:24 +04:00
|
|
|
}
|
2012-10-02 00:33:26 +04:00
|
|
|
};
|
2015-09-02 19:44:30 +03:00
|
|
|
|
|
|
|
this.TraversalHelper = {
|
|
|
|
_helperPivotCache: null,
|
|
|
|
|
|
|
|
get helperPivotCache() {
|
|
|
|
delete this.helperPivotCache;
|
|
|
|
this.helperPivotCache = new WeakMap();
|
|
|
|
return this.helperPivotCache;
|
|
|
|
},
|
|
|
|
|
|
|
|
getHelperPivot: function TraversalHelper_getHelperPivot(aRoot) {
|
|
|
|
let pivot = this.helperPivotCache.get(aRoot.DOMNode);
|
|
|
|
if (!pivot) {
|
2016-08-08 18:47:48 +03:00
|
|
|
pivot = Utils.AccService.createAccessiblePivot(aRoot);
|
2015-09-02 19:44:30 +03:00
|
|
|
this.helperPivotCache.set(aRoot.DOMNode, pivot);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pivot;
|
|
|
|
},
|
|
|
|
|
|
|
|
move: function TraversalHelper_move(aVirtualCursor, aMethod, aRule) {
|
|
|
|
let rule = TraversalRules[aRule];
|
|
|
|
|
|
|
|
if (rule.containerRule) {
|
|
|
|
let moved = false;
|
|
|
|
let helperPivot = this.getHelperPivot(aVirtualCursor.root);
|
|
|
|
helperPivot.position = aVirtualCursor.position;
|
|
|
|
|
|
|
|
// We continue to step through containers until there is one with an
|
|
|
|
// atomic child (via 'Simple') on which we could land.
|
|
|
|
while (!moved) {
|
|
|
|
if (helperPivot[aMethod](rule)) {
|
|
|
|
aVirtualCursor.modalRoot = helperPivot.position;
|
|
|
|
moved = aVirtualCursor.moveFirst(TraversalRules.Simple);
|
|
|
|
aVirtualCursor.modalRoot = null;
|
|
|
|
} else {
|
|
|
|
// If we failed to step to another container, break and return false.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return moved;
|
|
|
|
}
|
2017-08-01 21:08:02 +03:00
|
|
|
return aVirtualCursor[aMethod](rule);
|
|
|
|
|
2015-09-02 19:44:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|