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