Commit c996e91b authored by Aaron Leventhal's avatar Aaron Leventhal Committed by Commit Bot

Fire UIA/MSAA menu start/end events when menu is shown/hidden

Menu events should fire when a menu is made visible or hidden, whether
or not the menu or something within it gets
focused, because some authors simply show the menu at first, and
only move focus if the user arrows into it. If the menupopupstart
doesn't fire when the menu first appears, then the screen reader
does not know to change to focus mode (virtual cursor off), and
the web page will not receive down arrow keys.

This also matches the behavior of Firefox for menupopupstart.

See the two bugs listed. One contains a general simplified test case
and the other describes how to reproduce the issue with Gmail.

Bug: 98981, 964546
Change-Id: I975513ba73f3b23e884a7f1b38e6b5b161028d17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1637057Reviewed-by: default avatarIan Prest <iapres@microsoft.com>
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666478}
parent d16de39e
......@@ -191,6 +191,8 @@ CONTENT_EXPORT base::string16 AccessibilityEventToString(int32_t event) {
QUOTE(EVENT_OBJECT_DRAGLEAVE),
QUOTE(EVENT_OBJECT_DRAGDROPPED),
QUOTE(EVENT_SYSTEM_ALERT),
QUOTE(EVENT_SYSTEM_MENUPOPUPSTART),
QUOTE(EVENT_SYSTEM_MENUPOPUPEND),
QUOTE(EVENT_SYSTEM_SCROLLINGSTART),
QUOTE(EVENT_SYSTEM_SCROLLINGEND),
QUOTE(IA2_EVENT_ACTION_CHANGED),
......
......@@ -82,6 +82,10 @@ void BrowserAccessibilityManagerWin::OnSubtreeWillBeDeleted(ui::AXTree* tree,
BrowserAccessibility* obj = GetFromAXNode(node);
FireWinAccessibilityEvent(EVENT_OBJECT_HIDE, obj);
FireUiaStructureChangedEvent(StructureChangeType_ChildRemoved, obj);
if (obj && obj->GetRole() == ax::mojom::Role::kMenu) {
FireWinAccessibilityEvent(EVENT_SYSTEM_MENUPOPUPEND, obj);
FireUiaAccessibilityEvent(UIA_MenuClosedEventId, obj);
}
}
void BrowserAccessibilityManagerWin::UserIsReloading() {
......@@ -99,9 +103,6 @@ void BrowserAccessibilityManagerWin::FireFocusEvent(
BrowserAccessibilityManager::FireFocusEvent(node);
DCHECK(node);
if (node->GetRole() == ax::mojom::Role::kMenu)
FireUiaAccessibilityEvent(UIA_MenuOpenedEventId, node);
FireWinAccessibilityEvent(EVENT_OBJECT_FOCUS, node);
FireUiaAccessibilityEvent(UIA_AutomationFocusChangedEventId, node);
}
......@@ -347,6 +348,10 @@ void BrowserAccessibilityManagerWin::FireGeneratedEvent(
case ui::AXEventGenerator::Event::SUBTREE_CREATED:
FireWinAccessibilityEvent(EVENT_OBJECT_SHOW, node);
FireUiaStructureChangedEvent(StructureChangeType_ChildAdded, node);
if (node->GetRole() == ax::mojom::Role::kMenu) {
FireWinAccessibilityEvent(EVENT_SYSTEM_MENUPOPUPSTART, node);
FireUiaAccessibilityEvent(UIA_MenuOpenedEventId, node);
}
break;
case ui::AXEventGenerator::Event::VALUE_CHANGED:
FireWinAccessibilityEvent(EVENT_OBJECT_VALUECHANGE, node);
......@@ -393,9 +398,6 @@ void BrowserAccessibilityManagerWin::FireGeneratedEvent(
void BrowserAccessibilityManagerWin::OnFocusLost(BrowserAccessibility* node) {
BrowserAccessibilityManager::OnFocusLost(node);
DCHECK(node);
if (node->GetRole() == ax::mojom::Role::kMenu)
FireUiaAccessibilityEvent(UIA_MenuClosedEventId, node);
}
void BrowserAccessibilityManagerWin::FireWinAccessibilityEvent(
......
MenuOpened on role=menu, name=menu
=== Start Continuation ===
MenuClosed on role=menu, name=menu
MenuOpened on role=menu, name=submenu1
MenuOpened on role=menu
=== Start Continuation ===
MenuClosed on role=menu, name=submenu1
MenuClosed
MenuClosed on role=menu
=== Start Continuation ===
MenuOpened on role=menu, name=submenu2
=== Start Continuation ===
MenuClosed on role=menu, name=submenu2
MenuClosed
MenuClosed on role=menu, name=menu
\ No newline at end of file
EVENT_SYSTEM_MENUPOPUPSTART on <div#menu> role=ROLE_SYSTEM_MENUPOPUP name="menu" IA2_STATE_VERTICAL SetSize=2
=== Start Continuation ===
EVENT_SYSTEM_MENUPOPUPSTART on <div#submenu> role=ROLE_SYSTEM_MENUPOPUP IA2_STATE_VERTICAL SetSize=1
=== Start Continuation ===
EVENT_SYSTEM_MENUPOPUPEND on <div#submenu> role=ROLE_SYSTEM_MENUPOPUP IA2_STATE_VERTICAL
=== Start Continuation ===
EVENT_SYSTEM_MENUPOPUPEND on <div#menu> role=ROLE_SYSTEM_MENUPOPUP name="menu" IA2_STATE_VERTICAL
<!--
@WIN-DENY:EVENT_OBJECT_FOCUS*
@UIA-WIN-DENY:AutomationFocusChanged*
@WIN-DENY:EVENT_OBJECT_REORDER*
@WIN-DENY:EVENT_OBJECT_SHOW*
@WIN-DENY:EVENT_OBJECT_HIDE*
@WIN-DENY:IA2_EVENT_TEXT_INSERTED*
@WIN-DENY:IA2_EVENT_TEXT_REMOVED*
@UIA-WIN-DENY:*StructureChanged*
@UIA-WIN_DENY:AutomationFocusChanged*
-->
<!DOCTYPE html>
<div tabindex="1" id="menu" aria-label="menu" role="menu">
<div tabindex="2" id="submenu1" aria-label="submenu1" role="menu"></div>
<div tabindex="3" id="submenu2" aria-label="submenu2" role="menu">
<div tabindex="4" id="option" aria-label="option" role="menuitem"></div>
<div id="menu" aria-label="menu" role="menu" style="display: none">
<div tabindex="2" id="menuitem1" aria-label="submenu1" role="menuitem"></div>
<div tabindex="3" id="menuitem2" aria-label="submenu2" role="menuitem">
<div id="submenu" role="menu" style="display:none">
<div tabindex="4" id="menuitem2.1" aria-label="option" role="menuitem"></div>
</div>
</div>
</div>
<script>
const go_passes = [
() => document.getElementById('menu').focus(),
() => document.getElementById('submenu1').focus(),
() => document.getElementById('submenu1').blur(),
() => document.getElementById('submenu2').focus(),
() => document.getElementById('option').focus(),
() => document.getElementById('menu').style.display = 'block',
() => document.getElementById('submenu').style.display = 'block',
() => document.getElementById('submenu').style.display = 'none',
() => document.getElementById('menu').style.display = 'none',
];
var current_pass = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment