Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/controls/menu/menu_controller.h" | 5 #include "ui/views/controls/menu/menu_controller.h" |
| 6 | 6 |
| 7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 if (!blocking_run_) { | 457 if (!blocking_run_) { |
| 458 if (!is_nested_drag) { | 458 if (!is_nested_drag) { |
| 459 // Start the timer to hide the menu. This is needed as we get no | 459 // Start the timer to hide the menu. This is needed as we get no |
| 460 // notification when the drag has finished. | 460 // notification when the drag has finished. |
| 461 StartCancelAllTimer(); | 461 StartCancelAllTimer(); |
| 462 } | 462 } |
| 463 return NULL; | 463 return NULL; |
| 464 } | 464 } |
| 465 | 465 |
| 466 if (button) | 466 if (button) |
| 467 pressed_lock_.reset(new MenuButton::PressedLock(button)); | 467 pressed_lock_.reset(new MenuButton::PressedLock(button, true)); |
|
varkha
2016/03/11 17:57:17
nit: Some better readability on the true / false a
bruthig
2016/03/11 21:58:20
Done.
| |
| 468 | 468 |
| 469 // Make sure Chrome doesn't attempt to shut down while the menu is showing. | 469 // Make sure Chrome doesn't attempt to shut down while the menu is showing. |
| 470 if (ViewsDelegate::GetInstance()) | 470 if (ViewsDelegate::GetInstance()) |
| 471 ViewsDelegate::GetInstance()->AddRef(); | 471 ViewsDelegate::GetInstance()->AddRef(); |
| 472 | 472 |
| 473 if (async_run_) | 473 if (async_run_) |
| 474 return nullptr; | 474 return nullptr; |
| 475 | 475 |
| 476 // We need to turn on nestable tasks as in some situations (pressing alt-f for | 476 // We need to turn on nestable tasks as in some situations (pressing alt-f for |
| 477 // one) the menus are run from a task. If we don't do this and are invoked | 477 // one) the menus are run from a task. If we don't do this and are invoked |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1444 delegate_->SiblingMenuCreated(alt_menu); | 1444 delegate_->SiblingMenuCreated(alt_menu); |
| 1445 | 1445 |
| 1446 if (!button) { | 1446 if (!button) { |
| 1447 // If the delegate returns a menu, they must also return a button. | 1447 // If the delegate returns a menu, they must also return a button. |
| 1448 NOTREACHED(); | 1448 NOTREACHED(); |
| 1449 return false; | 1449 return false; |
| 1450 } | 1450 } |
| 1451 | 1451 |
| 1452 // There is a sibling menu, update the button state, hide the current menu | 1452 // There is a sibling menu, update the button state, hide the current menu |
| 1453 // and show the new one. | 1453 // and show the new one. |
| 1454 pressed_lock_.reset(new MenuButton::PressedLock(button)); | 1454 pressed_lock_.reset(new MenuButton::PressedLock(button, false)); |
| 1455 | 1455 |
| 1456 // Need to reset capture when we show the menu again, otherwise we aren't | 1456 // Need to reset capture when we show the menu again, otherwise we aren't |
| 1457 // going to get any events. | 1457 // going to get any events. |
| 1458 did_capture_ = false; | 1458 did_capture_ = false; |
| 1459 gfx::Point screen_menu_loc; | 1459 gfx::Point screen_menu_loc; |
| 1460 View::ConvertPointToScreen(button, &screen_menu_loc); | 1460 View::ConvertPointToScreen(button, &screen_menu_loc); |
| 1461 | 1461 |
| 1462 // It is currently not possible to show a submenu recursively in a bubble. | 1462 // It is currently not possible to show a submenu recursively in a bubble. |
| 1463 DCHECK(!MenuItemView::IsBubble(anchor)); | 1463 DCHECK(!MenuItemView::IsBubble(anchor)); |
| 1464 // Subtract 1 from the height to make the popup flush with the button border. | 1464 // Subtract 1 from the height to make the popup flush with the button border. |
| (...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2645 return; | 2645 return; |
| 2646 } | 2646 } |
| 2647 if (hot_button_) | 2647 if (hot_button_) |
| 2648 hot_button_->SetHotTracked(false); | 2648 hot_button_->SetHotTracked(false); |
| 2649 hot_button_ = hot_button; | 2649 hot_button_ = hot_button; |
| 2650 if (hot_button) | 2650 if (hot_button) |
| 2651 hot_button->SetHotTracked(true); | 2651 hot_button->SetHotTracked(true); |
| 2652 } | 2652 } |
| 2653 | 2653 |
| 2654 } // namespace views | 2654 } // namespace views |
| OLD | NEW |