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

Side by Side Diff: ui/views/controls/textfield/native_textfield_views.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/textfield/native_textfield_views.h" 5 #include "ui/views/controls/textfield/native_textfield_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 void NativeTextfieldViews::ConvertPointFromScreen(gfx::Point* point) { 420 void NativeTextfieldViews::ConvertPointFromScreen(gfx::Point* point) {
421 View::ConvertPointFromScreen(this, point); 421 View::ConvertPointFromScreen(this, point);
422 } 422 }
423 423
424 bool NativeTextfieldViews::DrawsHandles() { 424 bool NativeTextfieldViews::DrawsHandles() {
425 return false; 425 return false;
426 } 426 }
427 427
428 void NativeTextfieldViews::OpenContextMenu(const gfx::Point anchor) { 428 void NativeTextfieldViews::OpenContextMenu(const gfx::Point anchor) {
429 touch_selection_controller_.reset(); 429 touch_selection_controller_.reset();
430 ShowContextMenu(anchor, false); 430 ShowContextMenu(anchor, ui::CONTEXT_MENU_SOURCE_TOUCH_EDITING);
431 } 431 }
432 432
433 gfx::NativeCursor NativeTextfieldViews::GetCursor(const ui::MouseEvent& event) { 433 gfx::NativeCursor NativeTextfieldViews::GetCursor(const ui::MouseEvent& event) {
434 bool in_selection = GetRenderText()->IsPointInSelection(event.location()); 434 bool in_selection = GetRenderText()->IsPointInSelection(event.location());
435 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED; 435 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED;
436 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection); 436 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection);
437 #if defined(USE_AURA) 437 #if defined(USE_AURA)
438 return text_cursor ? ui::kCursorIBeam : ui::kCursorNull; 438 return text_cursor ? ui::kCursorIBeam : ui::kCursorNull;
439 #elif defined(OS_WIN) 439 #elif defined(OS_WIN)
440 static HCURSOR ibeam = LoadCursor(NULL, IDC_IBEAM); 440 static HCURSOR ibeam = LoadCursor(NULL, IDC_IBEAM);
441 static HCURSOR arrow = LoadCursor(NULL, IDC_ARROW); 441 static HCURSOR arrow = LoadCursor(NULL, IDC_ARROW);
442 return text_cursor ? ibeam : arrow; 442 return text_cursor ? ibeam : arrow;
443 #endif 443 #endif
444 } 444 }
445 445
446 ///////////////////////////////////////////////////////////////// 446 /////////////////////////////////////////////////////////////////
447 // NativeTextfieldViews, ContextMenuController overrides: 447 // NativeTextfieldViews, ContextMenuController overrides:
448 void NativeTextfieldViews::ShowContextMenuForView(View* source, 448 void NativeTextfieldViews::ShowContextMenuForView(
449 const gfx::Point& point) { 449 View* source,
450 const gfx::Point& point,
451 ui::ContextMenuSourceType source_type) {
450 UpdateContextMenu(); 452 UpdateContextMenu();
451 if (context_menu_runner_->RunMenuAt(GetWidget(), NULL, 453 if (context_menu_runner_->RunContextMenuAt(GetWidget(), NULL,
452 gfx::Rect(point, gfx::Size()), views::MenuItemView::TOPLEFT, 454 gfx::Rect(point, gfx::Size()), source_type,
453 MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == 455 MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) ==
454 MenuRunner::MENU_DELETED) 456 MenuRunner::MENU_DELETED)
455 return; 457 return;
456 } 458 }
457 459
458 ///////////////////////////////////////////////////////////////// 460 /////////////////////////////////////////////////////////////////
459 // NativeTextfieldViews, views::DragController overrides: 461 // NativeTextfieldViews, views::DragController overrides:
460 void NativeTextfieldViews::WriteDragDataForView(views::View* sender, 462 void NativeTextfieldViews::WriteDragDataForView(views::View* sender,
461 const gfx::Point& press_pt, 463 const gfx::Point& press_pt,
462 OSExchangeData* data) { 464 OSExchangeData* data) {
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 if (index != -1) { 1508 if (index != -1) {
1507 obscured_reveal_timer_.Start( 1509 obscured_reveal_timer_.Start(
1508 FROM_HERE, 1510 FROM_HERE,
1509 duration, 1511 duration,
1510 base::Bind(&NativeTextfieldViews::RevealObscuredChar, 1512 base::Bind(&NativeTextfieldViews::RevealObscuredChar,
1511 base::Unretained(this), -1, base::TimeDelta())); 1513 base::Unretained(this), -1, base::TimeDelta()));
1512 } 1514 }
1513 } 1515 }
1514 1516
1515 } // namespace views 1517 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698