| Index: ui/views/controls/menu/menu_controller.cc
|
| diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
|
| index 1cd057e8dcfc1e33813236383bba75570df59295..9289c5f8e0b9a3d9fed948195b98749b151e1249 100644
|
| --- a/ui/views/controls/menu/menu_controller.cc
|
| +++ b/ui/views/controls/menu/menu_controller.cc
|
| @@ -114,6 +114,21 @@ static CustomButton* GetFirstHotTrackedView(View* view) {
|
| return NULL;
|
| }
|
|
|
| +CustomButton* OtherHotTrackedButton(View* view, CustomButton* button_hot) {
|
| + if (!view)
|
| + return nullptr;
|
| + CustomButton* button = CustomButton::AsCustomButton(view);
|
| + if (button && button != button_hot && button->IsHotTracked())
|
| + return button;
|
| +
|
| + for (int i = 0; i < view->child_count(); ++i) {
|
| + button = OtherHotTrackedButton(view->child_at(i), button_hot);
|
| + if (button)
|
| + return button;
|
| + }
|
| + return nullptr;
|
| +}
|
| +
|
| // Recurses through the child views of |view| returning the first view starting
|
| // at |start| that is focusable. A value of -1 for |start| indicates to start at
|
| // the first view (if |forward| is false, iterating starts at the last view). If
|
| @@ -939,7 +954,13 @@ void MenuController::SetSelection(MenuItemView* menu_item,
|
| if (pending_item_changed && pending_state_.item) {
|
| CustomButton* button = GetFirstHotTrackedView(pending_state_.item);
|
| if (button)
|
| - button->SetHotTracked(false);
|
| + SetHotTrackedButton(button, false);
|
| + }
|
| + CustomButton* new_hot_button = OtherHotTrackedButton(menu_item, hot_button_);
|
| + if (new_hot_button) {
|
| + if (hot_button_)
|
| + SetHotTrackedButton(hot_button_, false);
|
| + SetHotTrackedButton(new_hot_button, true);
|
| }
|
|
|
| // Notify the old path it isn't selected.
|
| @@ -1191,6 +1212,7 @@ MenuController::MenuController(bool blocking,
|
| last_drop_operation_(MenuDelegate::DROP_UNKNOWN),
|
| showing_submenu_(false),
|
| active_mouse_view_id_(ViewStorage::GetInstance()->CreateStorageID()),
|
| + hot_button_(nullptr),
|
| delegate_(delegate),
|
| message_loop_depth_(0),
|
| closing_event_time_(base::TimeDelta()),
|
| @@ -1226,8 +1248,7 @@ bool MenuController::SendAcceleratorToHotTrackedView() {
|
|
|
| ui::Accelerator accelerator(ui::VKEY_RETURN, ui::EF_NONE);
|
| hot_view->AcceleratorPressed(accelerator);
|
| - CustomButton* button = static_cast<CustomButton*>(hot_view);
|
| - button->SetHotTracked(true);
|
| + SetHotTrackedButton(hot_view, true);
|
| return true;
|
| }
|
|
|
| @@ -1989,8 +2010,7 @@ void MenuController::IncrementSelection(
|
| // select the first menu item that is visible and enabled.
|
| if (item->GetSubmenu()->GetMenuItemCount()) {
|
| MenuItemView* to_select = FindInitialSelectableMenuItem(item, direction);
|
| - if (to_select)
|
| - SetSelection(to_select, SELECTION_DEFAULT);
|
| + SetInitialHotTrackedView(to_select, direction);
|
| return;
|
| }
|
| }
|
| @@ -1998,12 +2018,12 @@ void MenuController::IncrementSelection(
|
| if (item->has_children()) {
|
| CustomButton* button = GetFirstHotTrackedView(item);
|
| if (button) {
|
| - button->SetHotTracked(false);
|
| + SetHotTrackedButton(button, false);
|
| View* to_make_hot = GetNextFocusableView(
|
| item, button, direction == INCREMENT_SELECTION_DOWN);
|
| CustomButton* button_hot = CustomButton::AsCustomButton(to_make_hot);
|
| if (button_hot) {
|
| - button_hot->SetHotTracked(true);
|
| + SetHotTrackedButton(button_hot, true);
|
| return;
|
| }
|
| } else {
|
| @@ -2011,7 +2031,7 @@ void MenuController::IncrementSelection(
|
| GetInitialFocusableView(item, direction == INCREMENT_SELECTION_DOWN);
|
| CustomButton* button_hot = CustomButton::AsCustomButton(to_make_hot);
|
| if (button_hot) {
|
| - button_hot->SetHotTracked(true);
|
| + SetHotTrackedButton(button_hot, true);
|
| return;
|
| }
|
| }
|
| @@ -2025,14 +2045,7 @@ void MenuController::IncrementSelection(
|
| if (parent->GetSubmenu()->GetMenuItemAt(i) == item) {
|
| MenuItemView* to_select =
|
| FindNextSelectableMenuItem(parent, i, direction);
|
| - if (!to_select)
|
| - break;
|
| - SetSelection(to_select, SELECTION_DEFAULT);
|
| - View* to_make_hot = GetInitialFocusableView(
|
| - to_select, direction == INCREMENT_SELECTION_DOWN);
|
| - CustomButton* button_hot = CustomButton::AsCustomButton(to_make_hot);
|
| - if (button_hot)
|
| - button_hot->SetHotTracked(true);
|
| + SetInitialHotTrackedView(to_select, direction);
|
| break;
|
| }
|
| }
|
| @@ -2597,4 +2610,30 @@ void MenuController::HandleMouseLocation(SubmenuView* source,
|
| }
|
| }
|
|
|
| +void MenuController::SetHotTrackedButton(CustomButton* hot_button,
|
| + bool is_hot_tracked) {
|
| + DCHECK(hot_button);
|
| + hot_button->SetHotTracked(is_hot_tracked);
|
| + if (is_hot_tracked)
|
| + hot_button_ = hot_button;
|
| + else if (hot_button_ == hot_button)
|
| + hot_button_ = nullptr;
|
| + else
|
| + NOTREACHED();
|
| +}
|
| +
|
| +void MenuController::SetInitialHotTrackedView(
|
| + MenuItemView* item,
|
| + SelectionIncrementDirectionType direction) {
|
| + if (!item)
|
| + return;
|
| + SetSelection(item, SELECTION_DEFAULT);
|
| + View* to_make_hot = GetInitialFocusableView(
|
| + item, direction == INCREMENT_SELECTION_DOWN);
|
| + CustomButton* button_hot = CustomButton::AsCustomButton(to_make_hot);
|
| + if (button_hot)
|
| + SetHotTrackedButton(button_hot, true);
|
| + return;
|
| +}
|
| +
|
| } // namespace views
|
|
|