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 5364b83da55b3c6fe23fe56fc1c580795fee83be..fd61014567cb7c079c86c6b9ddfbc16d47d73540 100644 |
--- a/ui/views/controls/menu/menu_controller.cc |
+++ b/ui/views/controls/menu/menu_controller.cc |
@@ -1184,7 +1184,8 @@ bool MenuController::ShowSiblingMenu(SubmenuView* source, |
anchor); |
alt_menu->PrepareForRun( |
has_mnemonics, |
- source->GetMenuItem()->GetRootMenuItem()->show_mnemonics_); |
+ source->GetMenuItem()->GetRootMenuItem()->show_mnemonics_, |
+ false); |
alt_menu->controller_ = this; |
SetSelection(alt_menu, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); |
return true; |
@@ -1550,9 +1551,16 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, |
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(item->is_root_context_menu()) |
+ x += 1; |
y = state_.initial_bounds.bottom(); |
- if (state_.anchor == MenuItemView::TOPRIGHT) |
+ if (state_.anchor == MenuItemView::TOPRIGHT) { |
x = x + state_.initial_bounds.width() - pref.width(); |
+ if(item->is_root_context_menu()) |
+ x -= 1; |
+ } |
if (!state_.monitor_bounds.IsEmpty() && |
y + pref.height() > state_.monitor_bounds.bottom()) { |
@@ -1669,10 +1677,20 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, |
} |
if (state_.monitor_bounds.width() != 0) { |
- if (x + pref.width() > state_.monitor_bounds.right()) |
- x = state_.monitor_bounds.right() - pref.width(); |
- if (x < state_.monitor_bounds.x()) |
- x = state_.monitor_bounds.x(); |
+ if (x + pref.width() > state_.monitor_bounds.right()) { |
+ if(item->is_root_context_menu()) |
+ x -= pref.width() + 1; |
+ else |
+ x = state_.monitor_bounds.right() - pref.width(); |
+ } |
+ if (x < state_.monitor_bounds.x()) { |
+ int temp_loc = state_.initial_bounds.x() + 1; |
+ if(item->is_root_context_menu() && temp_loc >= state_.monitor_bounds.x() |
+ && temp_loc + pref.width() < state_.monitor_bounds.right()) |
+ x = temp_loc; |
+ else |
+ x = state_.monitor_bounds.x(); |
+ } |
} |
return gfx::Rect(x, y, pref.width(), pref.height()); |
} |