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

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

Issue 10412009: Enable disabled omnibox tests on aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 | Annotate | Revision Log
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/native_textfield_views.h" 5 #include "ui/views/controls/textfield/native_textfield_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 // TODO(oshima): Refactor and consolidate with ExecuteCommand. 848 // TODO(oshima): Refactor and consolidate with ExecuteCommand.
849 if (key_event.type() == ui::ET_KEY_PRESSED) { 849 if (key_event.type() == ui::ET_KEY_PRESSED) {
850 ui::KeyboardCode key_code = key_event.key_code(); 850 ui::KeyboardCode key_code = key_event.key_code();
851 // TODO(oshima): shift-tab does not work. Figure out why and fix. 851 // TODO(oshima): shift-tab does not work. Figure out why and fix.
852 if (key_code == ui::VKEY_TAB) 852 if (key_code == ui::VKEY_TAB)
853 return false; 853 return false;
854 854
855 OnBeforeUserAction(); 855 OnBeforeUserAction();
856 bool editable = !textfield_->read_only(); 856 bool editable = !textfield_->read_only();
857 bool readable = !textfield_->IsObscured(); 857 bool readable = !textfield_->IsObscured();
858 bool selection = key_event.IsShiftDown(); 858 bool shift = key_event.IsShiftDown();
859 bool control = key_event.IsControlDown(); 859 bool control = key_event.IsControlDown();
860 bool text_changed = false; 860 bool text_changed = false;
861 bool cursor_changed = false; 861 bool cursor_changed = false;
862 switch (key_code) { 862 switch (key_code) {
863 case ui::VKEY_Z: 863 case ui::VKEY_Z:
864 if (control && editable) 864 if (control && !shift && editable)
865 cursor_changed = text_changed = model_->Undo(); 865 cursor_changed = text_changed = model_->Undo();
866 else if (control && shift && editable)
867 cursor_changed = text_changed = model_->Redo();
866 break; 868 break;
867 case ui::VKEY_Y: 869 case ui::VKEY_Y:
868 if (control && editable) 870 if (control && editable)
869 cursor_changed = text_changed = model_->Redo(); 871 cursor_changed = text_changed = model_->Redo();
870 break; 872 break;
871 case ui::VKEY_A: 873 case ui::VKEY_A:
872 if (control) { 874 if (control) {
873 model_->SelectAll(); 875 model_->SelectAll();
874 cursor_changed = true; 876 cursor_changed = true;
875 } 877 }
876 break; 878 break;
877 case ui::VKEY_X: 879 case ui::VKEY_X:
878 if (control && editable && readable) 880 if (control && editable && readable)
879 cursor_changed = text_changed = Cut(); 881 cursor_changed = text_changed = Cut();
880 break; 882 break;
881 case ui::VKEY_C: 883 case ui::VKEY_C:
882 if (control && readable) 884 if (control && readable)
883 Copy(); 885 Copy();
884 break; 886 break;
885 case ui::VKEY_V: 887 case ui::VKEY_V:
886 if (control && editable) 888 if (control && editable)
887 cursor_changed = text_changed = Paste(); 889 cursor_changed = text_changed = Paste();
888 break; 890 break;
889 case ui::VKEY_RIGHT: 891 case ui::VKEY_RIGHT:
890 case ui::VKEY_LEFT: 892 case ui::VKEY_LEFT:
891 model_->MoveCursor( 893 model_->MoveCursor(
892 control ? gfx::WORD_BREAK : gfx::CHARACTER_BREAK, 894 control ? gfx::WORD_BREAK : gfx::CHARACTER_BREAK,
893 (key_code == ui::VKEY_RIGHT) ? gfx::CURSOR_RIGHT : gfx::CURSOR_LEFT, 895 (key_code == ui::VKEY_RIGHT) ? gfx::CURSOR_RIGHT : gfx::CURSOR_LEFT,
894 selection); 896 shift);
895 cursor_changed = true; 897 cursor_changed = true;
896 break; 898 break;
897 case ui::VKEY_END: 899 case ui::VKEY_END:
898 case ui::VKEY_HOME: 900 case ui::VKEY_HOME:
899 if ((key_code == ui::VKEY_HOME) == 901 if ((key_code == ui::VKEY_HOME) ==
900 (GetRenderText()->GetTextDirection() == base::i18n::RIGHT_TO_LEFT)) 902 (GetRenderText()->GetTextDirection() == base::i18n::RIGHT_TO_LEFT))
901 model_->MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, selection); 903 model_->MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, shift);
902 else 904 else
903 model_->MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_LEFT, selection); 905 model_->MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_LEFT, shift);
904 cursor_changed = true; 906 cursor_changed = true;
905 break; 907 break;
906 case ui::VKEY_BACK: 908 case ui::VKEY_BACK:
907 case ui::VKEY_DELETE: 909 case ui::VKEY_DELETE:
908 if (!editable) 910 if (!editable)
909 break; 911 break;
910 if (!model_->HasSelection()) { 912 if (!model_->HasSelection()) {
911 gfx::VisualCursorDirection direction = (key_code == ui::VKEY_DELETE) ? 913 gfx::VisualCursorDirection direction = (key_code == ui::VKEY_DELETE) ?
912 gfx::CURSOR_RIGHT : gfx::CURSOR_LEFT; 914 gfx::CURSOR_RIGHT : gfx::CURSOR_LEFT;
913 if (selection && control) { 915 if (shift && control) {
914 // If both shift and control are pressed, then erase up to the 916 // If both shift and control are pressed, then erase up to the
915 // beginning/end of the buffer in ChromeOS. In windows, do nothing. 917 // beginning/end of the buffer in ChromeOS. In windows, do nothing.
916 #if defined(OS_WIN) 918 #if defined(OS_WIN)
917 break; 919 break;
918 #else 920 #else
919 model_->MoveCursor(gfx::LINE_BREAK, direction, true); 921 model_->MoveCursor(gfx::LINE_BREAK, direction, true);
920 #endif 922 #endif
921 } else if (control) { 923 } else if (control) {
922 // If only control is pressed, then erase the previous/next word. 924 // If only control is pressed, then erase the previous/next word.
923 model_->MoveCursor(gfx::WORD_BREAK, direction, true); 925 model_->MoveCursor(gfx::WORD_BREAK, direction, true);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 1152
1151 #if defined(USE_AURA) 1153 #if defined(USE_AURA)
1152 // static 1154 // static
1153 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( 1155 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper(
1154 Textfield* field) { 1156 Textfield* field) {
1155 return new NativeTextfieldViews(field); 1157 return new NativeTextfieldViews(field);
1156 } 1158 }
1157 #endif 1159 #endif
1158 1160
1159 } // namespace views 1161 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698