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

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

Issue 10917102: Context menus should appear above the touch point if invoked by long press. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
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/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 // Offsets for context menu prevent menu items being selected by 1557 // Offsets for context menu prevent menu items being selected by
1558 // simply opening the menu (bug 142992). 1558 // simply opening the menu (bug 142992).
1559 if (MenuConfig::instance().offset_context_menus && state_.context_menu) 1559 if (MenuConfig::instance().offset_context_menus && state_.context_menu)
1560 x += 1; 1560 x += 1;
1561 1561
1562 y = state_.initial_bounds.bottom(); 1562 y = state_.initial_bounds.bottom();
1563 if (state_.anchor == MenuItemView::TOPRIGHT) { 1563 if (state_.anchor == MenuItemView::TOPRIGHT) {
1564 x = x + state_.initial_bounds.width() - pref.width(); 1564 x = x + state_.initial_bounds.width() - pref.width();
1565 if (MenuConfig::instance().offset_context_menus && state_.context_menu) 1565 if (MenuConfig::instance().offset_context_menus && state_.context_menu)
1566 x -= 1; 1566 x -= 1;
1567 } else if (state_.anchor == MenuItemView::BOTTOMCENTER) {
1568 x = x - (pref.width() - state_.initial_bounds.width()) / 2;
1569 y = std::max(0, state_.initial_bounds.y() - pref.height());
1567 } 1570 }
1568 1571
1569 if (!state_.monitor_bounds.IsEmpty() && 1572 if (!state_.monitor_bounds.IsEmpty() &&
1570 y + pref.height() > state_.monitor_bounds.bottom()) { 1573 y + pref.height() > state_.monitor_bounds.bottom()) {
1571 // The menu doesn't fit fully below the button on the screen. The menu 1574 // The menu doesn't fit fully below the button on the screen. The menu
1572 // position with respect to the bounds will be preserved if it has 1575 // position with respect to the bounds will be preserved if it has
1573 // already been drawn. When the requested positioning is below the bounds 1576 // already been drawn. When the requested positioning is below the bounds
1574 // it will shrink the menu to make it fit below. 1577 // it will shrink the menu to make it fit below.
1575 // If the requested positioning is best fit, it will first try to fit the 1578 // If the requested positioning is best fit, it will first try to fit the
1576 // menu below. If that does not fit it will try to place it above. If 1579 // menu below. If that does not fit it will try to place it above. If
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 2122
2120 #if defined(USE_AURA) 2123 #if defined(USE_AURA)
2121 void MenuController::OnWindowActivated(aura::Window* active, 2124 void MenuController::OnWindowActivated(aura::Window* active,
2122 aura::Window* old_active) { 2125 aura::Window* old_active) {
2123 if (!drag_in_progress_) 2126 if (!drag_in_progress_)
2124 Cancel(EXIT_ALL); 2127 Cancel(EXIT_ALL);
2125 } 2128 }
2126 #endif 2129 #endif
2127 2130
2128 } // namespace views 2131 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698