diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index 1a6371a58ff..2efd05dc148 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -509,8 +509,14 @@ void nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *focusAccessible, if (focusAccessible && focusNode && gLastFocusedNode != focusNode) { mListener->HandleEvent(nsIAccessibleEventListener::EVENT_FOCUS, focusAccessible, nsnull); NS_IF_RELEASE(gLastFocusedNode); - gLastFocusedNode = focusNode; - NS_ADDREF(gLastFocusedNode); + PRUint32 role = ROLE_NOTHING; + focusAccessible->GetAccRole(&role); + if (role == ROLE_MENUITEM || role == ROLE_LISTITEM) + gLastFocusedNode = nsnull; // This makes it report all focus events on menu and list items + else { + gLastFocusedNode = focusNode; + NS_IF_ADDREF(gLastFocusedNode); + } if (mCaretAccessible) mCaretAccessible->AttachNewSelectionListener(focusNode); } diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 0adc952c013..4d17ddbef3c 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -1499,21 +1499,7 @@ nsListControlFrame::PerformSelection(PRInt32 aSelectedIndex, #endif #ifdef ACCESSIBILITY - // Fire a custom DOM event for the change, so that accessibility can - // fire a native focus event for accessibility - // (Some 3rd party products need to track our focus) - nsCOMPtr event; - nsCOMPtr manager; - mContent->GetListenerManager(getter_AddRefs(manager)); - if (manager && - NS_SUCCEEDED(manager->CreateEvent(mPresContext, nsnull, NS_LITERAL_STRING("Events"), getter_AddRefs(event)))) { - event->InitEvent(NS_LITERAL_STRING("DOMMenuItemActive"), PR_TRUE, PR_TRUE); - PRBool noDefault; - nsCOMPtr esm; - mPresContext->GetEventStateManager(getter_AddRefs(esm)); - if (esm) - esm->DispatchNewEvent(mContent, event, &noDefault); - } + FireMenuItemActiveEvent(); // Inform assistive tech what got focus #endif return wasChanged; @@ -2564,6 +2550,9 @@ nsListControlFrame::AboutToDropDown() mSelectedIndexWhenPoppedDown = selectedIndex; if (mIsAllContentHere && mIsAllFramesHere && mHasBeenInitialized) { ScrollToIndex(selectedIndex); +#ifdef ACCESSIBILITY + FireMenuItemActiveEvent(); // Inform assistive tech what got focus +#endif } return NS_OK; @@ -2862,6 +2851,28 @@ PRBool nsListControlFrame::IsClickingInCombobox(nsIDOMEvent* aMouseEvent) return PR_FALSE; } +//---------------------------------------------------------------------- +// Fire a custom DOM event for the change, so that accessibility can +// fire a native focus event for accessibility +// (Some 3rd party products need to track our focus) +#ifdef ACCESSIBILITY +void +nsListControlFrame::FireMenuItemActiveEvent() +{ + nsCOMPtr event; + nsCOMPtr manager; + mContent->GetListenerManager(getter_AddRefs(manager)); + if (manager && + NS_SUCCEEDED(manager->CreateEvent(mPresContext, nsnull, NS_LITERAL_STRING("Events"), getter_AddRefs(event)))) { + event->InitEvent(NS_LITERAL_STRING("DOMMenuItemActive"), PR_TRUE, PR_TRUE); + PRBool noDefault; + nsCOMPtr esm; + mPresContext->GetEventStateManager(getter_AddRefs(esm)); + if (esm) + esm->DispatchNewEvent(mContent, event, &noDefault); + } +} +#endif //---------------------------------------------------------------------- // Sets the mSelectedIndex and mOldSelectedIndex from figuring out what diff --git a/layout/forms/nsListControlFrame.h b/layout/forms/nsListControlFrame.h index 0cf823f28ed..626ff8cf45c 100644 --- a/layout/forms/nsListControlFrame.h +++ b/layout/forms/nsListControlFrame.h @@ -321,6 +321,10 @@ public: void PaintFocus(nsIRenderingContext& aRC, nsFramePaintLayer aWhichLayer); +#ifdef ACCESSIBILITY + void FireMenuItemActiveEvent(); // Inform assistive tech what got focused +#endif + protected: nsresult IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled); diff --git a/layout/html/forms/src/nsListControlFrame.cpp b/layout/html/forms/src/nsListControlFrame.cpp index 0adc952c013..4d17ddbef3c 100644 --- a/layout/html/forms/src/nsListControlFrame.cpp +++ b/layout/html/forms/src/nsListControlFrame.cpp @@ -1499,21 +1499,7 @@ nsListControlFrame::PerformSelection(PRInt32 aSelectedIndex, #endif #ifdef ACCESSIBILITY - // Fire a custom DOM event for the change, so that accessibility can - // fire a native focus event for accessibility - // (Some 3rd party products need to track our focus) - nsCOMPtr event; - nsCOMPtr manager; - mContent->GetListenerManager(getter_AddRefs(manager)); - if (manager && - NS_SUCCEEDED(manager->CreateEvent(mPresContext, nsnull, NS_LITERAL_STRING("Events"), getter_AddRefs(event)))) { - event->InitEvent(NS_LITERAL_STRING("DOMMenuItemActive"), PR_TRUE, PR_TRUE); - PRBool noDefault; - nsCOMPtr esm; - mPresContext->GetEventStateManager(getter_AddRefs(esm)); - if (esm) - esm->DispatchNewEvent(mContent, event, &noDefault); - } + FireMenuItemActiveEvent(); // Inform assistive tech what got focus #endif return wasChanged; @@ -2564,6 +2550,9 @@ nsListControlFrame::AboutToDropDown() mSelectedIndexWhenPoppedDown = selectedIndex; if (mIsAllContentHere && mIsAllFramesHere && mHasBeenInitialized) { ScrollToIndex(selectedIndex); +#ifdef ACCESSIBILITY + FireMenuItemActiveEvent(); // Inform assistive tech what got focus +#endif } return NS_OK; @@ -2862,6 +2851,28 @@ PRBool nsListControlFrame::IsClickingInCombobox(nsIDOMEvent* aMouseEvent) return PR_FALSE; } +//---------------------------------------------------------------------- +// Fire a custom DOM event for the change, so that accessibility can +// fire a native focus event for accessibility +// (Some 3rd party products need to track our focus) +#ifdef ACCESSIBILITY +void +nsListControlFrame::FireMenuItemActiveEvent() +{ + nsCOMPtr event; + nsCOMPtr manager; + mContent->GetListenerManager(getter_AddRefs(manager)); + if (manager && + NS_SUCCEEDED(manager->CreateEvent(mPresContext, nsnull, NS_LITERAL_STRING("Events"), getter_AddRefs(event)))) { + event->InitEvent(NS_LITERAL_STRING("DOMMenuItemActive"), PR_TRUE, PR_TRUE); + PRBool noDefault; + nsCOMPtr esm; + mPresContext->GetEventStateManager(getter_AddRefs(esm)); + if (esm) + esm->DispatchNewEvent(mContent, event, &noDefault); + } +} +#endif //---------------------------------------------------------------------- // Sets the mSelectedIndex and mOldSelectedIndex from figuring out what diff --git a/layout/html/forms/src/nsListControlFrame.h b/layout/html/forms/src/nsListControlFrame.h index 0cf823f28ed..626ff8cf45c 100644 --- a/layout/html/forms/src/nsListControlFrame.h +++ b/layout/html/forms/src/nsListControlFrame.h @@ -321,6 +321,10 @@ public: void PaintFocus(nsIRenderingContext& aRC, nsFramePaintLayer aWhichLayer); +#ifdef ACCESSIBILITY + void FireMenuItemActiveEvent(); // Inform assistive tech what got focused +#endif + protected: nsresult IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled);