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 DestroyTouchSelection(); | |
| 1306 | |
| 1307 // Some codepaths may bypass GetCommandForKeyEvent, so any selection-dependent | 1305 // Some codepaths may bypass GetCommandForKeyEvent, so any selection-dependent |
| 1308 // modifications of the command should happen here. | 1306 // modifications of the command should happen here. |
| 1309 if (HasSelection()) { | 1307 if (HasSelection()) { |
| 1310 switch (command_id) { | 1308 switch (command_id) { |
| 1311 case IDS_DELETE_WORD_BACKWARD: | 1309 case IDS_DELETE_WORD_BACKWARD: |
| 1312 case IDS_DELETE_TO_BEGINNING_OF_LINE: | 1310 case IDS_DELETE_TO_BEGINNING_OF_LINE: |
| 1313 command_id = IDS_DELETE_BACKWARD; | 1311 command_id = IDS_DELETE_BACKWARD; |
| 1314 break; | 1312 break; |
| 1315 case IDS_DELETE_WORD_FORWARD: | 1313 case IDS_DELETE_WORD_FORWARD: |
| 1316 case IDS_DELETE_TO_END_OF_LINE: | 1314 case IDS_DELETE_TO_END_OF_LINE: |
| 1317 command_id = IDS_DELETE_FORWARD; | 1315 command_id = IDS_DELETE_FORWARD; |
| 1318 break; | 1316 break; |
| 1319 } | 1317 } |
| 1320 } | 1318 } |
| 1321 | 1319 |
| 1322 if (!IsCommandIdEnabled(command_id)) | 1320 // We only execute the commands enabled in Textfield::IsCommandIdEnabled |
| 1321 // below. Hence don't do a virtual IsCommandIdEnabled call. | |
| 1322 if (!Textfield::IsCommandIdEnabled(command_id)) | |
| 1323 return; | 1323 return; |
| 1324 | 1324 |
| 1325 DestroyTouchSelection(); | |
|
tapted
2016/06/09 05:10:09
The comment above is good, but now the remaining g
| |
| 1326 | |
| 1325 bool text_changed = false; | 1327 bool text_changed = false; |
| 1326 bool cursor_changed = false; | 1328 bool cursor_changed = false; |
| 1327 bool rtl = GetTextDirection() == base::i18n::RIGHT_TO_LEFT; | 1329 bool rtl = GetTextDirection() == base::i18n::RIGHT_TO_LEFT; |
| 1328 gfx::VisualCursorDirection begin = rtl ? gfx::CURSOR_RIGHT : gfx::CURSOR_LEFT; | 1330 gfx::VisualCursorDirection begin = rtl ? gfx::CURSOR_RIGHT : gfx::CURSOR_LEFT; |
| 1329 gfx::VisualCursorDirection end = rtl ? gfx::CURSOR_LEFT : gfx::CURSOR_RIGHT; | 1331 gfx::VisualCursorDirection end = rtl ? gfx::CURSOR_LEFT : gfx::CURSOR_RIGHT; |
| 1330 gfx::SelectionModel selection_model = GetSelectionModel(); | 1332 gfx::SelectionModel selection_model = GetSelectionModel(); |
| 1331 | 1333 |
| 1332 OnBeforeUserAction(); | 1334 OnBeforeUserAction(); |
| 1333 switch (command_id) { | 1335 switch (command_id) { |
| 1334 case IDS_APP_UNDO: | 1336 case IDS_APP_UNDO: |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1929 RequestFocus(); | 1931 RequestFocus(); |
| 1930 model_->MoveCursorTo(mouse); | 1932 model_->MoveCursorTo(mouse); |
| 1931 if (!selection_clipboard_text.empty()) { | 1933 if (!selection_clipboard_text.empty()) { |
| 1932 model_->InsertText(selection_clipboard_text); | 1934 model_->InsertText(selection_clipboard_text); |
| 1933 UpdateAfterChange(true, true); | 1935 UpdateAfterChange(true, true); |
| 1934 } | 1936 } |
| 1935 OnAfterUserAction(); | 1937 OnAfterUserAction(); |
| 1936 } | 1938 } |
| 1937 | 1939 |
| 1938 } // namespace views | 1940 } // namespace views |
| OLD | NEW |