diff options
author | ctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-06 00:44:59 +0000 |
---|---|---|
committer | ctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-06 00:44:59 +0000 |
commit | e12e3f689c07014a9cd5f1b0a626f7d136e12ef8 (patch) | |
tree | 4e4a4256d230d78c23ff8e2ae4a1a3de461b5a8a /views/controls | |
parent | de4817b40830c7d3af8c63e1f5ae14dde042fed0 (diff) | |
download | chromium_src-e12e3f689c07014a9cd5f1b0a626f7d136e12ef8.zip chromium_src-e12e3f689c07014a9cd5f1b0a626f7d136e12ef8.tar.gz chromium_src-e12e3f689c07014a9cd5f1b0a626f7d136e12ef8.tar.bz2 |
Enable better NVDA support for custom menus.
- Send the popupmenu events on the MenuScrollViewContainer since it is the View with the ROLE_MENUPOPUP role.
- Return AccessibilityTypes::STATE_FOCUSED for MenuScrollViewContainer since it's not focused by MenuHostWin::ShowMenuHost. NVDA won't process children menu item's focus events unless a parent claims to have focus.
TEST=The wrench menu and it's menu items are read aloud when using NVDA.
BUG=49360
Review URL: http://codereview.chromium.org/3015055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55163 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r-- | views/controls/menu/menu_controller.cc | 11 | ||||
-rw-r--r-- | views/controls/menu/menu_scroll_view_container.cc | 9 | ||||
-rw-r--r-- | views/controls/menu/menu_scroll_view_container.h | 1 | ||||
-rw-r--r-- | views/controls/menu/submenu_view.cc | 14 |
4 files changed, 25 insertions, 10 deletions
diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index 3d49366..d5abe50 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -247,9 +247,6 @@ MenuItemView* MenuController::Run(gfx::NativeWindow parent, owner_ = parent; - if (button) - button->NotifyAccessibilityEvent(AccessibilityTypes::EVENT_MENUPOPUPSTART); - // Set the selection, which opens the initial menu. SetSelection(root, true, true); @@ -382,11 +379,6 @@ void MenuController::SetSelection(MenuItemView* menu_item, (MenuDepth(menu_item) != 1 || menu_item->GetType() != MenuItemView::SUBMENU)) menu_item->NotifyAccessibilityEvent(AccessibilityTypes::EVENT_FOCUS); - - if (menu_button_ && !menu_item && exit_type_ != EXIT_DESTROYED) { - menu_button_-> - NotifyAccessibilityEvent(AccessibilityTypes::EVENT_MENUPOPUPEND); - } } void MenuController::Cancel(ExitType type) { @@ -814,7 +806,6 @@ bool MenuController::Dispatch(const MSG& msg) { #else bool MenuController::Dispatch(GdkEvent* event) { - if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { gtk_main_do_event(event); return false; @@ -1212,7 +1203,7 @@ void MenuController::CommitPendingSelection() { state_.open_leading.clear(); } else { int cached_size = static_cast<int>(state_.open_leading.size()); - DCHECK(menu_depth >= 0); + DCHECK_GE(menu_depth, 0); while (cached_size-- >= menu_depth) state_.open_leading.pop_back(); } diff --git a/views/controls/menu/menu_scroll_view_container.cc b/views/controls/menu/menu_scroll_view_container.cc index 532366c..a88f0a4 100644 --- a/views/controls/menu/menu_scroll_view_container.cc +++ b/views/controls/menu/menu_scroll_view_container.cc @@ -274,4 +274,13 @@ bool MenuScrollViewContainer::GetAccessibleRole( return true; } +bool MenuScrollViewContainer::GetAccessibleState( + AccessibilityTypes::State* state) { + DCHECK(state); + // Some AT (like NVDA) will not process focus events on menu item children + // unless a parent claims to be focused. + *state = AccessibilityTypes::STATE_FOCUSED; + return true; +} + } // namespace views diff --git a/views/controls/menu/menu_scroll_view_container.h b/views/controls/menu/menu_scroll_view_container.h index cf7788e..41a0188 100644 --- a/views/controls/menu/menu_scroll_view_container.h +++ b/views/controls/menu/menu_scroll_view_container.h @@ -30,6 +30,7 @@ class MenuScrollViewContainer : public View { const gfx::Rect& current); virtual gfx::Size GetPreferredSize(); virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); + virtual bool GetAccessibleState(AccessibilityTypes::State* state); private: class MenuScrollView; diff --git a/views/controls/menu/submenu_view.cc b/views/controls/menu/submenu_view.cc index de74aa1..2cfd8b8 100644 --- a/views/controls/menu/submenu_view.cc +++ b/views/controls/menu/submenu_view.cc @@ -227,6 +227,9 @@ void SubmenuView::ShowAt(gfx::NativeWindow parent, bool do_capture) { if (host_) { host_->ShowMenuHost(do_capture); + + GetScrollViewContainer()->NotifyAccessibilityEvent( + AccessibilityTypes::EVENT_MENUPOPUPSTART); return; } @@ -236,6 +239,9 @@ void SubmenuView::ShowAt(gfx::NativeWindow parent, // Make sure the first row is visible. ScrollRectToVisible(gfx::Rect(gfx::Point(), gfx::Size(1, 1))); host_->Init(parent, bounds, scroll_view_container_, do_capture); + + GetScrollViewContainer()->NotifyAccessibilityEvent( + AccessibilityTypes::EVENT_MENUPOPUPSTART); } void SubmenuView::Reposition(const gfx::Rect& bounds) { @@ -245,6 +251,9 @@ void SubmenuView::Reposition(const gfx::Rect& bounds) { void SubmenuView::Close() { if (host_) { + GetScrollViewContainer()->NotifyAccessibilityEvent( + AccessibilityTypes::EVENT_MENUPOPUPEND); + host_->DestroyMenuHost(); host_ = NULL; } @@ -288,6 +297,11 @@ MenuScrollViewContainer* SubmenuView::GetScrollViewContainer() { scroll_view_container_ = new MenuScrollViewContainer(this); // Otherwise MenuHost would delete us. scroll_view_container_->set_parent_owned(false); + + // Use the parent menu item accessible name for the menu view. + std::wstring accessible_name; + GetMenuItem()->GetAccessibleName(&accessible_name); + scroll_view_container_->SetAccessibleName(accessible_name); } return scroll_view_container_; } |