Bug 752125 - Switch to a role-based traversal rule. r=davidb

This commit is contained in:
Eitan Isaacson 2012-05-07 11:21:21 -07:00
Родитель 6dfe7f3a97
Коммит 64b8bb0c89
1 изменённых файлов: 53 добавлений и 24 удалений

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

@ -114,38 +114,67 @@ var VirtualCursorController = {
SimpleTraversalRule: { SimpleTraversalRule: {
getMatchRoles: function(aRules) { getMatchRoles: function(aRules) {
aRules.value = []; aRules.value = this._matchRoles;
return 0; return this._matchRoles.length;
}, },
preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT | preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE, Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
match: function(aAccessible) { match: function(aAccessible) {
if (aAccessible.childCount) switch (aAccessible.role) {
// Non-leafs do not interest us. case Ci.nsIAccessibleRole.ROLE_COMBOBOX:
return Ci.nsIAccessibleTraversalRule.FILTER_IGNORE; // We don't want to ignore the subtree because this is often
// where the list box hangs out.
// XXX: Find a better solution for ROLE_STATICTEXT.
// It allows to filter list bullets but the same time it
// filters CSS generated content too as unwanted side effect.
let ignoreRoles = [Ci.nsIAccessibleRole.ROLE_WHITESPACE,
Ci.nsIAccessibleRole.ROLE_STATICTEXT];
if (ignoreRoles.indexOf(aAccessible.role) < 0) {
let name = aAccessible.name;
if (name && name.trim())
return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
}
let state = {};
aAccessible.getState(state, {});
if (state.value & Ci.nsIAccessibleStates.STATE_FOCUSABLE)
return Ci.nsIAccessibleTraversalRule.FILTER_MATCH; return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
case Ci.nsIAccessibleRole.ROLE_TEXT_LEAF:
return Ci.nsIAccessibleTraversalRule.FILTER_IGNORE; {
// Nameless text leaves are boring, skip them.
let name = aAccessible.name;
if (name && name.trim())
return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
else
return Ci.nsIAccessibleTraversalRule.FILTER_IGNORE;
}
case Ci.nsIAccessibleRole.ROLE_LINK:
// If the link has children we should land on them instead.
// Image map links don't have children so we need to match those.
if (aAccessible.childCount == 0)
return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
else
return Ci.nsIAccessibleTraversalRule.FILTER_IGNORE;
default:
// Ignore the subtree, if there is one. So that we don't land on
// the same content that was already presented by its parent.
return Ci.nsIAccessibleTraversalRule.FILTER_MATCH |
Ci.nsIAccessibleTraversalRule.FILTER_IGNORE_SUBTREE;
}
}, },
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule]) QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule]),
_matchRoles: [
Ci.nsIAccessibleRole.ROLE_MENUITEM,
Ci.nsIAccessibleRole.ROLE_LINK,
Ci.nsIAccessibleRole.ROLE_PAGETAB,
Ci.nsIAccessibleRole.ROLE_GRAPHIC,
// XXX: Find a better solution for ROLE_STATICTEXT.
// It allows to filter list bullets but at the same time it
// filters CSS generated content too as an unwanted side effect.
// Ci.nsIAccessibleRole.ROLE_STATICTEXT,
Ci.nsIAccessibleRole.ROLE_TEXT_LEAF,
Ci.nsIAccessibleRole.ROLE_PUSHBUTTON,
Ci.nsIAccessibleRole.ROLE_CHECKBUTTON,
Ci.nsIAccessibleRole.ROLE_RADIOBUTTON,
Ci.nsIAccessibleRole.ROLE_COMBOBOX,
Ci.nsIAccessibleRole.ROLE_PROGRESSBAR,
Ci.nsIAccessibleRole.ROLE_BUTTONDROPDOWN,
Ci.nsIAccessibleRole.ROLE_BUTTONMENU,
Ci.nsIAccessibleRole.ROLE_CHECK_MENU_ITEM,
Ci.nsIAccessibleRole.ROLE_PASSWORD_TEXT,
Ci.nsIAccessibleRole.ROLE_RADIO_MENU_ITEM,
Ci.nsIAccessibleRole.ROLE_TOGGLE_BUTTON,
Ci.nsIAccessibleRole.ROLE_ENTRY
]
} }
}; };