Commit 32795d8e authored by Tessa Nijssen's avatar Tessa Nijssen Committed by Commit Bot

[Views] Set Correct Menu Orientation

Toolkit-views menus positioned with POSITION_BEST_FIT are be
positioned to the side of the anchor when the menu height is greater
than ~50% of the screen. Currently in this situation, the "actual"
position of the menu is incorrectly recorded as POSITION_BELOW_BOUNDS.
If a menu delegate invokes MenuChildrenChanged() and recalculates the
menu bounds, this can cause the menu to reposition itself under
the anchor rather than remaining to the side.

To fix, record the "actual" position as POSITION_BEST_FIT in this
situation.

Bug: 840919
Change-Id: I4102e014c058b2f89d5bc38b7b4371c010367119
Reviewed-on: https://chromium-review.googlesource.com/1087516
Commit-Queue: Tessa Nijssen <tnijssen@google.com>
Reviewed-by: default avatarSarah Chan <spqchan@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565352}
parent 884aeb2e
...@@ -2046,7 +2046,7 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, ...@@ -2046,7 +2046,7 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
} else if (item->actual_menu_position() == } else if (item->actual_menu_position() ==
MenuItemView::POSITION_BEST_FIT) { MenuItemView::POSITION_BEST_FIT) {
MenuItemView::MenuPosition orientation = MenuItemView::MenuPosition orientation =
MenuItemView::POSITION_BELOW_BOUNDS; MenuItemView::POSITION_BEST_FIT;
if (state_.monitor_bounds.height() < pref.height()) { if (state_.monitor_bounds.height() < pref.height()) {
// Handle very tall menus. // Handle very tall menus.
pref.set_height(state_.monitor_bounds.height()); pref.set_height(state_.monitor_bounds.height());
...@@ -2061,7 +2061,7 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, ...@@ -2061,7 +2061,7 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
// best fit and to avoid showing scroll elements. // best fit and to avoid showing scroll elements.
y = state_.monitor_bounds.bottom() - pref.height(); y = state_.monitor_bounds.bottom() - pref.height();
} }
if (orientation == MenuItemView::POSITION_BELOW_BOUNDS) { if (orientation == MenuItemView::POSITION_BEST_FIT) {
// The menu should never overlap the owning button. So move it. // The menu should never overlap the owning button. So move it.
// We use the anchor view style to determine the preferred position // We use the anchor view style to determine the preferred position
// relative to the owning button. // relative to the owning button.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment