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

Unified Diff: ui/views/controls/menu/menu_controller.cc

Issue 2861873002: Align the base of the shelf's context menu to the top edge of the shelf. (Closed)
Patch Set: Fix UT. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
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 f9aac0a605a8bc1c51c65f28c3bce22e55c81e27..4c1ed3a29a6eceeeb123dd09348b5c7717cdd453 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -73,10 +73,6 @@ const int kScrollTimerMS = 30;
// Amount of time from when the drop exits the menu and the menu is hidden.
const int kCloseOnExitTime = 1200;
-// If a context menu is invoked by touch, we shift the menu by this offset so
-// that the finger does not obscure the menu.
-const int kCenteredContextMenuYOffset = -15;
minch1 2017/05/04 16:44:15 Sorry, not quite sure about here. This is not need
msw 2017/05/05 17:34:19 This seems wrong, it'll change the positioning of
-
// The spacing offset for the bubble tip.
const int kBubbleTipSizeLeftRight = 12;
const int kBubbleTipSizeTopBottom = 11;
@@ -1951,14 +1947,12 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
x -= 1;
} else if (state_.anchor == MENU_ANCHOR_BOTTOMCENTER) {
x = x - (pref.width() - state_.initial_bounds.width()) / 2;
- 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 menu does not fit above the anchor. We move it to below.
msw 2017/05/05 17:34:19 nit: "Place the menu below the anchor if it does n
+ y = pref.height() > state_.initial_bounds.y()
+ ? state_.initial_bounds.y()
+ : (state_.initial_bounds.y() - pref.height());
+ } else if (state_.anchor == MENU_ANCHOR_SIDECENTER) {
+ y = y - (pref.height() - state_.initial_bounds.height()) / 2;
msw 2017/05/05 17:34:19 nit: y -= (or += with subtraction reversed might b
}
if (!state_.monitor_bounds.IsEmpty() &&

Powered by Google App Engine
This is Rietveld 408576698