Bug 877124 - [AccessFu] Trust explicitly associated names of the current pivot and its children. r=eeejay

This commit is contained in:
Yura Zenevich 2013-06-10 13:31:17 -07:00
Родитель 33ee1de0f6
Коммит 59b31d660b
2 изменённых файлов: 33 добавлений и 36 удалений

Просмотреть файл

@ -383,44 +383,41 @@ PivotContext.prototype = {
/*
* Traverse the accessible's subtree in pre or post order.
* It only includes the accessible's visible chidren.
* Note: needSubtree is a function argument that can be used to determine
* whether aAccessible's subtree is required.
*/
_traverse: function _traverse(aAccessible, preorder) {
let list = [];
_traverse: function _traverse(aAccessible, aPreorder, aStop) {
if (aStop && aStop(aAccessible)) {
return;
}
let child = aAccessible.firstChild;
while (child) {
let state = {};
child.getState(state, {});
if (!(state.value & Ci.nsIAccessibleStates.STATE_INVISIBLE)) {
let traversed = _traverse(child, preorder);
// Prepend or append a child, based on traverse order.
traversed[preorder ? "unshift" : "push"](child);
list.push.apply(list, traversed);
if (aPreorder) {
yield child;
[yield node for (node of this._traverse(child, aPreorder, aStop))];
} else {
[yield node for (node of this._traverse(child, aPreorder, aStop))];
yield child;
}
}
child = child.nextSibling;
}
return list;
},
/*
* This is a flattened list of the accessible's subtree in preorder.
* A subtree generator function, used to generate a flattened
* list of the accessible's subtree in pre or post order.
* It only includes the accessible's visible chidren.
* @param {boolean} aPreorder A flag for traversal order. If true, traverse
* in preorder; if false, traverse in postorder.
* @param {function} aStop An optional function, indicating whether subtree
* traversal should stop.
*/
get subtreePreorder() {
if (!this._subtreePreOrder)
this._subtreePreOrder = this._traverse(this._accessible, true);
return this._subtreePreOrder;
},
/*
* This is a flattened list of the accessible's subtree in postorder.
* It only includes the accessible's visible chidren.
*/
get subtreePostorder() {
if (!this._subtreePostOrder)
this._subtreePostOrder = this._traverse(this._accessible, false);
return this._subtreePostOrder;
subtreeGenerator: function subtreeGenerator(aPreorder, aStop) {
return this._traverse(this._accessible, aPreorder, aStop);
},
get bounds() {

Просмотреть файл

@ -75,24 +75,24 @@ this.UtteranceGenerator = {
utterance.push.apply(utterance,
UtteranceGenerator.genForObject(aAccessible));
};
let roleString = Utils.AccRetrieval.getStringRole(aContext.accessible.role);
let nameRule = this.roleRuleMap[roleString] || 0;
let ignoreSubtree = function ignoreSubtree(aAccessible) {
let roleString = Utils.AccRetrieval.getStringRole(aAccessible.role);
let nameRule = UtteranceGenerator.roleRuleMap[roleString] || 0;
// Ignore subtree if the name is explicit and the role's name rule is the
// NAME_FROM_SUBTREE_RULE.
return (nameRule & NAME_FROM_SUBTREE_RULE) &&
(Utils.getAttributes(aAccessible)['explicit-name'] === 'true');
};
let utteranceOrder = gUtteranceOrder.value || UTTERANCE_DESC_FIRST;
// Include subtree if the name is not explicit or the role's name rule is
// not the NAME_FROM_SUBTREE_RULE.
let includeSubtree = (Utils.getAttributes(aContext.accessible)[
'explicit-name'] !== 'true') || !(nameRule & NAME_FROM_SUBTREE_RULE);
if (utteranceOrder === UTTERANCE_DESC_FIRST) {
aContext.newAncestry.forEach(addUtterance);
addUtterance(aContext.accessible);
if (includeSubtree) {
aContext.subtreePreorder.forEach(addUtterance);
}
[addUtterance(node) for
(node of aContext.subtreeGenerator(true, ignoreSubtree))];
} else {
if (includeSubtree) {
aContext.subtreePostorder.forEach(addUtterance);
}
[addUtterance(node) for
(node of aContext.subtreeGenerator(false, ignoreSubtree))];
addUtterance(aContext.accessible);
aContext.newAncestry.reverse().forEach(addUtterance);
}