2012-04-13 23:18:57 +00: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/. */
|
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
/* global Components, XPCOMUtils, Utils, PrefCache, States, Roles, Logger */
|
|
|
|
/* exported UtteranceGenerator, BrailleGenerator */
|
|
|
|
|
2012-04-13 23:18:57 +00:00
|
|
|
'use strict';
|
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
const {utils: Cu, interfaces: Ci} = Components;
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-24 18:46:04 +00:00
|
|
|
const INCLUDE_DESC = 0x01;
|
2012-04-13 23:18:57 +00:00
|
|
|
const INCLUDE_NAME = 0x02;
|
2013-10-14 19:56:19 +00:00
|
|
|
const INCLUDE_VALUE = 0x04;
|
|
|
|
const NAME_FROM_SUBTREE_RULE = 0x10;
|
2014-02-24 21:19:33 +00:00
|
|
|
const IGNORE_EXPLICIT_NAME = 0x20;
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
const OUTPUT_DESC_FIRST = 0;
|
|
|
|
const OUTPUT_DESC_LAST = 1;
|
2013-04-04 22:16:37 +00:00
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
2014-08-06 13:38:56 +00:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Utils', // jshint ignore:line
|
2013-06-17 14:36:41 +00:00
|
|
|
'resource://gre/modules/accessibility/Utils.jsm');
|
2014-08-06 13:38:56 +00:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'PrefCache', // jshint ignore:line
|
2013-06-17 14:36:41 +00:00
|
|
|
'resource://gre/modules/accessibility/Utils.jsm');
|
2014-08-06 13:38:56 +00:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Logger', // jshint ignore:line
|
2013-06-27 21:15:36 +00:00
|
|
|
'resource://gre/modules/accessibility/Utils.jsm');
|
2014-08-06 13:38:56 +00:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Roles', // jshint ignore:line
|
2013-11-19 18:17:43 +00:00
|
|
|
'resource://gre/modules/accessibility/Constants.jsm');
|
2014-08-06 13:38:56 +00:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'States', // jshint ignore:line
|
2014-01-28 00:35:13 +00:00
|
|
|
'resource://gre/modules/accessibility/Constants.jsm');
|
2013-06-27 21:15:36 +00:00
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
this.EXPORTED_SYMBOLS = ['UtteranceGenerator', 'BrailleGenerator']; // jshint ignore:line
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2015-09-15 18:19:45 +00:00
|
|
|
var OutputGenerator = {
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2013-07-10 14:25:57 +00:00
|
|
|
defaultOutputOrder: OUTPUT_DESC_LAST,
|
|
|
|
|
2013-04-04 22:16:37 +00:00
|
|
|
/**
|
2013-06-17 14:36:41 +00:00
|
|
|
* Generates output for a PivotContext.
|
2013-04-04 22:16:37 +00:00
|
|
|
* @param {PivotContext} aContext object that generates and caches
|
|
|
|
* context information for a given accessible and its relationship with
|
|
|
|
* another accessible.
|
2014-08-06 13:38:50 +00:00
|
|
|
* @return {Object} An array of speech data. Depending on the utterance order,
|
|
|
|
* the data describes the context for an accessible object either
|
2013-04-04 22:16:37 +00:00
|
|
|
* starting from the accessible's ancestry or accessible's subtree.
|
|
|
|
*/
|
|
|
|
genForContext: function genForContext(aContext) {
|
2013-06-17 14:36:41 +00:00
|
|
|
let output = [];
|
|
|
|
let self = this;
|
|
|
|
let addOutput = function addOutput(aAccessible) {
|
2013-06-27 21:15:36 +00:00
|
|
|
output.push.apply(output, self.genForObject(aAccessible, aContext));
|
2013-04-04 22:16:37 +00:00
|
|
|
};
|
2013-06-10 20:31:17 +00:00
|
|
|
let ignoreSubtree = function ignoreSubtree(aAccessible) {
|
2016-08-08 15:47:48 +00:00
|
|
|
let roleString = Utils.AccService.getStringRole(aAccessible.role);
|
2013-06-17 14:36:41 +00:00
|
|
|
let nameRule = self.roleRuleMap[roleString] || 0;
|
2013-06-10 20:31:17 +00:00
|
|
|
// Ignore subtree if the name is explicit and the role's name rule is the
|
|
|
|
// NAME_FROM_SUBTREE_RULE.
|
2013-10-14 19:56:19 +00:00
|
|
|
return (((nameRule & INCLUDE_VALUE) && aAccessible.value) ||
|
|
|
|
((nameRule & NAME_FROM_SUBTREE_RULE) &&
|
2014-02-24 21:19:33 +00:00
|
|
|
(Utils.getAttributes(aAccessible)['explicit-name'] === 'true' &&
|
|
|
|
!(nameRule & IGNORE_EXPLICIT_NAME))));
|
2013-06-10 20:31:17 +00:00
|
|
|
};
|
2013-07-09 20:09:25 +00:00
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
let contextStart = this._getContextStart(aContext);
|
|
|
|
|
2013-07-09 20:09:25 +00:00
|
|
|
if (this.outputOrder === OUTPUT_DESC_FIRST) {
|
2013-06-17 14:36:41 +00:00
|
|
|
contextStart.forEach(addOutput);
|
|
|
|
addOutput(aContext.accessible);
|
2015-10-18 14:21:31 +00:00
|
|
|
for (let node of aContext.subtreeGenerator(true, ignoreSubtree)) {
|
|
|
|
addOutput(node);
|
|
|
|
}
|
2013-04-04 22:16:37 +00:00
|
|
|
} else {
|
2015-10-18 14:21:31 +00:00
|
|
|
for (let node of aContext.subtreeGenerator(false, ignoreSubtree)) {
|
|
|
|
addOutput(node);
|
|
|
|
}
|
2013-06-17 14:36:41 +00:00
|
|
|
addOutput(aContext.accessible);
|
2015-10-14 15:24:36 +00:00
|
|
|
|
|
|
|
// If there are any documents in new ancestry, find a first one and place
|
|
|
|
// it in the beginning of the utterance.
|
|
|
|
let doc, docIndex = contextStart.findIndex(
|
|
|
|
ancestor => ancestor.role === Roles.DOCUMENT);
|
|
|
|
|
|
|
|
if (docIndex > -1) {
|
|
|
|
doc = contextStart.splice(docIndex, 1)[0];
|
|
|
|
}
|
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
contextStart.reverse().forEach(addOutput);
|
2015-10-14 15:24:36 +00:00
|
|
|
if (doc) {
|
|
|
|
output.unshift.apply(output, self.genForObject(doc, aContext));
|
|
|
|
}
|
2013-04-04 22:16:37 +00:00
|
|
|
}
|
|
|
|
|
2014-08-06 13:38:50 +00:00
|
|
|
return output;
|
2013-04-04 22:16:37 +00:00
|
|
|
},
|
|
|
|
|
2012-05-07 16:44:44 +00:00
|
|
|
|
|
|
|
/**
|
2013-06-17 14:36:41 +00:00
|
|
|
* Generates output for an object.
|
2013-07-09 20:09:25 +00:00
|
|
|
* @param {nsIAccessible} aAccessible accessible object to generate output
|
2012-05-07 16:44:44 +00:00
|
|
|
* for.
|
2013-06-27 21:15:36 +00:00
|
|
|
* @param {PivotContext} aContext object that generates and caches
|
|
|
|
* context information for a given accessible and its relationship with
|
|
|
|
* another accessible.
|
2014-08-06 13:38:50 +00:00
|
|
|
* @return {Array} A 2 element array of speech data. The first element
|
|
|
|
* describes the object and its state. The second element is the object's
|
|
|
|
* name. Whether the object's description or it's role is included is
|
|
|
|
* determined by {@link roleRuleMap}.
|
2012-05-07 16:44:44 +00:00
|
|
|
*/
|
2013-06-27 21:15:36 +00:00
|
|
|
genForObject: function genForObject(aAccessible, aContext) {
|
2016-08-08 15:47:48 +00:00
|
|
|
let roleString = Utils.AccService.getStringRole(aAccessible.role);
|
2013-06-27 21:15:36 +00:00
|
|
|
let func = this.objectOutputFunctions[
|
|
|
|
OutputGenerator._getOutputName(roleString)] ||
|
2013-06-17 14:36:41 +00:00
|
|
|
this.objectOutputFunctions.defaultFunc;
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2013-05-28 17:51:44 +00:00
|
|
|
let flags = this.roleRuleMap[roleString] || 0;
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
if (aAccessible.childCount === 0) {
|
2012-04-13 23:18:57 +00:00
|
|
|
flags |= INCLUDE_NAME;
|
2014-08-06 13:38:56 +00:00
|
|
|
}
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
return func.apply(this, [aAccessible, roleString,
|
|
|
|
Utils.getState(aAccessible), flags, aContext]);
|
2012-04-13 23:18:57 +00:00
|
|
|
},
|
|
|
|
|
2012-05-07 16:44:44 +00:00
|
|
|
/**
|
2013-06-17 14:36:41 +00:00
|
|
|
* Generates output for an action performed.
|
2012-05-07 16:44:44 +00:00
|
|
|
* @param {nsIAccessible} aAccessible accessible object that the action was
|
|
|
|
* invoked in.
|
|
|
|
* @param {string} aActionName the name of the action, one of the keys in
|
|
|
|
* {@link gActionMap}.
|
2014-08-06 13:38:50 +00:00
|
|
|
* @return {Array} A one element array with action data.
|
2012-05-07 16:44:44 +00:00
|
|
|
*/
|
2014-08-06 13:38:56 +00:00
|
|
|
genForAction: function genForAction(aObject, aActionName) {}, // jshint ignore:line
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-12-07 18:39:17 +00:00
|
|
|
/**
|
2014-08-06 13:38:50 +00:00
|
|
|
* Generates output for an announcement.
|
2012-12-07 18:39:17 +00:00
|
|
|
* @param {string} aAnnouncement unlocalized announcement.
|
2014-08-06 13:38:50 +00:00
|
|
|
* @return {Array} An announcement speech data to be localized.
|
2012-12-07 18:39:17 +00:00
|
|
|
*/
|
2014-08-06 13:38:56 +00:00
|
|
|
genForAnnouncement: function genForAnnouncement(aAnnouncement) {}, // jshint ignore:line
|
2012-12-07 18:39:17 +00:00
|
|
|
|
2012-05-07 16:44:44 +00:00
|
|
|
/**
|
2013-06-17 14:36:41 +00:00
|
|
|
* Generates output for a tab state change.
|
2012-05-07 16:44:44 +00:00
|
|
|
* @param {nsIAccessible} aAccessible accessible object of the tab's attached
|
|
|
|
* document.
|
|
|
|
* @param {string} aTabState the tab state name, see
|
|
|
|
* {@link Presenter.tabStateChanged}.
|
|
|
|
* @return {Array} The tab state utterace.
|
|
|
|
*/
|
2014-08-06 13:38:56 +00:00
|
|
|
genForTabStateChange: function genForTabStateChange(aObject, aTabState) {}, // jshint ignore:line
|
2012-05-07 16:44:44 +00:00
|
|
|
|
2012-07-10 23:10:15 +00:00
|
|
|
/**
|
2013-06-17 14:36:41 +00:00
|
|
|
* Generates output for announcing entering and leaving editing mode.
|
2012-07-10 23:10:15 +00:00
|
|
|
* @param {aIsEditing} boolean true if we are in editing mode
|
|
|
|
* @return {Array} The mode utterance
|
|
|
|
*/
|
2014-08-06 13:38:56 +00:00
|
|
|
genForEditingMode: function genForEditingMode(aIsEditing) {}, // jshint ignore:line
|
2013-06-17 14:36:41 +00:00
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
_getContextStart: function getContextStart(aContext) {}, // jshint ignore:line
|
2013-06-17 14:36:41 +00:00
|
|
|
|
2014-08-06 13:38:50 +00:00
|
|
|
/**
|
|
|
|
* Adds an accessible name and description to the output if available.
|
|
|
|
* @param {Array} aOutput Output array.
|
|
|
|
* @param {nsIAccessible} aAccessible current accessible object.
|
|
|
|
* @param {Number} aFlags output flags.
|
|
|
|
*/
|
2013-06-17 14:36:41 +00:00
|
|
|
_addName: function _addName(aOutput, aAccessible, aFlags) {
|
|
|
|
let name;
|
2014-02-24 21:19:33 +00:00
|
|
|
if ((Utils.getAttributes(aAccessible)['explicit-name'] === 'true' &&
|
|
|
|
!(aFlags & IGNORE_EXPLICIT_NAME)) || (aFlags & INCLUDE_NAME)) {
|
2013-06-17 14:36:41 +00:00
|
|
|
name = aAccessible.name;
|
|
|
|
}
|
|
|
|
|
2013-07-23 08:40:49 +00:00
|
|
|
let description = aAccessible.description;
|
|
|
|
if (description) {
|
|
|
|
// Compare against the calculated name unconditionally, regardless of name rule,
|
|
|
|
// so we can make sure we don't speak duplicated descriptions
|
|
|
|
let tmpName = name || aAccessible.name;
|
|
|
|
if (tmpName && (description !== tmpName)) {
|
|
|
|
name = name || '';
|
|
|
|
name = this.outputOrder === OUTPUT_DESC_FIRST ?
|
|
|
|
description + ' - ' + name :
|
|
|
|
name + ' - ' + description;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-06 13:38:50 +00:00
|
|
|
if (!name || !name.trim()) {
|
|
|
|
return;
|
2013-06-17 14:36:41 +00:00
|
|
|
}
|
2014-08-06 13:38:50 +00:00
|
|
|
aOutput[this.outputOrder === OUTPUT_DESC_FIRST ? 'push' : 'unshift'](name);
|
2012-07-10 23:10:15 +00:00
|
|
|
},
|
|
|
|
|
2013-07-09 20:09:25 +00:00
|
|
|
/**
|
|
|
|
* Adds a landmark role to the output if available.
|
|
|
|
* @param {Array} aOutput Output array.
|
|
|
|
* @param {nsIAccessible} aAccessible current accessible object.
|
|
|
|
*/
|
|
|
|
_addLandmark: function _addLandmark(aOutput, aAccessible) {
|
2013-07-11 20:42:11 +00:00
|
|
|
let landmarkName = Utils.getLandmarkName(aAccessible);
|
|
|
|
if (!landmarkName) {
|
|
|
|
return;
|
|
|
|
}
|
2014-08-06 13:38:50 +00:00
|
|
|
aOutput[this.outputOrder === OUTPUT_DESC_FIRST ? 'unshift' : 'push']({
|
|
|
|
string: landmarkName
|
|
|
|
});
|
2013-07-09 20:09:25 +00:00
|
|
|
},
|
|
|
|
|
2015-07-13 09:53:00 +00:00
|
|
|
/**
|
|
|
|
* Adds math roles to the output, for a MathML accessible.
|
|
|
|
* @param {Array} aOutput Output array.
|
|
|
|
* @param {nsIAccessible} aAccessible current accessible object.
|
|
|
|
* @param {String} aRoleStr aAccessible's role string.
|
|
|
|
*/
|
|
|
|
_addMathRoles: function _addMathRoles(aOutput, aAccessible, aRoleStr) {
|
|
|
|
// First, determine the actual role to use (e.g. mathmlfraction).
|
|
|
|
let roleStr = aRoleStr;
|
|
|
|
switch(aAccessible.role) {
|
|
|
|
case Roles.MATHML_CELL:
|
|
|
|
case Roles.MATHML_ENCLOSED:
|
|
|
|
case Roles.MATHML_LABELED_ROW:
|
|
|
|
case Roles.MATHML_ROOT:
|
|
|
|
case Roles.MATHML_SQUARE_ROOT:
|
|
|
|
case Roles.MATHML_TABLE:
|
|
|
|
case Roles.MATHML_TABLE_ROW:
|
|
|
|
// Use the default role string.
|
|
|
|
break;
|
|
|
|
case Roles.MATHML_MULTISCRIPTS:
|
|
|
|
case Roles.MATHML_OVER:
|
|
|
|
case Roles.MATHML_SUB:
|
|
|
|
case Roles.MATHML_SUB_SUP:
|
|
|
|
case Roles.MATHML_SUP:
|
|
|
|
case Roles.MATHML_UNDER:
|
|
|
|
case Roles.MATHML_UNDER_OVER:
|
|
|
|
// For scripted accessibles, use the string 'mathmlscripted'.
|
|
|
|
roleStr = 'mathmlscripted';
|
|
|
|
break;
|
|
|
|
case Roles.MATHML_FRACTION:
|
|
|
|
// From a semantic point of view, the only important point is to
|
|
|
|
// distinguish between fractions that have a bar and those that do not.
|
|
|
|
// Per the MathML 3 spec, the latter happens iff the linethickness
|
|
|
|
// attribute is of the form [zero-float][optional-unit]. In that case,
|
|
|
|
// we use the string 'mathmlfractionwithoutbar'.
|
|
|
|
let linethickness = Utils.getAttributes(aAccessible).linethickness;
|
|
|
|
if (linethickness) {
|
|
|
|
let numberMatch = linethickness.match(/^(?:\d|\.)+/);
|
|
|
|
if (numberMatch && !parseFloat(numberMatch[0])) {
|
|
|
|
roleStr += 'withoutbar';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Otherwise, do not output the actual role.
|
|
|
|
roleStr = null;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the math role based on the position in the parent accessible
|
|
|
|
// (e.g. numerator for the first child of a mathmlfraction).
|
|
|
|
let mathRole = Utils.getMathRole(aAccessible);
|
|
|
|
if (mathRole) {
|
|
|
|
aOutput[this.outputOrder === OUTPUT_DESC_FIRST ? 'push' : 'unshift']
|
|
|
|
({string: this._getOutputName(mathRole)});
|
|
|
|
}
|
|
|
|
if (roleStr) {
|
|
|
|
aOutput[this.outputOrder === OUTPUT_DESC_FIRST ? 'push' : 'unshift']
|
|
|
|
({string: this._getOutputName(roleStr)});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds MathML menclose notations to the output.
|
|
|
|
* @param {Array} aOutput Output array.
|
|
|
|
* @param {nsIAccessible} aAccessible current accessible object.
|
|
|
|
*/
|
|
|
|
_addMencloseNotations: function _addMencloseNotations(aOutput, aAccessible) {
|
|
|
|
let notations = Utils.getAttributes(aAccessible).notation || 'longdiv';
|
|
|
|
aOutput[this.outputOrder === OUTPUT_DESC_FIRST ? 'push' : 'unshift'].apply(
|
2016-05-02 15:09:28 +00:00
|
|
|
aOutput, notations.split(' ').map(notation => {
|
|
|
|
return { string: this._getOutputName('notation-' + notation) };
|
|
|
|
}));
|
2015-07-13 09:53:00 +00:00
|
|
|
},
|
|
|
|
|
2013-10-25 03:21:29 +00:00
|
|
|
/**
|
|
|
|
* Adds an entry type attribute to the description if available.
|
2014-08-06 13:38:50 +00:00
|
|
|
* @param {Array} aOutput Output array.
|
2013-10-25 03:21:29 +00:00
|
|
|
* @param {nsIAccessible} aAccessible current accessible object.
|
|
|
|
* @param {String} aRoleStr aAccessible's role string.
|
|
|
|
*/
|
2014-08-06 13:38:50 +00:00
|
|
|
_addType: function _addType(aOutput, aAccessible, aRoleStr) {
|
2013-10-25 03:21:29 +00:00
|
|
|
if (aRoleStr !== 'entry') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let typeName = Utils.getAttributes(aAccessible)['text-input-type'];
|
2013-11-01 13:38:41 +00:00
|
|
|
// Ignore the the input type="text" case.
|
|
|
|
if (!typeName || typeName === 'text') {
|
2013-10-25 03:21:29 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-08-06 13:38:50 +00:00
|
|
|
aOutput.push({string: 'textInputType_' + typeName});
|
2013-10-25 03:21:29 +00:00
|
|
|
},
|
|
|
|
|
2015-05-29 15:55:53 +00:00
|
|
|
_addState: function _addState(aOutput, aState, aRoleStr) {}, // jshint ignore:line
|
2014-08-06 13:38:50 +00:00
|
|
|
|
2015-07-13 09:53:00 +00:00
|
|
|
_addRole: function _addRole(aOutput, aAccessible, aRoleStr) {}, // jshint ignore:line
|
2014-08-06 13:38:50 +00:00
|
|
|
|
2013-07-09 20:09:25 +00:00
|
|
|
get outputOrder() {
|
|
|
|
if (!this._utteranceOrder) {
|
|
|
|
this._utteranceOrder = new PrefCache('accessibility.accessfu.utterance');
|
|
|
|
}
|
|
|
|
return typeof this._utteranceOrder.value === 'number' ?
|
|
|
|
this._utteranceOrder.value : this.defaultOutputOrder;
|
|
|
|
},
|
|
|
|
|
2013-06-27 21:15:36 +00:00
|
|
|
_getOutputName: function _getOutputName(aName) {
|
2015-02-25 21:33:34 +00:00
|
|
|
return aName.replace(/\s/g, '');
|
2013-06-27 21:15:36 +00:00
|
|
|
},
|
|
|
|
|
2013-05-28 17:51:44 +00:00
|
|
|
roleRuleMap: {
|
2012-05-24 18:46:04 +00:00
|
|
|
'menubar': INCLUDE_DESC,
|
|
|
|
'scrollbar': INCLUDE_DESC,
|
|
|
|
'grip': INCLUDE_DESC,
|
2012-05-29 20:46:08 +00:00
|
|
|
'alert': INCLUDE_DESC | INCLUDE_NAME,
|
2012-05-24 18:46:04 +00:00
|
|
|
'menupopup': INCLUDE_DESC,
|
2013-05-28 17:51:44 +00:00
|
|
|
'menuitem': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
|
|
|
'tooltip': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
2013-06-27 21:15:36 +00:00
|
|
|
'columnheader': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
|
|
|
'rowheader': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
2013-05-28 17:51:44 +00:00
|
|
|
'column': NAME_FROM_SUBTREE_RULE,
|
|
|
|
'row': NAME_FROM_SUBTREE_RULE,
|
2013-06-27 21:15:36 +00:00
|
|
|
'cell': INCLUDE_DESC | INCLUDE_NAME,
|
2012-04-13 23:18:57 +00:00
|
|
|
'application': INCLUDE_NAME,
|
|
|
|
'document': INCLUDE_NAME,
|
2012-05-29 20:46:08 +00:00
|
|
|
'grouping': INCLUDE_DESC | INCLUDE_NAME,
|
2012-05-24 18:46:04 +00:00
|
|
|
'toolbar': INCLUDE_DESC,
|
2012-05-29 20:46:08 +00:00
|
|
|
'table': INCLUDE_DESC | INCLUDE_NAME,
|
2013-05-28 17:51:44 +00:00
|
|
|
'link': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
|
|
|
'helpballoon': NAME_FROM_SUBTREE_RULE,
|
2012-11-14 18:20:50 +00:00
|
|
|
'list': INCLUDE_DESC | INCLUDE_NAME,
|
2013-05-28 17:51:44 +00:00
|
|
|
'listitem': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
2012-05-24 18:46:04 +00:00
|
|
|
'outline': INCLUDE_DESC,
|
2013-05-28 17:51:44 +00:00
|
|
|
'outlineitem': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
|
|
|
'pagetab': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
2012-05-29 20:46:08 +00:00
|
|
|
'graphic': INCLUDE_DESC,
|
2015-05-29 15:55:53 +00:00
|
|
|
'switch': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
2013-05-28 17:51:44 +00:00
|
|
|
'pushbutton': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
|
|
|
'checkbutton': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
|
|
|
'radiobutton': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
|
|
|
'buttondropdown': NAME_FROM_SUBTREE_RULE,
|
2014-10-22 04:39:49 +00:00
|
|
|
'combobox': INCLUDE_DESC | INCLUDE_VALUE,
|
2012-05-24 18:46:04 +00:00
|
|
|
'droplist': INCLUDE_DESC,
|
2013-10-14 19:56:19 +00:00
|
|
|
'progressbar': INCLUDE_DESC | INCLUDE_VALUE,
|
|
|
|
'slider': INCLUDE_DESC | INCLUDE_VALUE,
|
|
|
|
'spinbutton': INCLUDE_DESC | INCLUDE_VALUE,
|
2012-05-24 18:46:04 +00:00
|
|
|
'diagram': INCLUDE_DESC,
|
|
|
|
'animation': INCLUDE_DESC,
|
|
|
|
'equation': INCLUDE_DESC,
|
2013-05-28 17:51:44 +00:00
|
|
|
'buttonmenu': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
|
|
|
'buttondropdowngrid': NAME_FROM_SUBTREE_RULE,
|
2012-05-24 18:46:04 +00:00
|
|
|
'pagetablist': INCLUDE_DESC,
|
|
|
|
'canvas': INCLUDE_DESC,
|
2013-05-28 17:51:44 +00:00
|
|
|
'check menu item': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
|
|
|
'label': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
2012-05-24 18:46:04 +00:00
|
|
|
'password text': INCLUDE_DESC,
|
|
|
|
'popup menu': INCLUDE_DESC,
|
2013-05-28 17:51:44 +00:00
|
|
|
'radio menu item': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
|
|
|
'table column header': NAME_FROM_SUBTREE_RULE,
|
|
|
|
'table row header': NAME_FROM_SUBTREE_RULE,
|
|
|
|
'tear off menu item': NAME_FROM_SUBTREE_RULE,
|
|
|
|
'toggle button': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
|
|
|
'parent menuitem': NAME_FROM_SUBTREE_RULE,
|
2012-05-24 18:46:04 +00:00
|
|
|
'header': INCLUDE_DESC,
|
|
|
|
'footer': INCLUDE_DESC,
|
2013-10-14 19:56:19 +00:00
|
|
|
'entry': INCLUDE_DESC | INCLUDE_NAME | INCLUDE_VALUE,
|
2012-05-24 18:46:04 +00:00
|
|
|
'caption': INCLUDE_DESC,
|
|
|
|
'document frame': INCLUDE_DESC,
|
|
|
|
'heading': INCLUDE_DESC,
|
2012-05-29 20:46:08 +00:00
|
|
|
'calendar': INCLUDE_DESC | INCLUDE_NAME,
|
2013-05-28 17:51:44 +00:00
|
|
|
'combobox option': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
2013-09-26 19:59:21 +00:00
|
|
|
'listbox option': INCLUDE_DESC | NAME_FROM_SUBTREE_RULE,
|
2013-05-28 17:51:44 +00:00
|
|
|
'listbox rich option': NAME_FROM_SUBTREE_RULE,
|
|
|
|
'gridcell': NAME_FROM_SUBTREE_RULE,
|
|
|
|
'check rich option': NAME_FROM_SUBTREE_RULE,
|
|
|
|
'term': NAME_FROM_SUBTREE_RULE,
|
|
|
|
'definition': NAME_FROM_SUBTREE_RULE,
|
|
|
|
'key': NAME_FROM_SUBTREE_RULE,
|
2012-05-24 18:46:04 +00:00
|
|
|
'image map': INCLUDE_DESC,
|
|
|
|
'option': INCLUDE_DESC,
|
2012-11-14 18:20:50 +00:00
|
|
|
'listbox': INCLUDE_DESC,
|
2014-01-29 23:08:53 +00:00
|
|
|
'definitionlist': INCLUDE_DESC | INCLUDE_NAME,
|
2014-02-24 21:19:33 +00:00
|
|
|
'dialog': INCLUDE_DESC | INCLUDE_NAME,
|
|
|
|
'chrome window': IGNORE_EXPLICIT_NAME,
|
2015-07-06 18:38:35 +00:00
|
|
|
'app root': IGNORE_EXPLICIT_NAME,
|
2015-07-13 09:53:00 +00:00
|
|
|
'statusbar': NAME_FROM_SUBTREE_RULE,
|
|
|
|
'mathml table': INCLUDE_DESC | INCLUDE_NAME,
|
|
|
|
'mathml labeled row': NAME_FROM_SUBTREE_RULE,
|
|
|
|
'mathml table row': NAME_FROM_SUBTREE_RULE,
|
|
|
|
'mathml cell': INCLUDE_DESC | INCLUDE_NAME,
|
|
|
|
'mathml fraction': INCLUDE_DESC,
|
|
|
|
'mathml square root': INCLUDE_DESC,
|
|
|
|
'mathml root': INCLUDE_DESC,
|
|
|
|
'mathml enclosed': INCLUDE_DESC,
|
|
|
|
'mathml sub': INCLUDE_DESC,
|
|
|
|
'mathml sup': INCLUDE_DESC,
|
|
|
|
'mathml sub sup': INCLUDE_DESC,
|
|
|
|
'mathml under': INCLUDE_DESC,
|
|
|
|
'mathml over': INCLUDE_DESC,
|
|
|
|
'mathml under over': INCLUDE_DESC,
|
|
|
|
'mathml multiscripts': INCLUDE_DESC,
|
|
|
|
'mathml identifier': INCLUDE_DESC,
|
|
|
|
'mathml number': INCLUDE_DESC,
|
|
|
|
'mathml operator': INCLUDE_DESC,
|
|
|
|
'mathml text': INCLUDE_DESC,
|
|
|
|
'mathml string literal': INCLUDE_DESC,
|
|
|
|
'mathml row': INCLUDE_DESC,
|
|
|
|
'mathml style': INCLUDE_DESC,
|
|
|
|
'mathml error': INCLUDE_DESC },
|
|
|
|
|
|
|
|
mathmlRolesSet: new Set([
|
|
|
|
Roles.MATHML_MATH,
|
|
|
|
Roles.MATHML_IDENTIFIER,
|
|
|
|
Roles.MATHML_NUMBER,
|
|
|
|
Roles.MATHML_OPERATOR,
|
|
|
|
Roles.MATHML_TEXT,
|
|
|
|
Roles.MATHML_STRING_LITERAL,
|
|
|
|
Roles.MATHML_GLYPH,
|
|
|
|
Roles.MATHML_ROW,
|
|
|
|
Roles.MATHML_FRACTION,
|
|
|
|
Roles.MATHML_SQUARE_ROOT,
|
|
|
|
Roles.MATHML_ROOT,
|
|
|
|
Roles.MATHML_FENCED,
|
|
|
|
Roles.MATHML_ENCLOSED,
|
|
|
|
Roles.MATHML_STYLE,
|
|
|
|
Roles.MATHML_SUB,
|
|
|
|
Roles.MATHML_SUP,
|
|
|
|
Roles.MATHML_SUB_SUP,
|
|
|
|
Roles.MATHML_UNDER,
|
|
|
|
Roles.MATHML_OVER,
|
|
|
|
Roles.MATHML_UNDER_OVER,
|
|
|
|
Roles.MATHML_MULTISCRIPTS,
|
|
|
|
Roles.MATHML_TABLE,
|
|
|
|
Roles.LABELED_ROW,
|
|
|
|
Roles.MATHML_TABLE_ROW,
|
|
|
|
Roles.MATHML_CELL,
|
|
|
|
Roles.MATHML_ACTION,
|
|
|
|
Roles.MATHML_ERROR,
|
|
|
|
Roles.MATHML_STACK,
|
|
|
|
Roles.MATHML_LONG_DIVISION,
|
|
|
|
Roles.MATHML_STACK_GROUP,
|
|
|
|
Roles.MATHML_STACK_ROW,
|
|
|
|
Roles.MATHML_STACK_CARRIES,
|
|
|
|
Roles.MATHML_STACK_CARRY,
|
|
|
|
Roles.MATHML_STACK_LINE
|
|
|
|
]),
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
objectOutputFunctions: {
|
2014-08-06 13:38:56 +00:00
|
|
|
_generateBaseOutput:
|
|
|
|
function _generateBaseOutput(aAccessible, aRoleStr, aState, aFlags) {
|
|
|
|
let output = [];
|
|
|
|
|
|
|
|
if (aFlags & INCLUDE_DESC) {
|
2015-05-29 15:55:53 +00:00
|
|
|
this._addState(output, aState, aRoleStr);
|
2014-08-06 13:38:56 +00:00
|
|
|
this._addType(output, aAccessible, aRoleStr);
|
2015-07-13 09:53:00 +00:00
|
|
|
this._addRole(output, aAccessible, aRoleStr);
|
2014-08-06 13:38:56 +00:00
|
|
|
}
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
if (aFlags & INCLUDE_VALUE && aAccessible.value.trim()) {
|
|
|
|
output[this.outputOrder === OUTPUT_DESC_FIRST ? 'push' : 'unshift'](
|
|
|
|
aAccessible.value);
|
|
|
|
}
|
2013-10-14 19:56:19 +00:00
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
this._addName(output, aAccessible, aFlags);
|
|
|
|
this._addLandmark(output, aAccessible);
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
return output;
|
|
|
|
},
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
label: function label(aAccessible, aRoleStr, aState, aFlags, aContext) {
|
2013-10-14 19:56:19 +00:00
|
|
|
if (aContext.isNestedControl ||
|
|
|
|
aContext.accessible == Utils.getEmbeddedControl(aAccessible)) {
|
|
|
|
// If we are on a nested control, or a nesting label,
|
|
|
|
// we don't need the context.
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.objectOutputFunctions.defaultFunc.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
entry: function entry(aAccessible, aRoleStr, aState, aFlags) {
|
|
|
|
let rolestr = aState.contains(States.MULTI_LINE) ? 'textarea' : 'entry';
|
2013-10-14 19:56:19 +00:00
|
|
|
return this.objectOutputFunctions.defaultFunc.apply(
|
2014-01-28 00:35:13 +00:00
|
|
|
this, [aAccessible, rolestr, aState, aFlags]);
|
2013-06-27 21:15:36 +00:00
|
|
|
},
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
pagetab: function pagetab(aAccessible, aRoleStr, aState, aFlags) {
|
2013-08-21 07:52:46 +00:00
|
|
|
let itemno = {};
|
|
|
|
let itemof = {};
|
|
|
|
aAccessible.groupPosition({}, itemof, itemno);
|
|
|
|
let output = [];
|
2014-08-06 13:38:50 +00:00
|
|
|
this._addState(output, aState);
|
2015-07-13 09:53:00 +00:00
|
|
|
this._addRole(output, aAccessible, aRoleStr);
|
2014-08-06 13:38:50 +00:00
|
|
|
output.push({
|
|
|
|
string: 'objItemOfN',
|
|
|
|
args: [itemno.value, itemof.value]
|
|
|
|
});
|
2013-08-21 07:52:46 +00:00
|
|
|
|
|
|
|
this._addName(output, aAccessible, aFlags);
|
|
|
|
this._addLandmark(output, aAccessible);
|
|
|
|
|
|
|
|
return output;
|
|
|
|
},
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
table: function table(aAccessible, aRoleStr, aState, aFlags) {
|
2013-06-27 21:15:36 +00:00
|
|
|
let output = [];
|
|
|
|
let table;
|
|
|
|
try {
|
|
|
|
table = aAccessible.QueryInterface(Ci.nsIAccessibleTable);
|
|
|
|
} catch (x) {
|
|
|
|
Logger.logException(x);
|
|
|
|
return output;
|
|
|
|
} finally {
|
|
|
|
// Check if it's a layout table, and bail out if true.
|
|
|
|
// We don't want to speak any table information for layout tables.
|
|
|
|
if (table.isProbablyForLayout()) {
|
|
|
|
return output;
|
|
|
|
}
|
2015-07-13 09:53:00 +00:00
|
|
|
this._addRole(output, aAccessible, aRoleStr);
|
2014-08-06 13:38:50 +00:00
|
|
|
output.push.call(output, {
|
|
|
|
string: this._getOutputName('tblColumnInfo'),
|
|
|
|
count: table.columnCount
|
|
|
|
}, {
|
|
|
|
string: this._getOutputName('tblRowInfo'),
|
|
|
|
count: table.rowCount
|
|
|
|
});
|
2013-06-27 21:15:36 +00:00
|
|
|
this._addName(output, aAccessible, aFlags);
|
2013-07-09 20:09:25 +00:00
|
|
|
this._addLandmark(output, aAccessible);
|
2013-06-27 21:15:36 +00:00
|
|
|
return output;
|
|
|
|
}
|
2014-10-08 01:38:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
gridcell: function gridcell(aAccessible, aRoleStr, aState, aFlags) {
|
|
|
|
let output = [];
|
|
|
|
this._addState(output, aState);
|
|
|
|
this._addName(output, aAccessible, aFlags);
|
|
|
|
this._addLandmark(output, aAccessible);
|
|
|
|
return output;
|
2015-07-13 09:53:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Use the table output functions for MathML tabular elements.
|
|
|
|
mathmltable: function mathmltable() {
|
|
|
|
return this.objectOutputFunctions.table.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
mathmlcell: function mathmlcell() {
|
|
|
|
return this.objectOutputFunctions.cell.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
mathmlenclosed: function mathmlenclosed(aAccessible, aRoleStr, aState,
|
|
|
|
aFlags, aContext) {
|
|
|
|
let output = this.objectOutputFunctions.defaultFunc.
|
|
|
|
apply(this, [aAccessible, aRoleStr, aState, aFlags, aContext]);
|
|
|
|
this._addMencloseNotations(output, aAccessible);
|
|
|
|
return output;
|
2013-06-17 14:36:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates speech utterances from objects, actions and state changes.
|
2014-08-06 13:38:50 +00:00
|
|
|
* An utterance is an array of speech data.
|
2013-06-17 14:36:41 +00:00
|
|
|
*
|
|
|
|
* It should not be assumed that flattening an utterance array would create a
|
|
|
|
* gramatically correct sentence. For example, {@link genForObject} might
|
|
|
|
* return: ['graphic', 'Welcome to my home page'].
|
|
|
|
* Each string element in an utterance should be gramatically correct in itself.
|
|
|
|
* Another example from {@link genForObject}: ['list item 2 of 5', 'Alabama'].
|
|
|
|
*
|
|
|
|
* An utterance is ordered from the least to the most important. Speaking the
|
|
|
|
* last string usually makes sense, but speaking the first often won't.
|
|
|
|
* For example {@link genForAction} might return ['button', 'clicked'] for a
|
|
|
|
* clicked event. Speaking only 'clicked' makes sense. Speaking 'button' does
|
|
|
|
* not.
|
|
|
|
*/
|
2014-08-06 13:38:56 +00:00
|
|
|
this.UtteranceGenerator = { // jshint ignore:line
|
2015-05-29 15:55:53 +00:00
|
|
|
__proto__: OutputGenerator, // jshint ignore:line
|
2013-06-17 14:36:41 +00:00
|
|
|
|
|
|
|
gActionMap: {
|
|
|
|
jump: 'jumpAction',
|
|
|
|
press: 'pressAction',
|
|
|
|
check: 'checkAction',
|
|
|
|
uncheck: 'uncheckAction',
|
2015-05-29 15:55:53 +00:00
|
|
|
on: 'onAction',
|
|
|
|
off: 'offAction',
|
2013-06-17 14:36:41 +00:00
|
|
|
select: 'selectAction',
|
2013-11-13 00:56:24 +00:00
|
|
|
unselect: 'unselectAction',
|
2013-06-17 14:36:41 +00:00
|
|
|
open: 'openAction',
|
|
|
|
close: 'closeAction',
|
|
|
|
switch: 'switchAction',
|
|
|
|
click: 'clickAction',
|
|
|
|
collapse: 'collapseAction',
|
|
|
|
expand: 'expandAction',
|
|
|
|
activate: 'activateAction',
|
|
|
|
cycle: 'cycleAction'
|
|
|
|
},
|
|
|
|
|
|
|
|
//TODO: May become more verbose in the future.
|
|
|
|
genForAction: function genForAction(aObject, aActionName) {
|
2014-08-06 13:38:50 +00:00
|
|
|
return [{string: this.gActionMap[aActionName]}];
|
2013-06-17 14:36:41 +00:00
|
|
|
},
|
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
genForLiveRegion:
|
|
|
|
function genForLiveRegion(aContext, aIsHide, aModifiedText) {
|
|
|
|
let utterance = [];
|
|
|
|
if (aIsHide) {
|
|
|
|
utterance.push({string: 'hidden'});
|
|
|
|
}
|
|
|
|
return utterance.concat(aModifiedText || this.genForContext(aContext));
|
|
|
|
},
|
2013-08-21 16:40:06 +00:00
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
genForAnnouncement: function genForAnnouncement(aAnnouncement) {
|
2014-08-06 13:38:50 +00:00
|
|
|
return [{
|
|
|
|
string: aAnnouncement
|
|
|
|
}];
|
2013-06-17 14:36:41 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
genForTabStateChange: function genForTabStateChange(aObject, aTabState) {
|
|
|
|
switch (aTabState) {
|
|
|
|
case 'newtab':
|
2014-08-06 13:38:50 +00:00
|
|
|
return [{string: 'tabNew'}];
|
2013-06-17 14:36:41 +00:00
|
|
|
case 'loading':
|
2014-08-06 13:38:50 +00:00
|
|
|
return [{string: 'tabLoading'}];
|
2013-06-17 14:36:41 +00:00
|
|
|
case 'loaded':
|
2014-08-06 13:38:50 +00:00
|
|
|
return [aObject.name, {string: 'tabLoaded'}];
|
2013-06-17 14:36:41 +00:00
|
|
|
case 'loadstopped':
|
2014-08-06 13:38:50 +00:00
|
|
|
return [{string: 'tabLoadStopped'}];
|
2013-06-17 14:36:41 +00:00
|
|
|
case 'reload':
|
2014-08-06 13:38:50 +00:00
|
|
|
return [{string: 'tabReload'}];
|
2013-06-17 14:36:41 +00:00
|
|
|
default:
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
genForEditingMode: function genForEditingMode(aIsEditing) {
|
2014-08-06 13:38:50 +00:00
|
|
|
return [{string: aIsEditing ? 'editingMode' : 'navigationMode'}];
|
2013-06-17 14:36:41 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
objectOutputFunctions: {
|
|
|
|
|
2015-05-29 15:55:53 +00:00
|
|
|
__proto__: OutputGenerator.objectOutputFunctions, // jshint ignore:line
|
2013-06-27 21:15:36 +00:00
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
defaultFunc: function defaultFunc() {
|
|
|
|
return this.objectOutputFunctions._generateBaseOutput.apply(
|
|
|
|
this, arguments);
|
2012-05-25 16:37:48 +00:00
|
|
|
},
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
heading: function heading(aAccessible, aRoleStr, aState, aFlags) {
|
2012-04-13 23:18:57 +00:00
|
|
|
let level = {};
|
|
|
|
aAccessible.groupPosition(level, {}, {});
|
2014-08-06 13:38:50 +00:00
|
|
|
let utterance = [{string: 'headingLevel', args: [level.value]}];
|
2012-05-07 18:21:21 +00:00
|
|
|
|
2013-04-04 22:16:37 +00:00
|
|
|
this._addName(utterance, aAccessible, aFlags);
|
2013-07-09 20:09:25 +00:00
|
|
|
this._addLandmark(utterance, aAccessible);
|
2012-05-07 18:21:21 +00:00
|
|
|
|
|
|
|
return utterance;
|
2012-04-13 23:18:57 +00:00
|
|
|
},
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
listitem: function listitem(aAccessible, aRoleStr, aState, aFlags) {
|
2012-04-13 23:18:57 +00:00
|
|
|
let itemno = {};
|
|
|
|
let itemof = {};
|
|
|
|
aAccessible.groupPosition({}, itemof, itemno);
|
2012-11-14 18:20:50 +00:00
|
|
|
let utterance = [];
|
2014-08-06 13:38:50 +00:00
|
|
|
if (itemno.value == 1) {
|
|
|
|
// Start of list
|
|
|
|
utterance.push({string: 'listStart'});
|
|
|
|
}
|
|
|
|
else if (itemno.value == itemof.value) {
|
|
|
|
// last item
|
|
|
|
utterance.push({string: 'listEnd'});
|
|
|
|
}
|
2012-05-07 18:21:21 +00:00
|
|
|
|
2013-04-04 22:16:37 +00:00
|
|
|
this._addName(utterance, aAccessible, aFlags);
|
2013-07-09 20:09:25 +00:00
|
|
|
this._addLandmark(utterance, aAccessible);
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-05-07 18:21:21 +00:00
|
|
|
return utterance;
|
2012-11-12 23:46:09 +00:00
|
|
|
},
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
list: function list(aAccessible, aRoleStr, aState, aFlags) {
|
2012-11-14 18:20:50 +00:00
|
|
|
return this._getListUtterance
|
|
|
|
(aAccessible, aRoleStr, aFlags, aAccessible.childCount);
|
|
|
|
},
|
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
definitionlist:
|
|
|
|
function definitionlist(aAccessible, aRoleStr, aState, aFlags) {
|
|
|
|
return this._getListUtterance
|
|
|
|
(aAccessible, aRoleStr, aFlags, aAccessible.childCount / 2);
|
|
|
|
},
|
2012-11-14 18:20:50 +00:00
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
application: function application(aAccessible, aRoleStr, aState, aFlags) {
|
2012-11-12 23:46:09 +00:00
|
|
|
// Don't utter location of applications, it gets tiring.
|
2014-08-06 13:38:56 +00:00
|
|
|
if (aAccessible.name != aAccessible.DOMNode.location) {
|
2013-06-17 14:36:41 +00:00
|
|
|
return this.objectOutputFunctions.defaultFunc.apply(this,
|
2014-01-28 00:35:13 +00:00
|
|
|
[aAccessible, aRoleStr, aState, aFlags]);
|
2014-08-06 13:38:56 +00:00
|
|
|
}
|
2012-11-12 23:46:09 +00:00
|
|
|
|
|
|
|
return [];
|
2013-06-27 21:15:36 +00:00
|
|
|
},
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
cell: function cell(aAccessible, aRoleStr, aState, aFlags, aContext) {
|
2013-06-27 21:15:36 +00:00
|
|
|
let utterance = [];
|
|
|
|
let cell = aContext.getCellInfo(aAccessible);
|
|
|
|
if (cell) {
|
2014-08-06 13:38:50 +00:00
|
|
|
let addCellChanged =
|
|
|
|
function addCellChanged(aUtterance, aChanged, aString, aIndex) {
|
|
|
|
if (aChanged) {
|
|
|
|
aUtterance.push({string: aString, args: [aIndex + 1]});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
let addExtent = function addExtent(aUtterance, aExtent, aString) {
|
2013-06-27 21:15:36 +00:00
|
|
|
if (aExtent > 1) {
|
2014-08-06 13:38:50 +00:00
|
|
|
aUtterance.push({string: aString, args: [aExtent]});
|
2013-06-27 21:15:36 +00:00
|
|
|
}
|
|
|
|
};
|
2014-08-06 13:38:50 +00:00
|
|
|
let addHeaders = function addHeaders(aUtterance, aHeaders) {
|
2013-06-27 21:15:36 +00:00
|
|
|
if (aHeaders.length > 0) {
|
2014-08-06 13:38:50 +00:00
|
|
|
aUtterance.push.apply(aUtterance, aHeaders);
|
2013-06-27 21:15:36 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-08-06 13:38:50 +00:00
|
|
|
addCellChanged(utterance, cell.columnChanged, 'columnInfo',
|
|
|
|
cell.columnIndex);
|
|
|
|
addCellChanged(utterance, cell.rowChanged, 'rowInfo', cell.rowIndex);
|
2013-06-27 21:15:36 +00:00
|
|
|
|
2014-08-06 13:38:50 +00:00
|
|
|
addExtent(utterance, cell.columnExtent, 'spansColumns');
|
|
|
|
addExtent(utterance, cell.rowExtent, 'spansRows');
|
2013-06-27 21:15:36 +00:00
|
|
|
|
2014-08-06 13:38:50 +00:00
|
|
|
addHeaders(utterance, cell.columnHeaders);
|
|
|
|
addHeaders(utterance, cell.rowHeaders);
|
2013-06-27 21:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this._addName(utterance, aAccessible, aFlags);
|
2013-07-09 20:09:25 +00:00
|
|
|
this._addLandmark(utterance, aAccessible);
|
|
|
|
|
2013-06-27 21:15:36 +00:00
|
|
|
return utterance;
|
|
|
|
},
|
|
|
|
|
|
|
|
columnheader: function columnheader() {
|
|
|
|
return this.objectOutputFunctions.cell.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
rowheader: function rowheader() {
|
|
|
|
return this.objectOutputFunctions.cell.apply(this, arguments);
|
2014-05-01 04:33:37 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
statictext: function statictext(aAccessible) {
|
|
|
|
if (Utils.isListItemDecorator(aAccessible, true)) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.objectOutputFunctions.defaultFunc.apply(this, arguments);
|
2012-04-13 23:18:57 +00:00
|
|
|
}
|
2012-05-03 05:10:55 +00:00
|
|
|
},
|
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
_getContextStart: function _getContextStart(aContext) {
|
|
|
|
return aContext.newAncestry;
|
2013-04-04 22:16:37 +00:00
|
|
|
},
|
|
|
|
|
2015-07-13 09:53:00 +00:00
|
|
|
_addRole: function _addRole(aOutput, aAccessible, aRoleStr) {
|
|
|
|
if (this.mathmlRolesSet.has(aAccessible.role)) {
|
|
|
|
this._addMathRoles(aOutput, aAccessible, aRoleStr);
|
|
|
|
} else {
|
|
|
|
aOutput.push({string: this._getOutputName(aRoleStr)});
|
|
|
|
}
|
2012-05-24 18:46:04 +00:00
|
|
|
},
|
|
|
|
|
2015-05-29 15:55:53 +00:00
|
|
|
_addState: function _addState(aOutput, aState, aRoleStr) {
|
2012-05-24 18:46:04 +00:00
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
if (aState.contains(States.UNAVAILABLE)) {
|
2014-08-06 13:38:50 +00:00
|
|
|
aOutput.push({string: 'stateUnavailable'});
|
2012-05-24 18:46:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-24 00:22:03 +00:00
|
|
|
if (aState.contains(States.READONLY)) {
|
|
|
|
aOutput.push({string: 'stateReadonly'});
|
|
|
|
}
|
|
|
|
|
2013-05-23 14:06:27 +00:00
|
|
|
// Don't utter this in Jelly Bean, we let TalkBack do it for us there.
|
|
|
|
// This is because we expose the checked information on the node itself.
|
2014-08-06 13:38:50 +00:00
|
|
|
// XXX: this means the checked state is always appended to the end,
|
|
|
|
// regardless of the utterance ordering preference.
|
2014-03-19 07:38:25 +00:00
|
|
|
if ((Utils.AndroidSdkVersion < 16 || Utils.MozBuildApp === 'browser') &&
|
|
|
|
aState.contains(States.CHECKABLE)) {
|
2015-05-29 15:55:53 +00:00
|
|
|
let checked = aState.contains(States.CHECKED);
|
|
|
|
let statetr;
|
|
|
|
if (aRoleStr === 'switch') {
|
|
|
|
statetr = checked ? 'stateOn' : 'stateOff';
|
|
|
|
} else {
|
|
|
|
statetr = checked ? 'stateChecked' : 'stateNotChecked';
|
|
|
|
}
|
2014-08-06 13:38:50 +00:00
|
|
|
aOutput.push({string: statetr});
|
2012-05-24 18:46:04 +00:00
|
|
|
}
|
|
|
|
|
2014-04-04 08:01:19 +00:00
|
|
|
if (aState.contains(States.PRESSED)) {
|
2014-08-06 13:38:50 +00:00
|
|
|
aOutput.push({string: 'statePressed'});
|
2014-04-04 08:01:19 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
if (aState.contains(States.EXPANDABLE)) {
|
|
|
|
let statetr = aState.contains(States.EXPANDED) ?
|
2012-05-24 18:46:04 +00:00
|
|
|
'stateExpanded' : 'stateCollapsed';
|
2014-08-06 13:38:50 +00:00
|
|
|
aOutput.push({string: statetr});
|
2012-05-24 18:46:04 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
if (aState.contains(States.REQUIRED)) {
|
2014-08-06 13:38:50 +00:00
|
|
|
aOutput.push({string: 'stateRequired'});
|
2012-05-24 18:46:04 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
if (aState.contains(States.TRAVERSED)) {
|
2014-08-06 13:38:50 +00:00
|
|
|
aOutput.push({string: 'stateTraversed'});
|
2012-05-24 18:46:04 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
if (aState.contains(States.HASPOPUP)) {
|
2014-08-06 13:38:50 +00:00
|
|
|
aOutput.push({string: 'stateHasPopup'});
|
2013-05-30 15:24:18 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
if (aState.contains(States.SELECTED)) {
|
2014-08-06 13:38:50 +00:00
|
|
|
aOutput.push({string: 'stateSelected'});
|
2013-08-21 07:52:46 +00:00
|
|
|
}
|
2012-11-14 18:20:50 +00:00
|
|
|
},
|
2012-12-07 18:39:17 +00:00
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
_getListUtterance:
|
|
|
|
function _getListUtterance(aAccessible, aRoleStr, aFlags, aItemCount) {
|
|
|
|
let utterance = [];
|
2015-07-13 09:53:00 +00:00
|
|
|
this._addRole(utterance, aAccessible, aRoleStr);
|
2014-08-06 13:38:56 +00:00
|
|
|
utterance.push({
|
|
|
|
string: this._getOutputName('listItemsCount'),
|
|
|
|
count: aItemCount
|
|
|
|
});
|
2012-11-14 18:20:50 +00:00
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
this._addName(utterance, aAccessible, aFlags);
|
|
|
|
this._addLandmark(utterance, aAccessible);
|
2012-11-14 18:20:50 +00:00
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
return utterance;
|
|
|
|
}
|
2012-04-13 23:18:57 +00:00
|
|
|
};
|
2013-06-17 14:36:41 +00:00
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
this.BrailleGenerator = { // jshint ignore:line
|
2015-05-29 15:55:53 +00:00
|
|
|
__proto__: OutputGenerator, // jshint ignore:line
|
2013-06-17 14:36:41 +00:00
|
|
|
|
2013-07-03 22:20:11 +00:00
|
|
|
genForContext: function genForContext(aContext) {
|
|
|
|
let output = OutputGenerator.genForContext.apply(this, arguments);
|
|
|
|
|
|
|
|
let acc = aContext.accessible;
|
2013-12-24 20:58:14 +00:00
|
|
|
|
|
|
|
// add the static text indicating a list item; do this for both listitems or
|
2014-08-06 13:38:56 +00:00
|
|
|
// direct first children of listitems, because these are both common
|
|
|
|
// browsing scenarios
|
2013-12-24 20:58:14 +00:00
|
|
|
let addListitemIndicator = function addListitemIndicator(indicator = '*') {
|
2014-08-06 13:38:50 +00:00
|
|
|
output.unshift(indicator);
|
2013-12-24 20:58:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (acc.indexInParent === 1 &&
|
|
|
|
acc.parent.role == Roles.LISTITEM &&
|
|
|
|
acc.previousSibling.role == Roles.STATICTEXT) {
|
|
|
|
if (acc.parent.parent && acc.parent.parent.DOMNode &&
|
|
|
|
acc.parent.parent.DOMNode.nodeName == 'UL') {
|
|
|
|
addListitemIndicator();
|
|
|
|
} else {
|
|
|
|
addListitemIndicator(acc.previousSibling.name.trim());
|
|
|
|
}
|
|
|
|
} else if (acc.role == Roles.LISTITEM && acc.firstChild &&
|
|
|
|
acc.firstChild.role == Roles.STATICTEXT) {
|
|
|
|
if (acc.parent.DOMNode.nodeName == 'UL') {
|
|
|
|
addListitemIndicator();
|
|
|
|
} else {
|
|
|
|
addListitemIndicator(acc.firstChild.name.trim());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-03 22:20:11 +00:00
|
|
|
return output;
|
|
|
|
},
|
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
objectOutputFunctions: {
|
2013-06-27 21:15:36 +00:00
|
|
|
|
2015-05-29 15:55:53 +00:00
|
|
|
__proto__: OutputGenerator.objectOutputFunctions, // jshint ignore:line
|
2013-06-27 21:15:36 +00:00
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
defaultFunc: function defaultFunc() {
|
|
|
|
return this.objectOutputFunctions._generateBaseOutput.apply(
|
|
|
|
this, arguments);
|
2013-06-17 14:36:41 +00:00
|
|
|
},
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
listitem: function listitem(aAccessible, aRoleStr, aState, aFlags) {
|
2013-06-17 14:36:41 +00:00
|
|
|
let braille = [];
|
|
|
|
|
|
|
|
this._addName(braille, aAccessible, aFlags);
|
2013-07-09 20:09:25 +00:00
|
|
|
this._addLandmark(braille, aAccessible);
|
2013-06-17 14:36:41 +00:00
|
|
|
|
|
|
|
return braille;
|
|
|
|
},
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
cell: function cell(aAccessible, aRoleStr, aState, aFlags, aContext) {
|
2013-06-27 21:15:36 +00:00
|
|
|
let braille = [];
|
|
|
|
let cell = aContext.getCellInfo(aAccessible);
|
|
|
|
if (cell) {
|
2014-08-06 13:38:50 +00:00
|
|
|
let addHeaders = function addHeaders(aBraille, aHeaders) {
|
2013-06-27 21:15:36 +00:00
|
|
|
if (aHeaders.length > 0) {
|
2014-08-06 13:38:50 +00:00
|
|
|
aBraille.push.apply(aBraille, aHeaders);
|
2013-06-27 21:15:36 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-08-06 13:38:50 +00:00
|
|
|
braille.push({
|
|
|
|
string: this._getOutputName('cellInfo'),
|
|
|
|
args: [cell.columnIndex + 1, cell.rowIndex + 1]
|
|
|
|
});
|
2013-06-27 21:15:36 +00:00
|
|
|
|
2014-08-06 13:38:50 +00:00
|
|
|
addHeaders(braille, cell.columnHeaders);
|
|
|
|
addHeaders(braille, cell.rowHeaders);
|
2013-06-27 21:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this._addName(braille, aAccessible, aFlags);
|
2013-07-09 20:09:25 +00:00
|
|
|
this._addLandmark(braille, aAccessible);
|
2013-06-27 21:15:36 +00:00
|
|
|
return braille;
|
|
|
|
},
|
|
|
|
|
|
|
|
columnheader: function columnheader() {
|
|
|
|
return this.objectOutputFunctions.cell.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
rowheader: function rowheader() {
|
|
|
|
return this.objectOutputFunctions.cell.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
statictext: function statictext(aAccessible) {
|
2013-06-17 14:36:41 +00:00
|
|
|
// Since we customize the list bullet's output, we add the static
|
|
|
|
// text from the first node in each listitem, so skip it here.
|
2014-05-01 04:33:37 +00:00
|
|
|
if (Utils.isListItemDecorator(aAccessible)) {
|
2013-06-17 14:36:41 +00:00
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.objectOutputFunctions._useStateNotRole.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
_useStateNotRole:
|
|
|
|
function _useStateNotRole(aAccessible, aRoleStr, aState, aFlags) {
|
|
|
|
let braille = [];
|
2015-05-29 15:55:53 +00:00
|
|
|
this._addState(braille, aState, aRoleStr);
|
2014-08-06 13:38:56 +00:00
|
|
|
this._addName(braille, aAccessible, aFlags);
|
|
|
|
this._addLandmark(braille, aAccessible);
|
2013-06-17 14:36:41 +00:00
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
return braille;
|
|
|
|
},
|
2013-06-17 14:36:41 +00:00
|
|
|
|
2015-05-29 15:55:53 +00:00
|
|
|
switch: function braille_generator_object_output_functions_switch() {
|
|
|
|
return this.objectOutputFunctions._useStateNotRole.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
checkbutton: function checkbutton() {
|
2013-06-17 14:36:41 +00:00
|
|
|
return this.objectOutputFunctions._useStateNotRole.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
radiobutton: function radiobutton() {
|
2013-06-17 14:36:41 +00:00
|
|
|
return this.objectOutputFunctions._useStateNotRole.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
2014-08-06 13:38:56 +00:00
|
|
|
togglebutton: function togglebutton() {
|
2013-06-17 14:36:41 +00:00
|
|
|
return this.objectOutputFunctions._useStateNotRole.apply(this, arguments);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_getContextStart: function _getContextStart(aContext) {
|
2013-11-19 18:17:43 +00:00
|
|
|
if (aContext.accessible.parent.role == Roles.LINK) {
|
2013-06-17 14:36:41 +00:00
|
|
|
return [aContext.accessible.parent];
|
|
|
|
}
|
|
|
|
|
|
|
|
return [];
|
|
|
|
},
|
|
|
|
|
2013-06-27 21:15:36 +00:00
|
|
|
_getOutputName: function _getOutputName(aName) {
|
|
|
|
return OutputGenerator._getOutputName(aName) + 'Abbr';
|
|
|
|
},
|
|
|
|
|
2015-07-13 09:53:00 +00:00
|
|
|
_addRole: function _addRole(aBraille, aAccessible, aRoleStr) {
|
|
|
|
if (this.mathmlRolesSet.has(aAccessible.role)) {
|
|
|
|
this._addMathRoles(aBraille, aAccessible, aRoleStr);
|
|
|
|
} else {
|
|
|
|
aBraille.push({string: this._getOutputName(aRoleStr)});
|
|
|
|
}
|
2013-06-17 14:36:41 +00:00
|
|
|
},
|
|
|
|
|
2015-05-29 15:55:53 +00:00
|
|
|
_addState: function _addState(aBraille, aState, aRoleStr) {
|
2014-01-28 00:35:13 +00:00
|
|
|
if (aState.contains(States.CHECKABLE)) {
|
2014-08-06 13:38:50 +00:00
|
|
|
aBraille.push({
|
|
|
|
string: aState.contains(States.CHECKED) ?
|
|
|
|
this._getOutputName('stateChecked') :
|
|
|
|
this._getOutputName('stateUnchecked')
|
|
|
|
});
|
2014-04-04 08:01:19 +00:00
|
|
|
}
|
2015-05-29 15:55:53 +00:00
|
|
|
if (aRoleStr === 'toggle button') {
|
2014-08-06 13:38:50 +00:00
|
|
|
aBraille.push({
|
|
|
|
string: aState.contains(States.PRESSED) ?
|
|
|
|
this._getOutputName('statePressed') :
|
|
|
|
this._getOutputName('stateUnpressed')
|
|
|
|
});
|
2013-06-17 14:36:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|