Bug 302677. Accessible focus events incorrect for autocomplete. r=mconnor, +sr=neil, a=bsmedberg

This commit is contained in:
aaronleventhal%moonset.net 2005-08-06 04:14:55 +00:00
Родитель e9de7a5fbc
Коммит e3d1c1e4a6
3 изменённых файлов: 19 добавлений и 11 удалений

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

@ -353,14 +353,16 @@ NS_IMETHODIMP nsRootAccessible::GetCaretAccessible(nsIAccessible **aCaretAccessi
} }
void nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible, void nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
nsIDOMNode *aNode) nsIDOMNode *aNode,
PRBool aForceEvent)
{ {
NS_ASSERTION(aAccessible, "Attempted to fire focus event for no accessible"); NS_ASSERTION(aAccessible, "Attempted to fire focus event for no accessible");
PRUint32 role = ROLE_NOTHING;
aAccessible->GetFinalRole(&role);
// Fire focus only if it changes, but always fire focus events for menu items // Fire focus only if it changes, but always fire focus events for menu items
if (gLastFocusedNode == aNode && role != ROLE_MENUITEM) { // Also always fire for XUL tree items, because they always use the same node for
// the tree container itself
// XXX use optional aForceIt bool param
if (gLastFocusedNode == aNode && !aForceEvent) {
return; return;
} }
@ -370,6 +372,8 @@ void nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
// Use focus events on DHTML menuitems to indicate when to fire menustart and menuend // Use focus events on DHTML menuitems to indicate when to fire menustart and menuend
// Special dynamic content handling // Special dynamic content handling
PRUint32 role = ROLE_NOTHING;
aAccessible->GetFinalRole(&role);
PRUint32 naturalRole; // The natural role is the role that this type of element normally has PRUint32 naturalRole; // The natural role is the role that this type of element normally has
aAccessible->GetRole(&naturalRole); aAccessible->GetRole(&naturalRole);
if (role != naturalRole) { if (role != naturalRole) {
@ -551,10 +555,7 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
FireAccessibleFocusEvent(accessible, targetNode); // Tree has focus FireAccessibleFocusEvent(accessible, targetNode); // Tree has focus
} }
else if (eventType.LowerCaseEqualsLiteral("dommenuitemactive")) { else if (eventType.LowerCaseEqualsLiteral("dommenuitemactive")) {
if (gLastFocusedNode == targetNode) { FireAccessibleFocusEvent(treeItemAccessible, targetNode, PR_TRUE);
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_FOCUS,
treeItemAccessible, nsnull);
}
} }
else if (eventType.LowerCaseEqualsLiteral("select")) { else if (eventType.LowerCaseEqualsLiteral("select")) {
// If multiselect tree, we should fire selectionadd or selection removed // If multiselect tree, we should fire selectionadd or selection removed
@ -597,7 +598,7 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
// Only fire focus event for DOMMenuItemActive is not inside collapsed popup // Only fire focus event for DOMMenuItemActive is not inside collapsed popup
if (0 == (containerState & STATE_COLLAPSED)) { if (0 == (containerState & STATE_COLLAPSED)) {
FireAccessibleFocusEvent(accessible, targetNode); FireAccessibleFocusEvent(accessible, targetNode, PR_TRUE);
} }
} }
else if (eventType.LowerCaseEqualsLiteral("focus")) { else if (eventType.LowerCaseEqualsLiteral("focus")) {

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

@ -110,7 +110,8 @@ class nsRootAccessible : public nsDocAccessibleWrap,
nsresult RemoveEventListeners(); nsresult RemoveEventListeners();
static void GetTargetNode(nsIDOMEvent *aEvent, nsIDOMNode **aTargetNode); static void GetTargetNode(nsIDOMEvent *aEvent, nsIDOMNode **aTargetNode);
void FireAccessibleFocusEvent(nsIAccessible *focusAccessible, void FireAccessibleFocusEvent(nsIAccessible *focusAccessible,
nsIDOMNode *focusNode); nsIDOMNode *focusNode,
PRBool aForceEvent = PR_FALSE);
void FireCurrentFocusEvent(); void FireCurrentFocusEvent();
void GetChromeEventHandler(nsIDOMEventTarget **aChromeTarget); void GetChromeEventHandler(nsIDOMEventTarget **aChromeTarget);
nsCOMPtr<nsIAccessibilityService> mAccService; nsCOMPtr<nsIAccessibilityService> mAccService;

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

@ -575,7 +575,13 @@
<body><![CDATA[ <body><![CDATA[
try { try {
var amount = aPage ? 5 : 1; var amount = aPage ? 5 : 1;
this.selectedIndex = this.getNextIndex(aReverse, amount, this.selectedIndex, this.tree.view.rowCount-1); var selectedIndex = this.getNextIndex(aReverse, amount, this.selectedIndex, this.tree.view.rowCount-1);
if (selectedIndex != -1) {
this.selectedIndex = selectedIndex;
}
else {
this.input.focus();
}
} catch (ex) { } catch (ex) {
// do nothing - occasionally timer-related js errors happen here // do nothing - occasionally timer-related js errors happen here
// e.g. "this.selectedIndex has no properties", when you type fast and hit a // e.g. "this.selectedIndex has no properties", when you type fast and hit a