Chromium Code Reviews| 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 7e0ba88d89e316c3458ca7aab66ab7615a757625..8a3e94a4cc9134280729aef741af9c63c3ee0b52 100644 |
| --- a/ui/views/controls/menu/menu_controller.cc |
| +++ b/ui/views/controls/menu/menu_controller.cc |
| @@ -364,6 +364,7 @@ struct MenuController::SelectByCharDetails { |
| MenuController::State::State() |
| : item(NULL), |
| + hot_button(NULL), |
|
sky
2016/03/23 21:42:40
nullptr (feel free to change NULL on the previous
varkha
2016/03/24 18:36:18
Done.
|
| submenu_open(false), |
| anchor(MENU_ANCHOR_TOPLEFT), |
| context_menu(false) { |
| @@ -424,6 +425,7 @@ MenuItemView* MenuController::Run(Widget* parent, |
| // blocking/non-blocking shouldn't be needed. |
| DCHECK(blocking_run_); |
| + state_.hot_button = pending_state_.hot_button; |
| // We're already showing, push the current state. |
| menu_stack_.push_back( |
| std::make_pair(state_, make_linked_ptr(pressed_lock_.release()))); |
| @@ -558,8 +560,8 @@ bool MenuController::OnMousePressed(SubmenuView* source, |
| View* view = |
| forward_to_root->GetEventHandlerForPoint(event_for_root.location()); |
| CustomButton* button = CustomButton::AsCustomButton(view); |
| - if (hot_button_ && hot_button_ != button) |
| - SetHotTrackedButton(nullptr); |
| + if (pending_state_.hot_button != button) |
| + SetHotTrackedButton(button); |
| // Empty menu items are always handled by the menu controller. |
| if (!view || view->id() != MenuItemView::kEmptyMenuItemViewID) { |
| @@ -758,7 +760,7 @@ void MenuController::OnGestureEvent(SubmenuView* source, |
| View* view = |
| root_view->GetEventHandlerForPoint(event_for_root.location()); |
| CustomButton* button = CustomButton::AsCustomButton(view); |
| - if (hot_button_ && hot_button_ != button) |
| + if (pending_state_.hot_button && pending_state_.hot_button != button) |
| SetHotTrackedButton(nullptr); |
| } |
| @@ -834,9 +836,9 @@ void MenuController::ViewHierarchyChanged( |
| current_mouse_event_target_ = nullptr; |
| current_mouse_pressed_state_ = 0; |
| } |
| - // Update |hot_button_| if it gets removed while a menu is up. |
| - if (details.child == hot_button_) |
| - hot_button_ = nullptr; |
| + // Update |pending_state_.hot_button| if it gets removed while a menu is up. |
| + if (details.child == pending_state_.hot_button) |
| + pending_state_.hot_button = nullptr; |
| } |
| } |
| @@ -1316,7 +1318,6 @@ 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()), |
| @@ -2124,7 +2125,7 @@ void MenuController::IncrementSelection( |
| if (item->has_children()) { |
| CustomButton* button = GetFirstHotTrackedView(item); |
| if (button) { |
| - DCHECK_EQ(hot_button_, button); |
| + DCHECK_EQ(pending_state_.hot_button, button); |
| SetHotTrackedButton(nullptr); |
| } |
| bool direction_is_down = direction == INCREMENT_SELECTION_DOWN; |
| @@ -2588,9 +2589,11 @@ MenuItemView* MenuController::ExitMenuRun() { |
| } |
| } |
| - // Reset our pressed lock to the previous state's, if there was one. |
| - // The lock handles the case if the button was destroyed. |
| + // Reset our pressed lock and hot-tracked state to the previous state's, if |
| + // they were active. The lock handles the case if the button was destroyed. |
| pressed_lock_.reset(nested_pressed_lock.release()); |
| + if (pending_state_.hot_button) |
| + pending_state_.hot_button->SetHotTracked(true); |
| return result; |
| } |
| @@ -2639,15 +2642,15 @@ void MenuController::SetInitialHotTrackedView( |
| } |
| void MenuController::SetHotTrackedButton(CustomButton* hot_button) { |
| - if (hot_button == hot_button_) { |
| + if (hot_button == pending_state_.hot_button) { |
| // Hot-tracked state may change outside of the MenuController. Correct it. |
| if (hot_button && !hot_button->IsHotTracked()) |
| hot_button->SetHotTracked(true); |
| return; |
| } |
| - if (hot_button_) |
| - hot_button_->SetHotTracked(false); |
| - hot_button_ = hot_button; |
| + if (pending_state_.hot_button) |
| + pending_state_.hot_button->SetHotTracked(false); |
| + pending_state_.hot_button = hot_button; |
| if (hot_button) |
| hot_button->SetHotTracked(true); |
| } |