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

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

Issue 10916180: Context menus on view elements should be positioned above the finger when (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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/menu/menu_runner.cc
diff --git a/ui/views/controls/menu/menu_runner.cc b/ui/views/controls/menu/menu_runner.cc
index 185e52cdd3ec3766fdf6f410277282780c74a166..de6416638bf7ba17e062a6f6f86799dd9df039a3 100644
--- a/ui/views/controls/menu/menu_runner.cc
+++ b/ui/views/controls/menu/menu_runner.cc
@@ -10,11 +10,18 @@
#include "ui/views/controls/menu/menu_controller.h"
#include "ui/views/controls/menu/menu_controller_delegate.h"
#include "ui/views/controls/menu/menu_delegate.h"
+#include "ui/views/widget/widget.h"
#if defined(OS_WIN)
#include "base/win/win_util.h"
#endif
+namespace {
+// 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;
+} // namespace
+
namespace views {
namespace internal {
@@ -284,7 +291,14 @@ MenuRunner::RunResult MenuRunner::RunMenuAt(Widget* parent,
display_change_listener_.reset(
internal::DisplayChangeListener::Create(parent, this));
}
- return holder_->RunMenuAt(parent, button, bounds, anchor, types);
+ if ((types & MenuRunner::CONTEXT_MENU) && parent->GetCurrentEvent())
+ anchor = parent->GetCurrentEvent()->IsGestureEvent() ?
+ MenuItemView::BOTTOMCENTER : MenuItemView::TOPLEFT;
+ gfx::Rect menu_bounds = bounds;
+ if (anchor == MenuItemView::BOTTOMCENTER)
sky 2012/09/14 17:19:57 Can this be moved to UpdateInitialLocation?
varunjain 2012/09/14 18:46:06 Done.
+ menu_bounds.Offset(0, kCenteredContextMenuYOffset);
+
+ return holder_->RunMenuAt(parent, button, menu_bounds, anchor, types);
}
bool MenuRunner::IsRunning() const {
« no previous file with comments | « chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc ('k') | ui/views/controls/scrollbar/base_scroll_bar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698