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

Side by Side Diff: ui/views/controls/menu/menu_runner.cc

Issue 16979002: Add ContextMenuSourceType to views::ContextMenuController::ShowContextMenuForView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/menu/menu_runner.h" 5 #include "ui/views/controls/menu/menu_runner.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "ui/base/models/menu_model.h" 10 #include "ui/base/models/menu_model.h"
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 const gfx::Rect& bounds, 334 const gfx::Rect& bounds,
335 MenuItemView::AnchorPosition anchor, 335 MenuItemView::AnchorPosition anchor,
336 int32 types) { 336 int32 types) {
337 // The parent of the nested menu will have created a DisplayChangeListener, so 337 // The parent of the nested menu will have created a DisplayChangeListener, so
338 // we avoid creating a DisplayChangeListener if nested. Drop menus are 338 // we avoid creating a DisplayChangeListener if nested. Drop menus are
339 // transient, so we don't cancel in that case. 339 // transient, so we don't cancel in that case.
340 if ((types & (IS_NESTED | FOR_DROP)) == 0 && parent) { 340 if ((types & (IS_NESTED | FOR_DROP)) == 0 && parent) {
341 display_change_listener_.reset( 341 display_change_listener_.reset(
342 internal::DisplayChangeListener::Create(parent, this)); 342 internal::DisplayChangeListener::Create(parent, this));
343 } 343 }
344 if ((types & MenuRunner::CONTEXT_MENU) &&
345 parent &&
346 !MenuItemView::IsBubble(anchor)) {
347 const ui::Event* current_event = parent->GetCurrentEvent();
348 anchor = current_event && current_event->IsMouseEvent() ?
349 MenuItemView::TOPLEFT : MenuItemView::BOTTOMCENTER;
350 }
351 344
352 return holder_->RunMenuAt(parent, button, bounds, anchor, types); 345 return holder_->RunMenuAt(parent, button, bounds, anchor, types);
353 } 346 }
354 347
348 MenuRunner::RunResult MenuRunner::RunContextMenuAt(
349 Widget* parent,
350 MenuButton* button,
351 const gfx::Rect& bounds,
352 ui::ContextMenuSourceType source_type,
353 int32 types) {
354 MenuItemView::AnchorPosition anchor = MenuItemView::TOPLEFT;
355 switch (source_type) {
356 case ui::CONTEXT_MENU_SOURCE_KEYBOARD:
357 break;
358 case ui::CONTEXT_MENU_SOURCE_MOUSE:
359 break;
360 case ui::CONTEXT_MENU_SOURCE_TOUCH:
361 anchor = MenuItemView::BOTTOMCENTER;
362 break;
363 case ui::CONTEXT_MENU_SOURCE_TOUCH_EDITING:
364 anchor = MenuItemView::BOTTOMCENTER;
365 break;
366 default:
367 break;
368 }
369 types |= views::MenuRunner::CONTEXT_MENU;
370 return RunMenuAt(parent, button, bounds, anchor, types);
371 }
372
373
355 bool MenuRunner::IsRunning() const { 374 bool MenuRunner::IsRunning() const {
356 return holder_->running(); 375 return holder_->running();
357 } 376 }
358 377
359 void MenuRunner::Cancel() { 378 void MenuRunner::Cancel() {
360 holder_->Cancel(); 379 holder_->Cancel();
361 } 380 }
362 381
363 base::TimeDelta MenuRunner::closing_event_time() const { 382 base::TimeDelta MenuRunner::closing_event_time() const {
364 return holder_->closing_event_time(); 383 return holder_->closing_event_time();
365 } 384 }
366 385
367 } // namespace views 386 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698