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

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

Issue 2024893003: Views: Modify Textfield::ExecuteCommand to use Textfield::IsCommandIdEnabled instead of a virtual ca (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor1_IsEditCommandEnabled
Patch Set: Address review comments. Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 case IDS_DELETE_TO_BEGINNING_OF_LINE: 1312 case IDS_DELETE_TO_BEGINNING_OF_LINE:
1313 command_id = IDS_DELETE_BACKWARD; 1313 command_id = IDS_DELETE_BACKWARD;
1314 break; 1314 break;
1315 case IDS_DELETE_WORD_FORWARD: 1315 case IDS_DELETE_WORD_FORWARD:
1316 case IDS_DELETE_TO_END_OF_LINE: 1316 case IDS_DELETE_TO_END_OF_LINE:
1317 command_id = IDS_DELETE_FORWARD; 1317 command_id = IDS_DELETE_FORWARD;
1318 break; 1318 break;
1319 } 1319 }
1320 } 1320 }
1321 1321
1322 if (!IsCommandIdEnabled(command_id)) 1322 // We only execute the commands enabled in Textfield::IsCommandIdEnabled
1323 // below. Hence don't do a virtual IsCommandIdEnabled call.
1324 if (!Textfield::IsCommandIdEnabled(command_id))
1323 return; 1325 return;
1324 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();
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698