Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: ui/views/controls/menu/menu_controller.cc

Issue 1514693006: Revert of Use a single views::MenuConfig instance for each platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase revert on https://codereview.chromium.org/1504743003 Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/controls/menu/menu_config_win.cc ('k') | ui/views/controls/menu/menu_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 1685
1686 void MenuController::BuildMenuItemPath(MenuItemView* item, 1686 void MenuController::BuildMenuItemPath(MenuItemView* item,
1687 std::vector<MenuItemView*>* path) { 1687 std::vector<MenuItemView*>* path) {
1688 if (!item) 1688 if (!item)
1689 return; 1689 return;
1690 BuildMenuItemPath(item->GetParentMenuItem(), path); 1690 BuildMenuItemPath(item->GetParentMenuItem(), path);
1691 path->push_back(item); 1691 path->push_back(item);
1692 } 1692 }
1693 1693
1694 void MenuController::StartShowTimer() { 1694 void MenuController::StartShowTimer() {
1695 MenuItemView* item = pending_state_.item ? pending_state_.item : state_.item;
1695 show_timer_.Start( 1696 show_timer_.Start(
1696 FROM_HERE, TimeDelta::FromMilliseconds(MenuConfig::instance().show_delay), 1697 FROM_HERE, TimeDelta::FromMilliseconds(item->GetMenuConfig().show_delay),
1697 this, &MenuController::CommitPendingSelection); 1698 this, &MenuController::CommitPendingSelection);
1698 } 1699 }
1699 1700
1700 void MenuController::StopShowTimer() { 1701 void MenuController::StopShowTimer() {
1701 show_timer_.Stop(); 1702 show_timer_.Stop();
1702 } 1703 }
1703 1704
1704 void MenuController::StartCancelAllTimer() { 1705 void MenuController::StartCancelAllTimer() {
1705 cancel_all_timer_.Start(FROM_HERE, 1706 cancel_all_timer_.Start(FROM_HERE,
1706 TimeDelta::FromMilliseconds(kCloseOnExitTime), 1707 TimeDelta::FromMilliseconds(kCloseOnExitTime),
(...skipping 22 matching lines...) Expand all
1729 pref.set_width(std::min(pref.width(), 1730 pref.set_width(std::min(pref.width(),
1730 item->GetDelegate()->GetMaxWidthForMenu(item))); 1731 item->GetDelegate()->GetMaxWidthForMenu(item)));
1731 if (!state_.monitor_bounds.IsEmpty()) 1732 if (!state_.monitor_bounds.IsEmpty())
1732 pref.set_width(std::min(pref.width(), state_.monitor_bounds.width())); 1733 pref.set_width(std::min(pref.width(), state_.monitor_bounds.width()));
1733 1734
1734 // Assume we can honor prefer_leading. 1735 // Assume we can honor prefer_leading.
1735 *is_leading = prefer_leading; 1736 *is_leading = prefer_leading;
1736 1737
1737 int x, y; 1738 int x, y;
1738 1739
1739 const MenuConfig& menu_config = MenuConfig::instance(); 1740 const MenuConfig& menu_config = item->GetMenuConfig();
1740 1741
1741 if (!item->GetParentMenuItem()) { 1742 if (!item->GetParentMenuItem()) {
1742 // First item, position relative to initial location. 1743 // First item, position relative to initial location.
1743 x = state_.initial_bounds.x(); 1744 x = state_.initial_bounds.x();
1744 1745
1745 // Offsets for context menu prevent menu items being selected by 1746 // Offsets for context menu prevent menu items being selected by
1746 // simply opening the menu (bug 142992). 1747 // simply opening the menu (bug 142992).
1747 if (menu_config.offset_context_menus && state_.context_menu) 1748 if (menu_config.offset_context_menus && state_.context_menu)
1748 x += 1; 1749 x += 1;
1749 1750
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
2529 } 2530 }
2530 } 2531 }
2531 2532
2532 gfx::Screen* MenuController::GetScreen() { 2533 gfx::Screen* MenuController::GetScreen() {
2533 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; 2534 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL;
2534 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) 2535 return root ? gfx::Screen::GetScreenFor(root->GetNativeView())
2535 : gfx::Screen::GetNativeScreen(); 2536 : gfx::Screen::GetNativeScreen();
2536 } 2537 }
2537 2538
2538 } // namespace views 2539 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_config_win.cc ('k') | ui/views/controls/menu/menu_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698