Commit 1d4c6ef2 authored by Aaron Leventhal's avatar Aaron Leventhal Committed by Commit Bot

Fire exactly one selection event when hovering over new menu item

Adjust menu controller to ensure correct number of kSelection events.
These are turned into focus events under MSAA.

- Regular menu items: we were firing extra events even when selection
  didn't change.
- Hot button menu items, such as zoom-related, cut/copy/paste in edit
  menu, were not firing any events on hover, because the button already
  considered itself hot tracked via the button controller's mouse
  handling.

AX-Relnotes: avoid missing or duplicate menu item announcements when using mouse
Bug: 1077755, 1106916
Change-Id: Ie933146b647d56f7665cfc72bb708e9f7bdd71de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2350483
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797288}
parent 16c53719
...@@ -1381,7 +1381,7 @@ void MenuController::SetSelection(MenuItemView* menu_item, ...@@ -1381,7 +1381,7 @@ void MenuController::SetSelection(MenuItemView* menu_item,
StartShowTimer(); StartShowTimer();
// Notify an accessibility focus event on all menu items except for the root. // Notify an accessibility focus event on all menu items except for the root.
if (menu_item && if (menu_item && pending_item_changed &&
(MenuDepth(menu_item) != 1 || (MenuDepth(menu_item) != 1 ||
menu_item->GetType() != MenuItemView::Type::kSubMenu || menu_item->GetType() != MenuItemView::Type::kSubMenu ||
(menu_item->GetType() == MenuItemView::Type::kActionableSubMenu && (menu_item->GetType() == MenuItemView::Type::kActionableSubMenu &&
...@@ -3117,16 +3117,19 @@ void MenuController::SetNextHotTrackedView( ...@@ -3117,16 +3117,19 @@ void MenuController::SetNextHotTrackedView(
SetInitialHotTrackedView(to_select, direction); SetInitialHotTrackedView(to_select, direction);
} }
void MenuController::SetHotTrackedButton(Button* hot_button) { void MenuController::SetHotTrackedButton(Button* new_hot_button) {
if (hot_button_ == new_hot_button)
return;
// If we're providing a new hot-tracked button, first remove the existing one. // If we're providing a new hot-tracked button, first remove the existing one.
if (hot_button_ && hot_button_ != hot_button) { if (hot_button_) {
hot_button_->SetHotTracked(false); hot_button_->SetHotTracked(false);
hot_button_->GetViewAccessibility().EndPopupFocusOverride(); hot_button_->GetViewAccessibility().EndPopupFocusOverride();
} }
// Then set the new one. // Then set the new one.
hot_button_ = hot_button; hot_button_ = new_hot_button;
if (hot_button_ && !hot_button_->IsHotTracked()) { if (hot_button_) {
hot_button_->GetViewAccessibility().SetPopupFocusOverride(); hot_button_->GetViewAccessibility().SetPopupFocusOverride();
hot_button_->SetHotTracked(true); hot_button_->SetHotTracked(true);
hot_button_->NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); hot_button_->NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true);
......
...@@ -612,7 +612,7 @@ class VIEWS_EXPORT MenuController ...@@ -612,7 +612,7 @@ class VIEWS_EXPORT MenuController
SelectionIncrementDirectionType direction); SelectionIncrementDirectionType direction);
// Updates the current |hot_button_| and its hot tracked state. // Updates the current |hot_button_| and its hot tracked state.
void SetHotTrackedButton(Button* hot_button); void SetHotTrackedButton(Button* new_hot_button);
// Returns whether typing a new character will continue the existing prefix // Returns whether typing a new character will continue the existing prefix
// selection. If this returns false, typing a new character will start a new // selection. If this returns false, typing a new character will start a new
......
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