| 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/time.h" | 9 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 // Reverse anchor position for RTL languages. | 1065 // Reverse anchor position for RTL languages. |
| 1066 if (base::i18n::IsRTL()) { | 1066 if (base::i18n::IsRTL()) { |
| 1067 pending_state_.anchor = position == MenuItemView::TOPRIGHT ? | 1067 pending_state_.anchor = position == MenuItemView::TOPRIGHT ? |
| 1068 MenuItemView::TOPLEFT : MenuItemView::TOPRIGHT; | 1068 MenuItemView::TOPLEFT : MenuItemView::TOPRIGHT; |
| 1069 } else { | 1069 } else { |
| 1070 pending_state_.anchor = position; | 1070 pending_state_.anchor = position; |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 // Calculate the bounds of the monitor we'll show menus on. Do this once to | 1073 // Calculate the bounds of the monitor we'll show menus on. Do this once to |
| 1074 // avoid repeated system queries for the info. | 1074 // avoid repeated system queries for the info. |
| 1075 pending_state_.monitor_bounds = gfx::Screen::GetMonitorWorkAreaNearestPoint( | 1075 pending_state_.monitor_bounds = gfx::Screen::GetMonitorNearestPoint( |
| 1076 bounds.origin()); | 1076 bounds.origin()).work_area(); |
| 1077 #if defined(USE_ASH) | 1077 #if defined(USE_ASH) |
| 1078 if (!pending_state_.monitor_bounds.Contains(bounds)) { | 1078 if (!pending_state_.monitor_bounds.Contains(bounds)) { |
| 1079 // Use the monitor area if the work area doesn't contain the bounds. This | 1079 // Use the monitor area if the work area doesn't contain the bounds. This |
| 1080 // handles showing a menu from the launcher. | 1080 // handles showing a menu from the launcher. |
| 1081 gfx::Rect monitor_area = | 1081 gfx::Rect monitor_area = |
| 1082 gfx::Screen::GetMonitorAreaNearestPoint(bounds.origin()); | 1082 gfx::Screen::GetMonitorNearestPoint(bounds.origin()).bounds(); |
| 1083 if (monitor_area.Contains(bounds)) | 1083 if (monitor_area.Contains(bounds)) |
| 1084 pending_state_.monitor_bounds = monitor_area; | 1084 pending_state_.monitor_bounds = monitor_area; |
| 1085 } | 1085 } |
| 1086 #endif | 1086 #endif |
| 1087 } | 1087 } |
| 1088 | 1088 |
| 1089 void MenuController::Accept(MenuItemView* item, int mouse_event_flags) { | 1089 void MenuController::Accept(MenuItemView* item, int mouse_event_flags) { |
| 1090 DCHECK(IsBlockingRun()); | 1090 DCHECK(IsBlockingRun()); |
| 1091 result_ = item; | 1091 result_ = item; |
| 1092 if (item && !menu_stack_.empty() && | 1092 if (item && !menu_stack_.empty() && |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2006 (!pending_state_.item->HasSubmenu() || | 2006 (!pending_state_.item->HasSubmenu() || |
| 2007 !pending_state_.item->GetSubmenu()->IsShowing())) { | 2007 !pending_state_.item->GetSubmenu()->IsShowing())) { |
| 2008 // On exit if the user hasn't selected an item with a submenu, move the | 2008 // On exit if the user hasn't selected an item with a submenu, move the |
| 2009 // selection back to the parent menu item. | 2009 // selection back to the parent menu item. |
| 2010 SetSelection(pending_state_.item->GetParentMenuItem(), | 2010 SetSelection(pending_state_.item->GetParentMenuItem(), |
| 2011 SELECTION_OPEN_SUBMENU); | 2011 SELECTION_OPEN_SUBMENU); |
| 2012 } | 2012 } |
| 2013 } | 2013 } |
| 2014 | 2014 |
| 2015 } // namespace views | 2015 } // namespace views |
| OLD | NEW |