Chromium Code Reviews| 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 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1295 case IDS_APP_SELECT_ALL: | 1295 case IDS_APP_SELECT_ALL: |
| 1296 *accelerator = ui::Accelerator(ui::VKEY_A, ui::EF_CONTROL_DOWN); | 1296 *accelerator = ui::Accelerator(ui::VKEY_A, ui::EF_CONTROL_DOWN); |
| 1297 return true; | 1297 return true; |
| 1298 | 1298 |
| 1299 default: | 1299 default: |
| 1300 return false; | 1300 return false; |
| 1301 } | 1301 } |
| 1302 } | 1302 } |
| 1303 | 1303 |
| 1304 void Textfield::ExecuteCommand(int command_id, int event_flags) { | 1304 void Textfield::ExecuteCommand(int command_id, int event_flags) { |
| 1305 if (!Textfield::IsCommandIdEnabled(command_id)) | |
| 1306 return; | |
| 1307 | |
| 1305 DestroyTouchSelection(); | 1308 DestroyTouchSelection(); |
| 1306 | 1309 |
| 1307 // Some codepaths may bypass GetCommandForKeyEvent, so any selection-dependent | 1310 // Some codepaths may bypass GetCommandForKeyEvent, so any selection-dependent |
| 1308 // modifications of the command should happen here. | 1311 // modifications of the command should happen here. |
| 1309 if (HasSelection()) { | 1312 if (HasSelection()) { |
| 1310 switch (command_id) { | 1313 switch (command_id) { |
| 1311 case IDS_DELETE_WORD_BACKWARD: | 1314 case IDS_DELETE_WORD_BACKWARD: |
| 1312 case IDS_DELETE_TO_BEGINNING_OF_LINE: | 1315 case IDS_DELETE_TO_BEGINNING_OF_LINE: |
| 1313 command_id = IDS_DELETE_BACKWARD; | 1316 command_id = IDS_DELETE_BACKWARD; |
|
tapted
2016/06/06 07:26:16
The command_id can change down here, so this doesn
karandeepb
2016/06/08 03:05:49
Yeah I added this code in https://codereview.chrom
tapted
2016/06/08 04:02:39
Perhaps the CL needs a clearer rationale then, or
| |
| 1314 break; | 1317 break; |
| 1315 case IDS_DELETE_WORD_FORWARD: | 1318 case IDS_DELETE_WORD_FORWARD: |
| 1316 case IDS_DELETE_TO_END_OF_LINE: | 1319 case IDS_DELETE_TO_END_OF_LINE: |
| 1317 command_id = IDS_DELETE_FORWARD; | 1320 command_id = IDS_DELETE_FORWARD; |
| 1318 break; | 1321 break; |
| 1319 } | 1322 } |
| 1320 } | 1323 } |
| 1321 | 1324 |
| 1322 if (!IsCommandIdEnabled(command_id)) | |
| 1323 return; | |
| 1324 | |
| 1325 bool text_changed = false; | 1325 bool text_changed = false; |
| 1326 bool cursor_changed = false; | 1326 bool cursor_changed = false; |
| 1327 bool rtl = GetTextDirection() == base::i18n::RIGHT_TO_LEFT; | 1327 bool rtl = GetTextDirection() == base::i18n::RIGHT_TO_LEFT; |
| 1328 gfx::VisualCursorDirection begin = rtl ? gfx::CURSOR_RIGHT : gfx::CURSOR_LEFT; | 1328 gfx::VisualCursorDirection begin = rtl ? gfx::CURSOR_RIGHT : gfx::CURSOR_LEFT; |
| 1329 gfx::VisualCursorDirection end = rtl ? gfx::CURSOR_LEFT : gfx::CURSOR_RIGHT; | 1329 gfx::VisualCursorDirection end = rtl ? gfx::CURSOR_LEFT : gfx::CURSOR_RIGHT; |
| 1330 gfx::SelectionModel selection_model = GetSelectionModel(); | 1330 gfx::SelectionModel selection_model = GetSelectionModel(); |
| 1331 | 1331 |
| 1332 OnBeforeUserAction(); | 1332 OnBeforeUserAction(); |
| 1333 switch (command_id) { | 1333 switch (command_id) { |
| 1334 case IDS_APP_UNDO: | 1334 case IDS_APP_UNDO: |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1929 RequestFocus(); | 1929 RequestFocus(); |
| 1930 model_->MoveCursorTo(mouse); | 1930 model_->MoveCursorTo(mouse); |
| 1931 if (!selection_clipboard_text.empty()) { | 1931 if (!selection_clipboard_text.empty()) { |
| 1932 model_->InsertText(selection_clipboard_text); | 1932 model_->InsertText(selection_clipboard_text); |
| 1933 UpdateAfterChange(true, true); | 1933 UpdateAfterChange(true, true); |
| 1934 } | 1934 } |
| 1935 OnAfterUserAction(); | 1935 OnAfterUserAction(); |
| 1936 } | 1936 } |
| 1937 | 1937 |
| 1938 } // namespace views | 1938 } // namespace views |
| OLD | NEW |