OLD | NEW |
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/textfield/textfield.h" | 5 #include "ui/views/controls/textfield/textfield.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 OnBeforeUserAction(); | 642 OnBeforeUserAction(); |
643 drag_selection_timer_.Stop(); | 643 drag_selection_timer_.Stop(); |
644 // Cancel suspected drag initiations, the user was clicking in the selection. | 644 // Cancel suspected drag initiations, the user was clicking in the selection. |
645 if (initiating_drag_) | 645 if (initiating_drag_) |
646 MoveCursorTo(event.location(), false); | 646 MoveCursorTo(event.location(), false); |
647 initiating_drag_ = false; | 647 initiating_drag_ = false; |
648 UpdateSelectionClipboard(); | 648 UpdateSelectionClipboard(); |
649 OnAfterUserAction(); | 649 OnAfterUserAction(); |
650 } | 650 } |
651 | 651 |
| 652 WordLookupClient* Textfield::GetWordLookupClient() { |
| 653 return this; |
| 654 } |
| 655 |
652 bool Textfield::OnKeyPressed(const ui::KeyEvent& event) { | 656 bool Textfield::OnKeyPressed(const ui::KeyEvent& event) { |
653 ui::TextEditCommand edit_command = scheduled_text_edit_command_; | 657 ui::TextEditCommand edit_command = scheduled_text_edit_command_; |
654 scheduled_text_edit_command_ = ui::TextEditCommand::INVALID_COMMAND; | 658 scheduled_text_edit_command_ = ui::TextEditCommand::INVALID_COMMAND; |
655 | 659 |
656 // Since HandleKeyEvent() might destroy |this|, get a weak pointer and verify | 660 // Since HandleKeyEvent() might destroy |this|, get a weak pointer and verify |
657 // it isn't null before proceeding. | 661 // it isn't null before proceeding. |
658 base::WeakPtr<Textfield> textfield(weak_ptr_factory_.GetWeakPtr()); | 662 base::WeakPtr<Textfield> textfield(weak_ptr_factory_.GetWeakPtr()); |
659 | 663 |
660 bool handled = controller_ && controller_->HandleKeyEvent(this, event); | 664 bool handled = controller_ && controller_->HandleKeyEvent(this, event); |
661 | 665 |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 return drag_operations; | 1094 return drag_operations; |
1091 } | 1095 } |
1092 | 1096 |
1093 bool Textfield::CanStartDragForView(View* sender, | 1097 bool Textfield::CanStartDragForView(View* sender, |
1094 const gfx::Point& press_pt, | 1098 const gfx::Point& press_pt, |
1095 const gfx::Point& p) { | 1099 const gfx::Point& p) { |
1096 return initiating_drag_ && GetRenderText()->IsPointInSelection(press_pt); | 1100 return initiating_drag_ && GetRenderText()->IsPointInSelection(press_pt); |
1097 } | 1101 } |
1098 | 1102 |
1099 //////////////////////////////////////////////////////////////////////////////// | 1103 //////////////////////////////////////////////////////////////////////////////// |
| 1104 // Textfield, WordLookupClient overrides: |
| 1105 |
| 1106 bool Textfield::GetDecoratedWordAtPoint(const gfx::Point& point, |
| 1107 gfx::DecoratedText* decorated_word, |
| 1108 gfx::Point* baseline_point) { |
| 1109 return GetRenderText()->GetDecoratedWordAtPoint(point, decorated_word, |
| 1110 baseline_point); |
| 1111 } |
| 1112 |
| 1113 //////////////////////////////////////////////////////////////////////////////// |
1100 // Textfield, ui::TouchEditable overrides: | 1114 // Textfield, ui::TouchEditable overrides: |
1101 | 1115 |
1102 void Textfield::SelectRect(const gfx::Point& start, const gfx::Point& end) { | 1116 void Textfield::SelectRect(const gfx::Point& start, const gfx::Point& end) { |
1103 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) | 1117 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) |
1104 return; | 1118 return; |
1105 | 1119 |
1106 gfx::SelectionModel start_caret = GetRenderText()->FindCursorPosition(start); | 1120 gfx::SelectionModel start_caret = GetRenderText()->FindCursorPosition(start); |
1107 gfx::SelectionModel end_caret = GetRenderText()->FindCursorPosition(end); | 1121 gfx::SelectionModel end_caret = GetRenderText()->FindCursorPosition(end); |
1108 gfx::SelectionModel selection( | 1122 gfx::SelectionModel selection( |
1109 gfx::Range(start_caret.caret_pos(), end_caret.caret_pos()), | 1123 gfx::Range(start_caret.caret_pos(), end_caret.caret_pos()), |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2059 } | 2073 } |
2060 | 2074 |
2061 void Textfield::OnCursorBlinkTimerFired() { | 2075 void Textfield::OnCursorBlinkTimerFired() { |
2062 DCHECK(ShouldBlinkCursor()); | 2076 DCHECK(ShouldBlinkCursor()); |
2063 gfx::RenderText* render_text = GetRenderText(); | 2077 gfx::RenderText* render_text = GetRenderText(); |
2064 render_text->set_cursor_visible(!render_text->cursor_visible()); | 2078 render_text->set_cursor_visible(!render_text->cursor_visible()); |
2065 RepaintCursor(); | 2079 RepaintCursor(); |
2066 } | 2080 } |
2067 | 2081 |
2068 } // namespace views | 2082 } // namespace views |
OLD | NEW |