| 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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1671 | 1671 |
| 1672 void MenuController::BuildMenuItemPath(MenuItemView* item, | 1672 void MenuController::BuildMenuItemPath(MenuItemView* item, |
| 1673 std::vector<MenuItemView*>* path) { | 1673 std::vector<MenuItemView*>* path) { |
| 1674 if (!item) | 1674 if (!item) |
| 1675 return; | 1675 return; |
| 1676 BuildMenuItemPath(item->GetParentMenuItem(), path); | 1676 BuildMenuItemPath(item->GetParentMenuItem(), path); |
| 1677 path->push_back(item); | 1677 path->push_back(item); |
| 1678 } | 1678 } |
| 1679 | 1679 |
| 1680 void MenuController::StartShowTimer() { | 1680 void MenuController::StartShowTimer() { |
| 1681 MenuItemView* item = pending_state_.item ? pending_state_.item : state_.item; | |
| 1682 show_timer_.Start( | 1681 show_timer_.Start( |
| 1683 FROM_HERE, TimeDelta::FromMilliseconds(item->GetMenuConfig().show_delay), | 1682 FROM_HERE, TimeDelta::FromMilliseconds(MenuConfig::instance().show_delay), |
| 1684 this, &MenuController::CommitPendingSelection); | 1683 this, &MenuController::CommitPendingSelection); |
| 1685 } | 1684 } |
| 1686 | 1685 |
| 1687 void MenuController::StopShowTimer() { | 1686 void MenuController::StopShowTimer() { |
| 1688 show_timer_.Stop(); | 1687 show_timer_.Stop(); |
| 1689 } | 1688 } |
| 1690 | 1689 |
| 1691 void MenuController::StartCancelAllTimer() { | 1690 void MenuController::StartCancelAllTimer() { |
| 1692 cancel_all_timer_.Start(FROM_HERE, | 1691 cancel_all_timer_.Start(FROM_HERE, |
| 1693 TimeDelta::FromMilliseconds(kCloseOnExitTime), | 1692 TimeDelta::FromMilliseconds(kCloseOnExitTime), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1716 pref.set_width(std::min(pref.width(), | 1715 pref.set_width(std::min(pref.width(), |
| 1717 item->GetDelegate()->GetMaxWidthForMenu(item))); | 1716 item->GetDelegate()->GetMaxWidthForMenu(item))); |
| 1718 if (!state_.monitor_bounds.IsEmpty()) | 1717 if (!state_.monitor_bounds.IsEmpty()) |
| 1719 pref.set_width(std::min(pref.width(), state_.monitor_bounds.width())); | 1718 pref.set_width(std::min(pref.width(), state_.monitor_bounds.width())); |
| 1720 | 1719 |
| 1721 // Assume we can honor prefer_leading. | 1720 // Assume we can honor prefer_leading. |
| 1722 *is_leading = prefer_leading; | 1721 *is_leading = prefer_leading; |
| 1723 | 1722 |
| 1724 int x, y; | 1723 int x, y; |
| 1725 | 1724 |
| 1726 const MenuConfig& menu_config = item->GetMenuConfig(); | 1725 const MenuConfig& menu_config = MenuConfig::instance(); |
| 1727 | 1726 |
| 1728 if (!item->GetParentMenuItem()) { | 1727 if (!item->GetParentMenuItem()) { |
| 1729 // First item, position relative to initial location. | 1728 // First item, position relative to initial location. |
| 1730 x = state_.initial_bounds.x(); | 1729 x = state_.initial_bounds.x(); |
| 1731 | 1730 |
| 1732 // Offsets for context menu prevent menu items being selected by | 1731 // Offsets for context menu prevent menu items being selected by |
| 1733 // simply opening the menu (bug 142992). | 1732 // simply opening the menu (bug 142992). |
| 1734 if (menu_config.offset_context_menus && state_.context_menu) | 1733 if (menu_config.offset_context_menus && state_.context_menu) |
| 1735 x += 1; | 1734 x += 1; |
| 1736 | 1735 |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2507 } | 2506 } |
| 2508 } | 2507 } |
| 2509 | 2508 |
| 2510 gfx::Screen* MenuController::GetScreen() { | 2509 gfx::Screen* MenuController::GetScreen() { |
| 2511 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; | 2510 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; |
| 2512 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) | 2511 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) |
| 2513 : gfx::Screen::GetNativeScreen(); | 2512 : gfx::Screen::GetNativeScreen(); |
| 2514 } | 2513 } |
| 2515 | 2514 |
| 2516 } // namespace views | 2515 } // namespace views |
| OLD | NEW |