diff options
author | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-18 16:54:28 +0000 |
---|---|---|
committer | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-18 16:54:28 +0000 |
commit | 940fb1c9ca08476b1d52fdb6e92b42e699f2d1e4 (patch) | |
tree | 49f2f8fbb112b16feadd07bef76f86bd5423f16b /ui/views/controls/button/button_dropdown.cc | |
parent | cf43b6c19e56557cae9f0c36d3896b4576830475 (diff) | |
download | chromium_src-940fb1c9ca08476b1d52fdb6e92b42e699f2d1e4.zip chromium_src-940fb1c9ca08476b1d52fdb6e92b42e699f2d1e4.tar.gz chromium_src-940fb1c9ca08476b1d52fdb6e92b42e699f2d1e4.tar.bz2 |
Add ContextMenuSourceType to views::ContextMenuController::ShowContextMenuForView.
This will help bring context menu positioning logic to one place and unify the
positioning logic for all views.
BUG=239110
Review URL: https://chromiumcodereview.appspot.com/16979002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207019 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/controls/button/button_dropdown.cc')
-rw-r--r-- | ui/views/controls/button/button_dropdown.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ui/views/controls/button/button_dropdown.cc b/ui/views/controls/button/button_dropdown.cc index a243cee..fa57e3b 100644 --- a/ui/views/controls/button/button_dropdown.cc +++ b/ui/views/controls/button/button_dropdown.cc @@ -70,7 +70,8 @@ bool ButtonDropDown::OnMousePressed(const ui::MouseEvent& event) { base::MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&ButtonDropDown::ShowDropDownMenu, - show_menu_factory_.GetWeakPtr()), + show_menu_factory_.GetWeakPtr(), + ui::GetMenuSourceTypeForEvent(event)), base::TimeDelta::FromMilliseconds(kMenuTimerDelay)); } return ImageButton::OnMousePressed(event); @@ -85,7 +86,7 @@ bool ButtonDropDown::OnMouseDragged(const ui::MouseEvent& event) { // it immediately. if (event.y() > y_position_on_lbuttondown_ + GetHorizontalDragThreshold()) { show_menu_factory_.InvalidateWeakPtrs(); - ShowDropDownMenu(); + ShowDropDownMenu(ui::GetMenuSourceTypeForEvent(event)); } } @@ -132,12 +133,13 @@ void ButtonDropDown::GetAccessibleState(ui::AccessibleViewState* state) { } void ButtonDropDown::ShowContextMenuForView(View* source, - const gfx::Point& point) { + const gfx::Point& point, + ui::MenuSourceType source_type) { if (!enabled()) return; show_menu_factory_.InvalidateWeakPtrs(); - ShowDropDownMenu(); + ShowDropDownMenu(source_type); } bool ButtonDropDown::ShouldEnterPushedState(const ui::Event& event) { @@ -153,7 +155,7 @@ bool ButtonDropDown::ShouldShowMenu() { return true; } -void ButtonDropDown::ShowDropDownMenu() { +void ButtonDropDown::ShowDropDownMenu(ui::MenuSourceType source_type) { if (!ShouldShowMenu()) return; @@ -191,6 +193,7 @@ void ButtonDropDown::ShowDropDownMenu() { menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(menu_position, gfx::Size(0, 0)), MenuItemView::TOPLEFT, + source_type, MenuRunner::HAS_MNEMONICS); if (result == MenuRunner::MENU_DELETED) return; @@ -202,6 +205,7 @@ void ButtonDropDown::ShowDropDownMenu() { menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(menu_position, gfx::Size(0, 0)), MenuItemView::TOPLEFT, + source_type, MenuRunner::HAS_MNEMONICS); if (result == MenuRunner::MENU_DELETED) return; |