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

Unified Diff: ui/views/controls/menu/menu_controller.cc

Issue 11026076: Added MenuConfig setter to MenuItemView, updated rest of the code to use set MenuConfig if it avail… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/menu/menu_config_win.cc ('k') | ui/views/controls/menu/menu_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7fbccfb223b8e7d5e2df0610efa01d083c8ee63a..8d33dede81f2a0aa49686c4ad499f9774aeaca0b 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -1556,19 +1556,21 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
int x, y;
+ const MenuConfig& menu_config = item->GetMenuConfig();
+
if (!item->GetParentMenuItem()) {
// First item, position relative to initial location.
x = state_.initial_bounds.x();
// Offsets for context menu prevent menu items being selected by
// simply opening the menu (bug 142992).
- if (MenuConfig::instance().offset_context_menus && state_.context_menu)
+ if (menu_config.offset_context_menus && state_.context_menu)
x += 1;
y = state_.initial_bounds.bottom();
if (state_.anchor == MenuItemView::TOPRIGHT) {
x = x + state_.initial_bounds.width() - pref.width();
- if (MenuConfig::instance().offset_context_menus && state_.context_menu)
+ if (menu_config.offset_context_menus && state_.context_menu)
x -= 1;
} else if (state_.anchor == MenuItemView::BOTTOMCENTER) {
x = x - (pref.width() - state_.initial_bounds.width()) / 2;
@@ -1645,7 +1647,7 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
item->set_actual_menu_position(MenuItemView::POSITION_BELOW_BOUNDS);
}
if (state_.monitor_bounds.width() != 0 &&
- MenuConfig::instance().offset_context_menus && state_.context_menu) {
+ menu_config.offset_context_menus && state_.context_menu) {
if (x + pref.width() > state_.monitor_bounds.right())
x = state_.initial_bounds.x() - pref.width() - 1;
if (x < state_.monitor_bounds.x())
@@ -1663,8 +1665,7 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
bool layout_is_rtl = base::i18n::IsRTL();
bool create_on_the_right = (prefer_leading && !layout_is_rtl) ||
(!prefer_leading && layout_is_rtl);
- int submenu_horizontal_inset =
- MenuConfig::instance().submenu_horizontal_inset;
+ int submenu_horizontal_inset = menu_config.submenu_horizontal_inset;
if (create_on_the_right) {
x = item_loc.x() + item->width() - submenu_horizontal_inset;
@@ -1686,7 +1687,7 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
x = item_loc.x() + item->width() - submenu_horizontal_inset;
}
}
- y = item_loc.y() - MenuConfig::instance().submenu_vertical_margin_size;
+ y = item_loc.y() - menu_config.submenu_vertical_margin_size;
if (state_.monitor_bounds.width() != 0) {
pref.set_height(std::min(pref.height(), state_.monitor_bounds.height()));
if (y + pref.height() > state_.monitor_bounds.bottom())
« no previous file with comments | « ui/views/controls/menu/menu_config_win.cc ('k') | ui/views/controls/menu/menu_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698