Chromium Code Reviews| 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 { |