diff options
author | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-29 22:22:05 +0000 |
---|---|---|
committer | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-29 22:22:05 +0000 |
commit | 8103d87c0bc7689d3c85293d0f646f0f0b56acfd (patch) | |
tree | 5c00655f3804781279dee89ec19731bef62a8a6d /ui/views/controls | |
parent | beecad254659b4f8ae525f44efe08cb33fff0551 (diff) | |
download | chromium_src-8103d87c0bc7689d3c85293d0f646f0f0b56acfd.zip chromium_src-8103d87c0bc7689d3c85293d0f646f0f0b56acfd.tar.gz chromium_src-8103d87c0bc7689d3c85293d0f646f0f0b56acfd.tar.bz2 |
Change to context menu position determining logic: If the menu is invoked with
anchor BOTTOMCENTER, and there is not enough space to position the menu above
the anchor, we position it completely below the anchor instead of overlapping
with the anchor.
BUG=152773
Review URL: https://chromiumcodereview.appspot.com/11419208
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170257 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/controls')
-rw-r--r-- | ui/views/controls/menu/menu_controller.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc index f3e9e47..1cbb70f 100644 --- a/ui/views/controls/menu/menu_controller.cc +++ b/ui/views/controls/menu/menu_controller.cc @@ -1086,8 +1086,6 @@ void MenuController::UpdateInitialLocation( // nicely and menus close prematurely. pending_state_.initial_bounds.Inset(0, 1); } - if (position == MenuItemView::BOTTOMCENTER) - pending_state_.initial_bounds.Offset(0, kCenteredContextMenuYOffset); // Reverse anchor position for RTL languages. if (base::i18n::IsRTL()) { @@ -1566,7 +1564,14 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, x -= 1; } else if (state_.anchor == MenuItemView::BOTTOMCENTER) { x = x - (pref.width() - state_.initial_bounds.width()) / 2; - y = std::max(0, state_.initial_bounds.y() - pref.height()); + if (pref.height() > + state_.initial_bounds.y() + kCenteredContextMenuYOffset) { + // Menu does not fit above the anchor. We move it to below. + y = state_.initial_bounds.y() - kCenteredContextMenuYOffset; + } else { + y = std::max(0, state_.initial_bounds.y() - pref.height()) + + kCenteredContextMenuYOffset; + } } if (!state_.monitor_bounds.IsEmpty() && |