Fix for bug 377612 - move out state change events handling from atk, r=ginn.chen

This commit is contained in:
surkov.alexander@gmail.com 2007-04-17 05:39:10 -07:00
parent 8f6cd808de
commit cefcd1875d
2 changed files with 43 additions and 52 deletions

View File

@ -140,40 +140,6 @@ nsresult nsRootAccessibleWrap::HandleEventWithTarget(nsIDOMEvent *aEvent,
nsCOMPtr<nsPIAccessible> privAcc(do_QueryInterface(accessible));
if (eventType.EqualsLiteral("CheckboxStateChange") || // it's a XUL <checkbox>
eventType.EqualsLiteral("RadioStateChange")) { // it's a XUL <radio>
PRUint32 state = State(accessible);
// prefPane tab is implemented as list items in A11y, so we need to
// check nsIAccessibleStates::STATE_SELECTED also.
PRBool isEnabled = (state & (nsIAccessibleStates::STATE_CHECKED |
nsIAccessibleStates::STATE_SELECTED)) != 0;
nsCOMPtr<nsIAccessibleStateChangeEvent> accEvent =
new nsAccStateChangeEvent(accessible,
nsIAccessibleStates::STATE_CHECKED,
PR_FALSE, isEnabled);
FireAccessibleEvent(accEvent);
// only fire focus event for checked radio
if (eventType.EqualsLiteral("RadioStateChange") && isEnabled) {
FireAccessibleFocusEvent(accessible, aTargetNode, aEvent);
}
return NS_OK;
}
if (eventType.EqualsLiteral("OpenStateChange")) {
PRUint32 state = State(accessible); // collapsed/expanded changed
PRBool isEnabled = (state & nsIAccessibleStates::STATE_EXPANDED) != 0;
nsCOMPtr<nsIAccessibleStateChangeEvent> accEvent =
new nsAccStateChangeEvent(accessible,
nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE, isEnabled);
return FireAccessibleEvent(accEvent);
}
#ifdef MOZ_XUL
// If it's a tree element, need the currently selected item
nsCOMPtr<nsIAccessible> treeItemAccessible;

View File

@ -643,9 +643,41 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
nsCOMPtr<nsIAccessible> accessible;
accService->GetAccessibleInShell(aTargetNode, eventShell,
getter_AddRefs(accessible));
if (!accessible)
nsCOMPtr<nsPIAccessible> privAcc(do_QueryInterface(accessible));
if (!privAcc)
return NS_OK;
if (eventType.EqualsLiteral("RadioStateChange")) {
PRUint32 state = State(accessible);
PRBool isEnabled = state & nsIAccessibleStates::STATE_CHECKED;
nsCOMPtr<nsIAccessibleStateChangeEvent> accEvent =
new nsAccStateChangeEvent(accessible, nsIAccessibleStates::STATE_CHECKED,
PR_FALSE, isEnabled);
privAcc->FireAccessibleEvent(accEvent);
if (isEnabled)
FireAccessibleFocusEvent(accessible, aTargetNode, aEvent);
return NS_OK;
}
if (eventType.EqualsLiteral("CheckboxStateChange")) {
PRUint32 state = State(accessible);
// prefPane tab is implemented as list items in A11y, so we need to
// check nsIAccessibleStates::STATE_SELECTED also.
PRBool isEnabled = (state & (nsIAccessibleStates::STATE_CHECKED |
nsIAccessibleStates::STATE_SELECTED)) != 0;
nsCOMPtr<nsIAccessibleStateChangeEvent> accEvent =
new nsAccStateChangeEvent(accessible,
nsIAccessibleStates::STATE_CHECKED,
PR_FALSE, isEnabled);
return privAcc->FireAccessibleEvent(accEvent);
}
nsCOMPtr<nsIAccessible> treeItemAccessible;
#ifdef MOZ_XUL
// If it's a tree element, need the currently selected item
@ -671,16 +703,18 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
}
#endif
nsCOMPtr<nsPIAccessible> privAcc(do_QueryInterface(accessible));
#ifdef MOZ_XUL
// tree event
if (eventType.EqualsLiteral("CheckboxStateChange") ||
eventType.EqualsLiteral("OpenStateChange")) {
return privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE,
accessible, nsnull);
if (treeItemAccessible && eventType.EqualsLiteral("OpenStateChange")) {
PRUint32 state = State(accessible); // collapsed/expanded changed
PRBool isEnabled = (state & nsIAccessibleStates::STATE_EXPANDED) != 0;
nsCOMPtr<nsIAccessibleStateChangeEvent> accEvent =
new nsAccStateChangeEvent(accessible, nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE, isEnabled);
return FireAccessibleEvent(accEvent);
}
else if (treeItemAccessible && eventType.EqualsLiteral("select")) {
if (treeItemAccessible && eventType.EqualsLiteral("select")) {
// If multiselect tree, we should fire selectionadd or selection removed
if (gLastFocusedNode == aTargetNode) {
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSel =
@ -742,15 +776,6 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_ALERT,
accessible, nsnull);
}
else if (eventType.EqualsLiteral("RadioStateChange")) {
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE,
accessible, nsnull);
PRUint32 finalState = State(accessible);
if (finalState & (nsIAccessibleStates::STATE_CHECKED |
nsIAccessibleStates::STATE_SELECTED)) {
FireAccessibleFocusEvent(accessible, aTargetNode, aEvent);
}
}
else if (eventType.EqualsLiteral("popuphiding")) {
// If accessible focus was on or inside popup that closes,
// then restore it to true current focus.