| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_model.h" | 5 #include "ui/views/controls/textfield/textfield_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 return render_text_->SelectRange(range); | 424 return render_text_->SelectRange(range); |
| 425 return render_text_->MoveCursorTo( | 425 return render_text_->MoveCursorTo( |
| 426 gfx::SelectionModel(cursor.caret_pos(), cursor.caret_affinity())); | 426 gfx::SelectionModel(cursor.caret_pos(), cursor.caret_affinity())); |
| 427 } | 427 } |
| 428 return render_text_->MoveCursorTo(cursor); | 428 return render_text_->MoveCursorTo(cursor); |
| 429 } | 429 } |
| 430 | 430 |
| 431 bool TextfieldModel::MoveCursorTo(const gfx::Point& point, bool select) { | 431 bool TextfieldModel::MoveCursorTo(const gfx::Point& point, bool select) { |
| 432 if (HasCompositionText()) | 432 if (HasCompositionText()) |
| 433 ConfirmCompositionText(); | 433 ConfirmCompositionText(); |
| 434 gfx::SelectionModel cursor = render_text_->FindCursorPosition(point); | 434 return render_text_->MoveCursorTo(point, select); |
| 435 if (select) | |
| 436 cursor.set_selection_start(render_text_->selection().start()); | |
| 437 return render_text_->MoveCursorTo(cursor); | |
| 438 } | 435 } |
| 439 | 436 |
| 440 base::string16 TextfieldModel::GetSelectedText() const { | 437 base::string16 TextfieldModel::GetSelectedText() const { |
| 441 return GetTextFromRange(render_text_->selection()); | 438 return GetTextFromRange(render_text_->selection()); |
| 442 } | 439 } |
| 443 | 440 |
| 444 void TextfieldModel::SelectRange(const gfx::Range& range) { | 441 void TextfieldModel::SelectRange(const gfx::Range& range) { |
| 445 if (HasCompositionText()) | 442 if (HasCompositionText()) |
| 446 ConfirmCompositionText(); | 443 ConfirmCompositionText(); |
| 447 render_text_->SelectRange(range); | 444 render_text_->SelectRange(range); |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 render_text_->SetCursorPosition(new_cursor_pos); | 848 render_text_->SetCursorPosition(new_cursor_pos); |
| 852 // TODO(oshima): Select text that was just undone, like Mac (but not GTK). | 849 // TODO(oshima): Select text that was just undone, like Mac (but not GTK). |
| 853 } | 850 } |
| 854 | 851 |
| 855 // static | 852 // static |
| 856 void TextfieldModel::ClearKillBuffer() { | 853 void TextfieldModel::ClearKillBuffer() { |
| 857 SetKillBuffer(base::string16()); | 854 SetKillBuffer(base::string16()); |
| 858 } | 855 } |
| 859 | 856 |
| 860 } // namespace views | 857 } // namespace views |
| OLD | NEW |