| 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 ExecuteAndRecordDelete(range_to_delete, true); | 392 ExecuteAndRecordDelete(range_to_delete, true); |
| 393 return true; | 393 return true; |
| 394 } | 394 } |
| 395 return false; | 395 return false; |
| 396 } | 396 } |
| 397 | 397 |
| 398 size_t TextfieldModel::GetCursorPosition() const { | 398 size_t TextfieldModel::GetCursorPosition() const { |
| 399 return render_text_->cursor_position(); | 399 return render_text_->cursor_position(); |
| 400 } | 400 } |
| 401 | 401 |
| 402 void TextfieldModel::MoveCursor(gfx::BreakType break_type, | 402 void TextfieldModel::MoveCursor( |
| 403 gfx::VisualCursorDirection direction, | 403 gfx::BreakType break_type, |
| 404 bool select) { | 404 gfx::VisualCursorDirection direction, |
| 405 bool select, |
| 406 gfx::SelectionReversedBehavior select_behavior) { |
| 405 if (HasCompositionText()) | 407 if (HasCompositionText()) |
| 406 ConfirmCompositionText(); | 408 ConfirmCompositionText(); |
| 407 render_text_->MoveCursor(break_type, direction, select); | 409 render_text_->MoveCursor(break_type, direction, select, select_behavior); |
| 408 } | 410 } |
| 409 | 411 |
| 410 bool TextfieldModel::MoveCursorTo(const gfx::SelectionModel& cursor) { | 412 bool TextfieldModel::MoveCursorTo(const gfx::SelectionModel& cursor) { |
| 411 if (HasCompositionText()) { | 413 if (HasCompositionText()) { |
| 412 ConfirmCompositionText(); | 414 ConfirmCompositionText(); |
| 413 // ConfirmCompositionText() updates cursor position. Need to reflect it in | 415 // ConfirmCompositionText() updates cursor position. Need to reflect it in |
| 414 // the SelectionModel parameter of MoveCursorTo(). | 416 // the SelectionModel parameter of MoveCursorTo(). |
| 415 gfx::Range range(render_text_->selection().start(), cursor.caret_pos()); | 417 gfx::Range range(render_text_->selection().start(), cursor.caret_pos()); |
| 416 if (!range.is_empty()) | 418 if (!range.is_empty()) |
| 417 return render_text_->SelectRange(range); | 419 return render_text_->SelectRange(range); |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 render_text_->SetCursorPosition(new_cursor_pos); | 849 render_text_->SetCursorPosition(new_cursor_pos); |
| 848 // TODO(oshima): Select text that was just undone, like Mac (but not GTK). | 850 // TODO(oshima): Select text that was just undone, like Mac (but not GTK). |
| 849 } | 851 } |
| 850 | 852 |
| 851 // static | 853 // static |
| 852 void TextfieldModel::ClearKillBuffer() { | 854 void TextfieldModel::ClearKillBuffer() { |
| 853 SetKillBuffer(base::string16()); | 855 SetKillBuffer(base::string16()); |
| 854 } | 856 } |
| 855 | 857 |
| 856 } // namespace views | 858 } // namespace views |
| OLD | NEW |