зеркало из https://github.com/mozilla/gecko-dev.git
Bug 753986 - Change presenter and utterance generator to be subtree-based. r=davidb
This commit is contained in:
Родитель
6a8a426ea3
Коммит
3eb91e2637
|
@ -238,13 +238,20 @@ AndroidPresenter.prototype = {
|
|||
return;
|
||||
|
||||
let output = [];
|
||||
for (let i in aContext.newAncestry)
|
||||
output.push.apply(
|
||||
output, UtteranceGenerator.genForObject(aContext.newAncestry[i]));
|
||||
aContext.newAncestry.forEach(
|
||||
function (acc) {
|
||||
output.push.apply(output, UtteranceGenerator.genForObject(acc));
|
||||
}
|
||||
);
|
||||
|
||||
output.push.apply(output,
|
||||
UtteranceGenerator.genForObject(aContext.accessible,
|
||||
true));
|
||||
UtteranceGenerator.genForObject(aContext.accessible));
|
||||
|
||||
aContext.subtreePreorder.forEach(
|
||||
function (acc) {
|
||||
output.push.apply(output, UtteranceGenerator.genForObject(acc));
|
||||
}
|
||||
);
|
||||
|
||||
this.sendMessageToJava({
|
||||
gecko: {
|
||||
|
@ -364,16 +371,13 @@ PresenterContext.prototype = {
|
|||
let oldLineage = [];
|
||||
|
||||
let parent = this._accessible;
|
||||
while ((parent = parent.parent))
|
||||
while (parent && (parent = parent.parent))
|
||||
newLineage.push(parent);
|
||||
|
||||
if (this._oldAccessible) {
|
||||
parent = this._oldAccessible;
|
||||
while ((parent = parent.parent))
|
||||
oldLineage.push(parent);
|
||||
}
|
||||
parent = this._oldAccessible;
|
||||
while (parent && (parent = parent.parent))
|
||||
oldLineage.push(parent);
|
||||
|
||||
let i = 0;
|
||||
this._newAncestry = [];
|
||||
|
||||
while (true) {
|
||||
|
@ -385,7 +389,6 @@ PresenterContext.prototype = {
|
|||
|
||||
if (newAncestor != oldAncestor)
|
||||
this._newAncestry.push(newAncestor);
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -393,6 +396,34 @@ PresenterContext.prototype = {
|
|||
return this._newAncestry;
|
||||
},
|
||||
|
||||
/*
|
||||
* This is a flattened list of the accessible's subtree in preorder.
|
||||
* It only includes the accessible's visible chidren.
|
||||
*/
|
||||
get subtreePreorder() {
|
||||
function traversePreorder(aAccessible) {
|
||||
let list = [];
|
||||
let child = aAccessible.firstChild;
|
||||
while (child) {
|
||||
let state = {};
|
||||
child.getState(state, {});
|
||||
|
||||
if (!(state.value & Ci.nsIAccessibleStates.STATE_INVISIBLE)) {
|
||||
list.push(child);
|
||||
list.push.apply(list, traversePreorder(child));
|
||||
}
|
||||
|
||||
child = child.nextSibling;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
if (!this._subtreePreOrder)
|
||||
this._subtreePreOrder = traversePreorder(this._accessible);
|
||||
|
||||
return this._subtreePreOrder;
|
||||
},
|
||||
|
||||
_isDefunct: function _isDefunct(aAccessible) {
|
||||
try {
|
||||
let extstate = {};
|
||||
|
|
|
@ -60,15 +60,12 @@ var UtteranceGenerator = {
|
|||
* Generates an utterance for an object.
|
||||
* @param {nsIAccessible} aAccessible accessible object to generate utterance
|
||||
* for.
|
||||
* @param {boolean} aForceName include the object's name in the utterance
|
||||
* even if this object type does not usually have it's name uttered.
|
||||
* @return {Array} Two string array. The first string describes the object
|
||||
* and its states. The second string is the object's name. Some object
|
||||
* types may have the description or name omitted, instead an empty string
|
||||
* is returned as a placeholder. Whether the object's description or it's
|
||||
* role is included is determined by {@link verbosityRoleMap}.
|
||||
* and its states. The second string is the object's name. Whether the
|
||||
* object's description or it's role is included is determined by
|
||||
* {@link verbosityRoleMap}.
|
||||
*/
|
||||
genForObject: function genForObject(aAccessible, aForceName) {
|
||||
genForObject: function genForObject(aAccessible) {
|
||||
let roleString = gAccRetrieval.getStringRole(aAccessible.role);
|
||||
|
||||
let func = this.objectUtteranceFunctions[roleString] ||
|
||||
|
@ -76,7 +73,7 @@ var UtteranceGenerator = {
|
|||
|
||||
let flags = this.verbosityRoleMap[roleString] || 0;
|
||||
|
||||
if (aForceName)
|
||||
if (aAccessible.childCount == 0)
|
||||
flags |= INCLUDE_NAME;
|
||||
|
||||
let state = {};
|
||||
|
@ -130,25 +127,25 @@ var UtteranceGenerator = {
|
|||
'menubar': INCLUDE_DESC,
|
||||
'scrollbar': INCLUDE_DESC,
|
||||
'grip': INCLUDE_DESC,
|
||||
'alert': INCLUDE_DESC,
|
||||
'alert': INCLUDE_DESC | INCLUDE_NAME,
|
||||
'menupopup': INCLUDE_DESC,
|
||||
'menuitem': INCLUDE_DESC,
|
||||
'tooltip': INCLUDE_DESC,
|
||||
'application': INCLUDE_NAME,
|
||||
'document': INCLUDE_NAME,
|
||||
'grouping': INCLUDE_DESC | INCLUDE_NAME,
|
||||
'toolbar': INCLUDE_DESC,
|
||||
'table': INCLUDE_DESC | INCLUDE_NAME,
|
||||
'link': INCLUDE_DESC,
|
||||
'list': INCLUDE_DESC,
|
||||
'listitem': INCLUDE_DESC,
|
||||
'outline': INCLUDE_DESC,
|
||||
'outlineitem': INCLUDE_DESC,
|
||||
'pagetab': INCLUDE_DESC,
|
||||
'graphic': INCLUDE_DESC | INCLUDE_NAME,
|
||||
'statictext': INCLUDE_NAME,
|
||||
'text leaf': INCLUDE_NAME,
|
||||
'graphic': INCLUDE_DESC,
|
||||
'pushbutton': INCLUDE_DESC,
|
||||
'checkbutton': INCLUDE_DESC | INCLUDE_NAME,
|
||||
'radiobutton': INCLUDE_DESC | INCLUDE_NAME,
|
||||
'checkbutton': INCLUDE_DESC,
|
||||
'radiobutton': INCLUDE_DESC,
|
||||
'combobox': INCLUDE_DESC,
|
||||
'droplist': INCLUDE_DESC,
|
||||
'progressbar': INCLUDE_DESC,
|
||||
|
@ -168,11 +165,11 @@ var UtteranceGenerator = {
|
|||
'toggle button': INCLUDE_DESC,
|
||||
'header': INCLUDE_DESC,
|
||||
'footer': INCLUDE_DESC,
|
||||
'entry': INCLUDE_DESC,
|
||||
'entry': INCLUDE_DESC | INCLUDE_NAME,
|
||||
'caption': INCLUDE_DESC,
|
||||
'document frame': INCLUDE_DESC,
|
||||
'heading': INCLUDE_DESC,
|
||||
'calendar': INCLUDE_DESC,
|
||||
'calendar': INCLUDE_DESC | INCLUDE_NAME,
|
||||
'combobox list': INCLUDE_DESC,
|
||||
'combobox option': INCLUDE_DESC,
|
||||
'image map': INCLUDE_DESC,
|
||||
|
|
Загрузка…
Ссылка в новой задаче