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

Unified Diff: ui/views/controls/textfield/textfield.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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index dc0a9f2535810941f1720d9e131d0061120ed26d..eca219194e9b9f0f13faaffb55ca67697e316455 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -1265,8 +1265,12 @@ bool Textfield::IsCommandIdEnabled(int command_id) const {
case IDS_MOVE_WORD_RIGHT_AND_MODIFY_SELECTION:
case IDS_MOVE_TO_BEGINNING_OF_LINE:
case IDS_MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION:
+ case IDS_MOVE_TO_BEGINNING_OF_LINE_AND_EXTEND_SELECTION:
+ case IDS_MOVE_TOWARDS_BEGINNING_OF_LINE_AND_MODIFY_SELECTION:
case IDS_MOVE_TO_END_OF_LINE:
case IDS_MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION:
+ case IDS_MOVE_TO_END_OF_LINE_AND_EXTEND_SELECTION:
+ case IDS_MOVE_TOWARDS_END_OF_LINE_AND_MODIFY_SELECTION:
return true;
default:
return false;
@@ -1329,6 +1333,12 @@ void Textfield::ExecuteCommand(int command_id, int event_flags) {
gfx::VisualCursorDirection end = rtl ? gfx::CURSOR_LEFT : gfx::CURSOR_RIGHT;
gfx::SelectionModel selection_model = GetSelectionModel();
+#if defined(OS_MACOSX)
+ gfx::SelectionReversedBehavior word_selection = gfx::SELECTION_CARET;
+#else
+ gfx::SelectionReversedBehavior word_selection = gfx::SELECTION_START_NEW;
+#endif
+
OnBeforeUserAction();
switch (command_id) {
case IDS_APP_UNDO:
@@ -1390,25 +1400,40 @@ void Textfield::ExecuteCommand(int command_id, int event_flags) {
model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, false);
break;
case IDS_MOVE_WORD_LEFT_AND_MODIFY_SELECTION:
- model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true);
+ model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true,
+ word_selection);
break;
case IDS_MOVE_WORD_RIGHT:
model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_RIGHT, false);
break;
case IDS_MOVE_WORD_RIGHT_AND_MODIFY_SELECTION:
- model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_RIGHT, true);
+ model_->MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_RIGHT, true,
+ word_selection);
break;
case IDS_MOVE_TO_BEGINNING_OF_LINE:
model_->MoveCursor(gfx::LINE_BREAK, begin, false);
break;
case IDS_MOVE_TO_BEGINNING_OF_LINE_AND_MODIFY_SELECTION:
- model_->MoveCursor(gfx::LINE_BREAK, begin, true);
+ model_->MoveCursor(gfx::LINE_BREAK, begin, true,
+ gfx::SELECTION_START_NEW);
+ break;
+ case IDS_MOVE_TO_BEGINNING_OF_LINE_AND_EXTEND_SELECTION:
+ model_->MoveCursor(gfx::LINE_BREAK, begin, true, gfx::SELECTION_EXTEND);
+ break;
+ case IDS_MOVE_TOWARDS_BEGINNING_OF_LINE_AND_MODIFY_SELECTION:
+ model_->MoveCursor(gfx::LINE_BREAK, begin, true, gfx::SELECTION_CARET);
break;
case IDS_MOVE_TO_END_OF_LINE:
model_->MoveCursor(gfx::LINE_BREAK, end, false);
break;
case IDS_MOVE_TO_END_OF_LINE_AND_MODIFY_SELECTION:
- model_->MoveCursor(gfx::LINE_BREAK, end, true);
+ model_->MoveCursor(gfx::LINE_BREAK, end, true, gfx::SELECTION_START_NEW);
+ break;
+ case IDS_MOVE_TO_END_OF_LINE_AND_EXTEND_SELECTION:
+ model_->MoveCursor(gfx::LINE_BREAK, end, true, gfx::SELECTION_EXTEND);
+ break;
+ case IDS_MOVE_TOWARDS_END_OF_LINE_AND_MODIFY_SELECTION:
+ model_->MoveCursor(gfx::LINE_BREAK, end, true, gfx::SELECTION_CARET);
break;
default:
NOTREACHED();

Powered by Google App Engine
This is Rietveld 408576698