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/. */
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cu = Components.utils;
|
|
|
|
const Cr = Components.results;
|
|
|
|
|
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 INCLUDE_CUSTOM = 0x08;
|
|
|
|
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');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Utils',
|
|
|
|
'resource://gre/modules/accessibility/Utils.jsm');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'PrefCache',
|
|
|
|
'resource://gre/modules/accessibility/Utils.jsm');
|
2013-06-27 21:15:36 +00:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Logger',
|
|
|
|
'resource://gre/modules/accessibility/Utils.jsm');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'PluralForm',
|
|
|
|
'resource://gre/modules/PluralForm.jsm');
|
2013-11-19 18:17:43 +00:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Roles',
|
|
|
|
'resource://gre/modules/accessibility/Constants.jsm');
|
2014-01-28 00:35:13 +00:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'States',
|
|
|
|
'resource://gre/modules/accessibility/Constants.jsm');
|
2013-06-27 21:15:36 +00:00
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
this.EXPORTED_SYMBOLS = ['UtteranceGenerator', 'BrailleGenerator'];
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
this.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.
|
2013-07-03 22:20:11 +00:00
|
|
|
* @return {Object} An object that neccessarily has an output property which
|
|
|
|
* is an array of strings. Depending on the utterance order,
|
2013-04-04 22:16:37 +00:00
|
|
|
* the strings describe the context for an accessible object either
|
|
|
|
* starting from the accessible's ancestry or accessible's subtree.
|
2013-07-03 22:20:11 +00:00
|
|
|
* The object may also have properties specific to the type of output
|
|
|
|
* generated.
|
2013-04-04 22:16:37 +00:00
|
|
|
*/
|
|
|
|
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) {
|
|
|
|
let roleString = Utils.AccRetrieval.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);
|
|
|
|
[addOutput(node) for
|
2013-06-10 20:31:17 +00:00
|
|
|
(node of aContext.subtreeGenerator(true, ignoreSubtree))];
|
2013-04-04 22:16:37 +00:00
|
|
|
} else {
|
2013-06-17 14:36:41 +00:00
|
|
|
[addOutput(node) for
|
2013-06-10 20:31:17 +00:00
|
|
|
(node of aContext.subtreeGenerator(false, ignoreSubtree))];
|
2013-06-17 14:36:41 +00:00
|
|
|
addOutput(aContext.accessible);
|
|
|
|
contextStart.reverse().forEach(addOutput);
|
2013-04-04 22:16:37 +00:00
|
|
|
}
|
|
|
|
|
2013-05-28 18:04:01 +00:00
|
|
|
// Clean up the white space.
|
|
|
|
let trimmed;
|
2013-06-17 14:36:41 +00:00
|
|
|
output = [trimmed for (word of output) if (trimmed = word.trim())];
|
2013-07-03 22:20:11 +00:00
|
|
|
return {output: 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.
|
2012-05-07 16:44:44 +00:00
|
|
|
* @return {Array} Two string array. The first string describes the object
|
2014-01-28 00:35:13 +00:00
|
|
|
* and its state. The second string is the object's name. Whether the
|
2012-05-29 20:46:08 +00:00
|
|
|
* object's description or it's role is included is determined by
|
2013-05-28 17:51:44 +00:00
|
|
|
* {@link roleRuleMap}.
|
2012-05-07 16:44:44 +00:00
|
|
|
*/
|
2013-06-27 21:15:36 +00:00
|
|
|
genForObject: function genForObject(aAccessible, aContext) {
|
2012-08-27 03:14:42 +00:00
|
|
|
let roleString = Utils.AccRetrieval.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
|
|
|
|
2012-05-29 20:46:08 +00:00
|
|
|
if (aAccessible.childCount == 0)
|
2012-04-13 23:18:57 +00:00
|
|
|
flags |= INCLUDE_NAME;
|
|
|
|
|
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}.
|
|
|
|
* @return {Array} A one string array with the action.
|
|
|
|
*/
|
2013-06-17 14:36:41 +00:00
|
|
|
genForAction: function genForAction(aObject, aActionName) {},
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2012-12-07 18:39:17 +00:00
|
|
|
/**
|
2013-06-17 14:36:41 +00:00
|
|
|
* Generates output for an announcement. Basically attempts to localize
|
2012-12-07 18:39:17 +00:00
|
|
|
* the announcement string.
|
|
|
|
* @param {string} aAnnouncement unlocalized announcement.
|
|
|
|
* @return {Array} A one string array with the announcement.
|
|
|
|
*/
|
2013-06-17 14:36:41 +00:00
|
|
|
genForAnnouncement: function genForAnnouncement(aAnnouncement) {},
|
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.
|
|
|
|
*/
|
2013-06-17 14:36:41 +00:00
|
|
|
genForTabStateChange: function genForTabStateChange(aObject, aTabState) {},
|
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
|
|
|
|
*/
|
2013-06-17 14:36:41 +00:00
|
|
|
genForEditingMode: function genForEditingMode(aIsEditing) {},
|
|
|
|
|
|
|
|
_getContextStart: function getContextStart(aContext) {},
|
|
|
|
|
|
|
|
_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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
if (name) {
|
2013-07-09 20:09:25 +00:00
|
|
|
aOutput[this.outputOrder === OUTPUT_DESC_FIRST ?
|
2013-06-17 14:36:41 +00:00
|
|
|
'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;
|
|
|
|
}
|
2013-07-09 20:09:25 +00:00
|
|
|
|
2014-03-04 18:10:38 +00:00
|
|
|
let landmark = Utils.stringBundle.GetStringFromName(landmarkName);
|
2013-07-09 20:09:25 +00:00
|
|
|
if (!landmark) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
aOutput[this.outputOrder === OUTPUT_DESC_FIRST ? 'unshift' : 'push'](
|
|
|
|
landmark);
|
|
|
|
},
|
|
|
|
|
2013-10-25 03:21:29 +00:00
|
|
|
/**
|
|
|
|
* Adds an entry type attribute to the description if available.
|
|
|
|
* @param {Array} aDesc Description array.
|
|
|
|
* @param {nsIAccessible} aAccessible current accessible object.
|
|
|
|
* @param {String} aRoleStr aAccessible's role string.
|
|
|
|
*/
|
|
|
|
_addType: function _addType(aDesc, aAccessible, aRoleStr) {
|
|
|
|
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;
|
|
|
|
}
|
2013-11-06 02:51:56 +00:00
|
|
|
typeName = 'textInputType_' + typeName;
|
|
|
|
try {
|
2014-03-04 18:10:38 +00:00
|
|
|
aDesc.push(Utils.stringBundle.GetStringFromName(typeName));
|
2013-11-06 02:51:56 +00:00
|
|
|
} catch (x) {
|
|
|
|
Logger.warning('Failed to get a string from a bundle for', typeName);
|
|
|
|
}
|
2013-10-25 03:21:29 +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) {
|
|
|
|
return aName.replace(' ', '');
|
|
|
|
},
|
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
_getLocalizedRole: function _getLocalizedRole(aRoleStr) {},
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
_getLocalizedState: function _getLocalizedState(aState) {},
|
2013-06-17 14:36:41 +00:00
|
|
|
|
2013-06-27 21:15:36 +00:00
|
|
|
_getPluralFormString: function _getPluralFormString(aString, aCount) {
|
2014-03-04 18:10:38 +00:00
|
|
|
let str = Utils.stringBundle.GetStringFromName(this._getOutputName(aString));
|
2013-06-27 21:15:36 +00:00
|
|
|
str = PluralForm.get(aCount, str);
|
|
|
|
return str.replace('#1', aCount);
|
|
|
|
},
|
|
|
|
|
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,
|
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,
|
2012-05-24 18:46:04 +00:00
|
|
|
'combobox': INCLUDE_DESC,
|
|
|
|
'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,
|
2012-05-24 18:46:04 +00:00
|
|
|
'combobox list': INCLUDE_DESC,
|
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,
|
|
|
|
'app root': IGNORE_EXPLICIT_NAME },
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
objectOutputFunctions: {
|
2014-01-28 00:35:13 +00:00
|
|
|
_generateBaseOutput: function _generateBaseOutput(aAccessible, aRoleStr, aState, aFlags) {
|
2013-06-17 14:36:41 +00:00
|
|
|
let output = [];
|
2012-05-07 18:21:21 +00:00
|
|
|
|
2012-05-24 18:46:04 +00:00
|
|
|
if (aFlags & INCLUDE_DESC) {
|
2014-01-28 00:35:13 +00:00
|
|
|
let desc = this._getLocalizedState(aState);
|
2012-05-24 18:46:04 +00:00
|
|
|
let roleStr = this._getLocalizedRole(aRoleStr);
|
2013-10-25 03:21:29 +00:00
|
|
|
if (roleStr) {
|
|
|
|
this._addType(desc, aAccessible, aRoleStr);
|
2012-05-24 18:46:04 +00:00
|
|
|
desc.push(roleStr);
|
2013-10-25 03:21:29 +00:00
|
|
|
}
|
2013-06-17 14:36:41 +00:00
|
|
|
output.push(desc.join(' '));
|
2012-04-13 23:18:57 +00:00
|
|
|
}
|
|
|
|
|
2013-10-14 19:56:19 +00:00
|
|
|
if (aFlags & INCLUDE_VALUE) {
|
|
|
|
let value = aAccessible.value;
|
|
|
|
if (value) {
|
|
|
|
output[this.outputOrder === OUTPUT_DESC_FIRST ?
|
|
|
|
'push' : 'unshift'](value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
this._addName(output, aAccessible, aFlags);
|
2013-07-09 20:09:25 +00:00
|
|
|
this._addLandmark(output, aAccessible);
|
2012-04-13 23:18:57 +00:00
|
|
|
|
2013-06-17 14:36:41 +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 localizedRole = this._getLocalizedRole(aRoleStr);
|
|
|
|
let itemno = {};
|
|
|
|
let itemof = {};
|
|
|
|
aAccessible.groupPosition({}, itemof, itemno);
|
|
|
|
let output = [];
|
2014-01-28 00:35:13 +00:00
|
|
|
let desc = this._getLocalizedState(aState);
|
2013-08-21 07:52:46 +00:00
|
|
|
desc.push(
|
2014-03-04 18:10:38 +00:00
|
|
|
Utils.stringBundle.formatStringFromName(
|
2013-08-21 07:52:46 +00:00
|
|
|
'objItemOf', [localizedRole, itemno.value, itemof.value], 3));
|
|
|
|
output.push(desc.join(' '));
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
let tableColumnInfo = this._getPluralFormString('tableColumnInfo',
|
|
|
|
table.columnCount);
|
|
|
|
let tableRowInfo = this._getPluralFormString('tableRowInfo',
|
|
|
|
table.rowCount);
|
2014-03-04 18:10:38 +00:00
|
|
|
output.push(Utils.stringBundle.formatStringFromName(
|
2013-06-27 21:15:36 +00:00
|
|
|
this._getOutputName('tableInfo'), [this._getLocalizedRole(aRoleStr),
|
|
|
|
tableColumnInfo, tableRowInfo], 3));
|
|
|
|
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;
|
|
|
|
}
|
2013-06-17 14:36:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates speech utterances from objects, actions and state changes.
|
|
|
|
* An utterance is an array of strings.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
this.UtteranceGenerator = {
|
|
|
|
__proto__: OutputGenerator,
|
|
|
|
|
|
|
|
gActionMap: {
|
|
|
|
jump: 'jumpAction',
|
|
|
|
press: 'pressAction',
|
|
|
|
check: 'checkAction',
|
|
|
|
uncheck: 'uncheckAction',
|
|
|
|
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-03-04 18:10:38 +00:00
|
|
|
return [Utils.stringBundle.GetStringFromName(this.gActionMap[aActionName])];
|
2013-06-17 14:36:41 +00:00
|
|
|
},
|
|
|
|
|
2013-08-21 16:40:06 +00:00
|
|
|
genForLiveRegion: function genForLiveRegion(aContext, aIsHide, aModifiedText) {
|
|
|
|
let utterance = [];
|
|
|
|
if (aIsHide) {
|
2014-03-04 18:10:38 +00:00
|
|
|
utterance.push(Utils.stringBundle.GetStringFromName('hidden'));
|
2013-08-21 16:40:06 +00:00
|
|
|
}
|
|
|
|
return utterance.concat(
|
|
|
|
aModifiedText || this.genForContext(aContext).output);
|
|
|
|
},
|
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
genForAnnouncement: function genForAnnouncement(aAnnouncement) {
|
|
|
|
try {
|
2014-03-04 18:10:38 +00:00
|
|
|
return [Utils.stringBundle.GetStringFromName(aAnnouncement)];
|
2013-06-17 14:36:41 +00:00
|
|
|
} catch (x) {
|
|
|
|
return [aAnnouncement];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
genForTabStateChange: function genForTabStateChange(aObject, aTabState) {
|
|
|
|
switch (aTabState) {
|
|
|
|
case 'newtab':
|
2014-03-04 18:10:38 +00:00
|
|
|
return [Utils.stringBundle.GetStringFromName('tabNew')];
|
2013-06-17 14:36:41 +00:00
|
|
|
case 'loading':
|
2014-03-04 18:10:38 +00:00
|
|
|
return [Utils.stringBundle.GetStringFromName('tabLoading')];
|
2013-06-17 14:36:41 +00:00
|
|
|
case 'loaded':
|
|
|
|
return [aObject.name || '',
|
2014-03-04 18:10:38 +00:00
|
|
|
Utils.stringBundle.GetStringFromName('tabLoaded')];
|
2013-06-17 14:36:41 +00:00
|
|
|
case 'loadstopped':
|
2014-03-04 18:10:38 +00:00
|
|
|
return [Utils.stringBundle.GetStringFromName('tabLoadStopped')];
|
2013-06-17 14:36:41 +00:00
|
|
|
case 'reload':
|
2014-03-04 18:10:38 +00:00
|
|
|
return [Utils.stringBundle.GetStringFromName('tabReload')];
|
2013-06-17 14:36:41 +00:00
|
|
|
default:
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
genForEditingMode: function genForEditingMode(aIsEditing) {
|
2014-03-04 18:10:38 +00:00
|
|
|
return [Utils.stringBundle.GetStringFromName(
|
|
|
|
aIsEditing ? 'editingMode' : 'navigationMode')];
|
2013-06-17 14:36:41 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
objectOutputFunctions: {
|
|
|
|
|
2013-06-27 21:15:36 +00:00
|
|
|
__proto__: OutputGenerator.objectOutputFunctions,
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
defaultFunc: function defaultFunc(aAccessible, aRoleStr, aState, aFlags) {
|
2013-06-27 21:15:36 +00:00
|
|
|
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, {}, {});
|
2012-05-07 18:21:21 +00:00
|
|
|
let utterance =
|
2014-03-04 18:10:38 +00:00
|
|
|
[Utils.stringBundle.formatStringFromName(
|
|
|
|
'headingLevel', [level.value], 1)];
|
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 = [];
|
|
|
|
if (itemno.value == 1) // Start of list
|
2014-03-04 18:10:38 +00:00
|
|
|
utterance.push(Utils.stringBundle.GetStringFromName('listStart'));
|
2012-11-14 18:20:50 +00:00
|
|
|
else if (itemno.value == itemof.value) // last item
|
2014-03-04 18:10:38 +00:00
|
|
|
utterance.push(Utils.stringBundle.GetStringFromName('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-01-28 00:35:13 +00:00
|
|
|
definitionlist: function definitionlist(aAccessible, aRoleStr, aState, aFlags) {
|
2012-11-14 18:20:50 +00:00
|
|
|
return this._getListUtterance
|
|
|
|
(aAccessible, aRoleStr, aFlags, aAccessible.childCount / 2);
|
|
|
|
},
|
|
|
|
|
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.
|
|
|
|
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]);
|
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) {
|
|
|
|
let desc = [];
|
|
|
|
let addCellChanged = function addCellChanged(aDesc, aChanged, aString, aIndex) {
|
|
|
|
if (aChanged) {
|
2014-03-04 18:10:38 +00:00
|
|
|
aDesc.push(Utils.stringBundle.formatStringFromName(aString,
|
2013-06-27 21:15:36 +00:00
|
|
|
[aIndex + 1], 1));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
let addExtent = function addExtent(aDesc, aExtent, aString) {
|
|
|
|
if (aExtent > 1) {
|
2014-03-04 18:10:38 +00:00
|
|
|
aDesc.push(Utils.stringBundle.formatStringFromName(aString,
|
2013-06-27 21:15:36 +00:00
|
|
|
[aExtent], 1));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
let addHeaders = function addHeaders(aDesc, aHeaders) {
|
|
|
|
if (aHeaders.length > 0) {
|
|
|
|
aDesc.push.apply(aDesc, aHeaders);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
addCellChanged(desc, cell.columnChanged, 'columnInfo', cell.columnIndex);
|
|
|
|
addCellChanged(desc, cell.rowChanged, 'rowInfo', cell.rowIndex);
|
|
|
|
|
|
|
|
addExtent(desc, cell.columnExtent, 'spansColumns');
|
|
|
|
addExtent(desc, cell.rowExtent, 'spansRows');
|
|
|
|
|
|
|
|
addHeaders(desc, cell.columnHeaders);
|
|
|
|
addHeaders(desc, cell.rowHeaders);
|
|
|
|
|
|
|
|
utterance.push(desc.join(' '));
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
2012-05-03 05:10:55 +00:00
|
|
|
_getLocalizedRole: function _getLocalizedRole(aRoleStr) {
|
|
|
|
try {
|
2014-03-04 18:10:38 +00:00
|
|
|
return Utils.stringBundle.GetStringFromName(
|
|
|
|
this._getOutputName(aRoleStr));
|
2012-05-03 05:10:55 +00:00
|
|
|
} catch (x) {
|
|
|
|
return '';
|
|
|
|
}
|
2012-05-24 18:46:04 +00:00
|
|
|
},
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
_getLocalizedState: function _getLocalizedState(aState) {
|
2012-05-24 18:46:04 +00:00
|
|
|
let stateUtterances = [];
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
if (aState.contains(States.UNAVAILABLE)) {
|
2014-03-04 18:10:38 +00:00
|
|
|
stateUtterances.push(
|
|
|
|
Utils.stringBundle.GetStringFromName('stateUnavailable'));
|
2012-05-24 18:46:04 +00:00
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
// 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)) {
|
2014-01-28 00:35:13 +00:00
|
|
|
let statetr = aState.contains(States.CHECKED) ?
|
2012-05-24 18:46:04 +00:00
|
|
|
'stateChecked' : 'stateNotChecked';
|
2014-03-04 18:10:38 +00:00
|
|
|
stateUtterances.push(Utils.stringBundle.GetStringFromName(statetr));
|
2012-05-24 18:46:04 +00:00
|
|
|
}
|
|
|
|
|
2014-04-04 08:01:19 +00:00
|
|
|
if (aState.contains(States.PRESSED)) {
|
|
|
|
stateUtterances.push(
|
|
|
|
Utils.stringBundle.GetStringFromName('statePressed'));
|
|
|
|
}
|
|
|
|
|
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-03-04 18:10:38 +00:00
|
|
|
stateUtterances.push(Utils.stringBundle.GetStringFromName(statetr));
|
2012-05-24 18:46:04 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
if (aState.contains(States.REQUIRED)) {
|
2014-03-04 18:10:38 +00:00
|
|
|
stateUtterances.push(
|
|
|
|
Utils.stringBundle.GetStringFromName('stateRequired'));
|
2012-05-24 18:46:04 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
if (aState.contains(States.TRAVERSED)) {
|
2014-03-04 18:10:38 +00:00
|
|
|
stateUtterances.push(
|
|
|
|
Utils.stringBundle.GetStringFromName('stateTraversed'));
|
2012-05-24 18:46:04 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
if (aState.contains(States.HASPOPUP)) {
|
2014-03-04 18:10:38 +00:00
|
|
|
stateUtterances.push(
|
|
|
|
Utils.stringBundle.GetStringFromName('stateHasPopup'));
|
2013-05-30 15:24:18 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
if (aState.contains(States.SELECTED)) {
|
2014-03-04 18:10:38 +00:00
|
|
|
stateUtterances.push(
|
|
|
|
Utils.stringBundle.GetStringFromName('stateSelected'));
|
2013-08-21 07:52:46 +00:00
|
|
|
}
|
|
|
|
|
2012-05-24 18:46:04 +00:00
|
|
|
return stateUtterances;
|
2012-11-14 18:20:50 +00:00
|
|
|
},
|
2012-12-07 18:39:17 +00:00
|
|
|
|
2012-11-14 18:20:50 +00:00
|
|
|
_getListUtterance: function _getListUtterance(aAccessible, aRoleStr, aFlags, aItemCount) {
|
|
|
|
let desc = [];
|
|
|
|
let roleStr = this._getLocalizedRole(aRoleStr);
|
2013-07-10 14:33:38 +00:00
|
|
|
if (roleStr) {
|
2012-11-14 18:20:50 +00:00
|
|
|
desc.push(roleStr);
|
2013-07-10 14:33:38 +00:00
|
|
|
}
|
2013-07-15 13:57:54 +00:00
|
|
|
desc.push(this._getPluralFormString('listItemsCount', aItemCount));
|
2012-11-14 18:20:50 +00:00
|
|
|
let utterance = [desc.join(' ')];
|
|
|
|
|
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-11-14 18:20:50 +00:00
|
|
|
|
|
|
|
return utterance;
|
2012-04-13 23:18:57 +00:00
|
|
|
}
|
|
|
|
};
|
2013-06-17 14:36:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
this.BrailleGenerator = {
|
|
|
|
__proto__: OutputGenerator,
|
|
|
|
|
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
|
|
|
|
// direct first children of listitems, because these are both common browsing
|
|
|
|
// scenarios
|
|
|
|
let addListitemIndicator = function addListitemIndicator(indicator = '*') {
|
|
|
|
output.output.unshift(indicator);
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
if (acc instanceof Ci.nsIAccessibleText) {
|
2013-07-09 20:09:25 +00:00
|
|
|
output.endOffset = this.outputOrder === OUTPUT_DESC_FIRST ?
|
2013-07-03 22:20:11 +00:00
|
|
|
output.output.join(' ').length : acc.characterCount;
|
|
|
|
output.startOffset = output.endOffset - acc.characterCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
return output;
|
|
|
|
},
|
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
objectOutputFunctions: {
|
2013-06-27 21:15:36 +00:00
|
|
|
|
|
|
|
__proto__: OutputGenerator.objectOutputFunctions,
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
defaultFunc: function defaultFunc(aAccessible, aRoleStr, aState, aFlags) {
|
2013-12-24 20:58:14 +00:00
|
|
|
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) {
|
|
|
|
let desc = [];
|
|
|
|
let addHeaders = function addHeaders(aDesc, aHeaders) {
|
|
|
|
if (aHeaders.length > 0) {
|
|
|
|
aDesc.push.apply(aDesc, aHeaders);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-03-04 18:10:38 +00:00
|
|
|
desc.push(Utils.stringBundle.formatStringFromName(
|
2013-06-27 21:15:36 +00:00
|
|
|
this._getOutputName('cellInfo'), [cell.columnIndex + 1,
|
|
|
|
cell.rowIndex + 1], 2));
|
|
|
|
|
|
|
|
addHeaders(desc, cell.columnHeaders);
|
|
|
|
addHeaders(desc, cell.rowHeaders);
|
|
|
|
braille.push(desc.join(' '));
|
|
|
|
}
|
|
|
|
|
|
|
|
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-01-28 00:35:13 +00:00
|
|
|
statictext: function statictext(aAccessible, aRoleStr, aState, aFlags) {
|
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-01-28 00:35:13 +00:00
|
|
|
_useStateNotRole: function _useStateNotRole(aAccessible, aRoleStr, aState, aFlags) {
|
2013-06-17 14:36:41 +00:00
|
|
|
let braille = [];
|
|
|
|
|
2014-04-04 08:01:19 +00:00
|
|
|
let desc = this._getLocalizedState(aState, aAccessible.role);
|
2013-06-17 14:36:41 +00:00
|
|
|
braille.push(desc.join(' '));
|
|
|
|
|
|
|
|
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
|
|
|
checkbutton: function checkbutton(aAccessible, aRoleStr, aState, aFlags) {
|
2013-06-17 14:36:41 +00:00
|
|
|
return this.objectOutputFunctions._useStateNotRole.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
radiobutton: function radiobutton(aAccessible, aRoleStr, aState, aFlags) {
|
2013-06-17 14:36:41 +00:00
|
|
|
return this.objectOutputFunctions._useStateNotRole.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
togglebutton: function radiobutton(aAccessible, aRoleStr, aState, aFlags) {
|
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';
|
|
|
|
},
|
|
|
|
|
2013-06-17 14:36:41 +00:00
|
|
|
_getLocalizedRole: function _getLocalizedRole(aRoleStr) {
|
|
|
|
try {
|
2014-03-04 18:10:38 +00:00
|
|
|
return Utils.stringBundle.GetStringFromName(
|
|
|
|
this._getOutputName(aRoleStr));
|
2013-06-17 14:36:41 +00:00
|
|
|
} catch (x) {
|
|
|
|
try {
|
2014-03-04 18:10:38 +00:00
|
|
|
return Utils.stringBundle.GetStringFromName(
|
2013-06-27 21:15:36 +00:00
|
|
|
OutputGenerator._getOutputName(aRoleStr));
|
2013-06-17 14:36:41 +00:00
|
|
|
} catch (y) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-04-04 08:01:19 +00:00
|
|
|
_getLocalizedState: function _getLocalizedState(aState, aRole) {
|
2013-06-17 14:36:41 +00:00
|
|
|
let stateBraille = [];
|
|
|
|
|
2014-04-04 08:01:19 +00:00
|
|
|
let getResultMarker = function getResultMarker(aMarker) {
|
|
|
|
// aMarker is a simple boolean.
|
2013-06-17 14:36:41 +00:00
|
|
|
let resultMarker = [];
|
|
|
|
resultMarker.push('(');
|
2014-04-04 08:01:19 +00:00
|
|
|
resultMarker.push(aMarker ? 'x' : ' ');
|
2013-06-17 14:36:41 +00:00
|
|
|
resultMarker.push(')');
|
|
|
|
|
|
|
|
return resultMarker.join('');
|
|
|
|
};
|
|
|
|
|
2014-01-28 00:35:13 +00:00
|
|
|
if (aState.contains(States.CHECKABLE)) {
|
2014-04-04 08:01:19 +00:00
|
|
|
stateBraille.push(getResultMarker(aState.contains(States.CHECKED)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aRole === Roles.TOGGLE_BUTTON) {
|
|
|
|
stateBraille.push(getResultMarker(aState.contains(States.PRESSED)));
|
2013-06-17 14:36:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return stateBraille;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|