Bug 381229. Incorrect accessible role and events for XUL autocomplete and combobox (menulist) popup lists. r=ginn.chen

This commit is contained in:
aaronleventhal%moonset.net 2007-05-21 13:53:57 +00:00
Родитель 7ff42ce7fa
Коммит 0a12a21fcc
2 изменённых файлов: 27 добавлений и 22 удалений

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

@ -606,25 +606,6 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
return NS_OK;
}
if (eventType.EqualsLiteral("popupshown")) {
// Fire menupopupstart events after a delay so that ancestor views
// are visible, otherwise an accessible cannot be created for the
// popup and the accessibility toolkit event can't be fired.
nsCOMPtr<nsIDOMXULPopupElement> popup(do_QueryInterface(aTargetNode));
if (popup) {
PRInt32 event = nsIAccessibleEvent::EVENT_MENUPOPUP_START;
nsCOMPtr<nsIContent> content(do_QueryInterface(aTargetNode));
if (content->NodeInfo()->Equals(nsAccessibilityAtoms::tooltip, kNameSpaceID_XUL)) {
// There is a single <xul:tooltip> node which Mozilla moves around.
// The accessible for it stays the same no matter where it moves.
// AT's expect to get an EVENT_SHOW for the tooltip.
// In event callback the tooltip's accessible will be ready.
event = nsIAccessibleEvent::EVENT_SHOW;
}
return FireDelayedToolkitEvent(event, aTargetNode, nsnull);
}
}
if (eventType.EqualsLiteral("DOMContentLoaded")) {
// Don't create the doc accessible until load scripts have a chance to set
// role attribute for <body> or <html> element, because the value of
@ -780,6 +761,25 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_ALERT,
accessible, nsnull);
}
if (eventType.EqualsLiteral("popupshown")) {
// Don't fire menupopup events for combobox and autocomplete lists
PRUint32 role = Role(accessible);
PRInt32 event = 0;
if (role == nsIAccessibleRole::ROLE_MENUPOPUP) {
event = nsIAccessibleEvent::EVENT_MENUPOPUP_START;
}
else if (role == nsIAccessibleRole::ROLE_TOOLTIP) {
// There is a single <xul:tooltip> node which Mozilla moves around.
// The accessible for it stays the same no matter where it moves.
// AT's expect to get an EVENT_SHOW for the tooltip.
// In event callback the tooltip's accessible will be ready.
event = nsIAccessibleEvent::EVENT_SHOW;
}
if (event) {
privAcc->FireToolkitEvent(event, accessible, nsnull);
}
}
else if (eventType.EqualsLiteral("popuphiding")) {
// If accessible focus was on or inside popup that closes,
// then restore it to true current focus.
@ -802,8 +802,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
FireCurrentFocusEvent();
}
else if (eventType.EqualsLiteral("DOMMenuInactive")) {
nsCOMPtr<nsIDOMXULPopupElement> popup(do_QueryInterface(aTargetNode));
if (popup) {
if (Role(accessible) == nsIAccessibleRole::ROLE_MENUPOPUP) {
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
accessible, nsnull);
}

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

@ -637,7 +637,13 @@ NS_IMETHODIMP nsXULMenupopupAccessible::GetName(nsAString& _retval)
NS_IMETHODIMP nsXULMenupopupAccessible::GetRole(PRUint32 *aRole)
{
if (mParent && Role(mParent) == nsIAccessibleRole::ROLE_COMBOBOX) {
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (!content) {
return NS_ERROR_FAILURE;
}
if ((mParent && Role(mParent) == nsIAccessibleRole::ROLE_COMBOBOX) ||
content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
nsAccessibilityAtoms::autocomplete, eIgnoreCase)) {
*aRole = nsIAccessibleRole::ROLE_COMBOBOX_LIST;
}
else {