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

Side by Side Diff: ui/views/controls/textfield/textfield_model.cc

Issue 1989143002: MacViews: Correct behavior of move and select commands when selection direction changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_commands
Patch Set: Created 4 years, 7 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
OLDNEW
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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 ExecuteAndRecordDelete(gfx::Range(cursor_position, previous_char), true); 363 ExecuteAndRecordDelete(gfx::Range(cursor_position, previous_char), true);
364 return true; 364 return true;
365 } 365 }
366 return false; 366 return false;
367 } 367 }
368 368
369 size_t TextfieldModel::GetCursorPosition() const { 369 size_t TextfieldModel::GetCursorPosition() const {
370 return render_text_->cursor_position(); 370 return render_text_->cursor_position();
371 } 371 }
372 372
373 void TextfieldModel::MoveCursor(gfx::BreakType break_type, 373 void TextfieldModel::MoveCursor(
374 gfx::VisualCursorDirection direction, 374 gfx::BreakType break_type,
375 bool select) { 375 gfx::VisualCursorDirection direction,
376 bool select,
377 gfx::SelectionReversedBehavior select_behavior) {
376 if (HasCompositionText()) 378 if (HasCompositionText())
377 ConfirmCompositionText(); 379 ConfirmCompositionText();
378 render_text_->MoveCursor(break_type, direction, select); 380 render_text_->MoveCursor(break_type, direction, select, select_behavior);
379 } 381 }
380 382
381 bool TextfieldModel::MoveCursorTo(const gfx::SelectionModel& cursor) { 383 bool TextfieldModel::MoveCursorTo(const gfx::SelectionModel& cursor) {
382 if (HasCompositionText()) { 384 if (HasCompositionText()) {
383 ConfirmCompositionText(); 385 ConfirmCompositionText();
384 // ConfirmCompositionText() updates cursor position. Need to reflect it in 386 // ConfirmCompositionText() updates cursor position. Need to reflect it in
385 // the SelectionModel parameter of MoveCursorTo(). 387 // the SelectionModel parameter of MoveCursorTo().
386 gfx::Range range(render_text_->selection().start(), cursor.caret_pos()); 388 gfx::Range range(render_text_->selection().start(), cursor.caret_pos());
387 if (!range.is_empty()) 389 if (!range.is_empty())
388 return render_text_->SelectRange(range); 390 return render_text_->SelectRange(range);
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 ClearComposition(); 776 ClearComposition();
775 if (delete_from != delete_to) 777 if (delete_from != delete_to)
776 render_text_->SetText(old_text.erase(delete_from, delete_to - delete_from)); 778 render_text_->SetText(old_text.erase(delete_from, delete_to - delete_from));
777 if (!new_text.empty()) 779 if (!new_text.empty())
778 render_text_->SetText(old_text.insert(new_text_insert_at, new_text)); 780 render_text_->SetText(old_text.insert(new_text_insert_at, new_text));
779 render_text_->SetCursorPosition(new_cursor_pos); 781 render_text_->SetCursorPosition(new_cursor_pos);
780 // TODO(oshima): Select text that was just undone, like Mac (but not GTK). 782 // TODO(oshima): Select text that was just undone, like Mac (but not GTK).
781 } 783 }
782 784
783 } // namespace views 785 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698