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

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

Issue 10825254: Remove views::KeyEvent, replacing uses of it with ui::KeyEvent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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"
11 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "base/i18n/case_conversion.h" 12 #include "base/i18n/case_conversion.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "grit/app_locale_settings.h" 16 #include "grit/app_locale_settings.h"
17 #include "grit/ui_strings.h" 17 #include "grit/ui_strings.h"
18 #include "third_party/skia/include/core/SkColor.h" 18 #include "third_party/skia/include/core/SkColor.h"
19 #include "ui/base/clipboard/clipboard.h" 19 #include "ui/base/clipboard/clipboard.h"
20 #include "ui/base/dragdrop/drag_drop_types.h" 20 #include "ui/base/dragdrop/drag_drop_types.h"
21 #include "ui/base/event.h"
21 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/base/range/range.h" 23 #include "ui/base/range/range.h"
23 #include "ui/compositor/layer.h" 24 #include "ui/compositor/layer.h"
24 #include "ui/gfx/canvas.h" 25 #include "ui/gfx/canvas.h"
25 #include "ui/gfx/insets.h" 26 #include "ui/gfx/insets.h"
26 #include "ui/gfx/render_text.h" 27 #include "ui/gfx/render_text.h"
27 #include "ui/gfx/text_constants.h" 28 #include "ui/gfx/text_constants.h"
28 #include "ui/views/background.h" 29 #include "ui/views/background.h"
29 #include "ui/views/border.h" 30 #include "ui/views/border.h"
30 #include "ui/views/controls/focusable_border.h" 31 #include "ui/views/controls/focusable_border.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if (MoveCursorTo(event.location(), true)) 174 if (MoveCursorTo(event.location(), true))
174 SchedulePaint(); 175 SchedulePaint();
175 OnAfterUserAction(); 176 OnAfterUserAction();
176 return ui::GESTURE_STATUS_CONSUMED; 177 return ui::GESTURE_STATUS_CONSUMED;
177 default: 178 default:
178 break; 179 break;
179 } 180 }
180 return TouchSelectionClientView::OnGestureEvent(event); 181 return TouchSelectionClientView::OnGestureEvent(event);
181 } 182 }
182 183
183 bool NativeTextfieldViews::OnKeyPressed(const KeyEvent& event) { 184 bool NativeTextfieldViews::OnKeyPressed(const ui::KeyEvent& event) {
184 // OnKeyPressed/OnKeyReleased/OnFocus/OnBlur will never be invoked on 185 // OnKeyPressed/OnKeyReleased/OnFocus/OnBlur will never be invoked on
185 // NativeTextfieldViews as it will never gain focus. 186 // NativeTextfieldViews as it will never gain focus.
186 NOTREACHED(); 187 NOTREACHED();
187 return false; 188 return false;
188 } 189 }
189 190
190 bool NativeTextfieldViews::OnKeyReleased(const KeyEvent& event) { 191 bool NativeTextfieldViews::OnKeyReleased(const ui::KeyEvent& event) {
191 NOTREACHED(); 192 NOTREACHED();
192 return false; 193 return false;
193 } 194 }
194 195
195 bool NativeTextfieldViews::GetDropFormats( 196 bool NativeTextfieldViews::GetDropFormats(
196 int* formats, 197 int* formats,
197 std::set<OSExchangeData::CustomFormat>* custom_formats) { 198 std::set<OSExchangeData::CustomFormat>* custom_formats) {
198 if (!textfield_->enabled() || textfield_->read_only()) 199 if (!textfield_->enabled() || textfield_->read_only())
199 return false; 200 return false;
200 // TODO(msw): Can we support URL, FILENAME, etc.? 201 // TODO(msw): Can we support URL, FILENAME, etc.?
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 const gfx::SelectionModel& sel) { 516 const gfx::SelectionModel& sel) {
516 model_->SelectSelectionModel(sel); 517 model_->SelectSelectionModel(sel);
517 OnCaretBoundsChanged(); 518 OnCaretBoundsChanged();
518 SchedulePaint(); 519 SchedulePaint();
519 } 520 }
520 521
521 size_t NativeTextfieldViews::GetCursorPosition() const { 522 size_t NativeTextfieldViews::GetCursorPosition() const {
522 return model_->GetCursorPosition(); 523 return model_->GetCursorPosition();
523 } 524 }
524 525
525 bool NativeTextfieldViews::HandleKeyPressed(const KeyEvent& e) { 526 bool NativeTextfieldViews::HandleKeyPressed(const ui::KeyEvent& e) {
526 TextfieldController* controller = textfield_->GetController(); 527 TextfieldController* controller = textfield_->GetController();
527 bool handled = false; 528 bool handled = false;
528 if (controller) 529 if (controller)
529 handled = controller->HandleKeyEvent(textfield_, e); 530 handled = controller->HandleKeyEvent(textfield_, e);
530 return handled || HandleKeyEvent(e); 531 return handled || HandleKeyEvent(e);
531 } 532 }
532 533
533 bool NativeTextfieldViews::HandleKeyReleased(const KeyEvent& e) { 534 bool NativeTextfieldViews::HandleKeyReleased(const ui::KeyEvent& e) {
534 return false; // crbug.com/127520 535 return false; // crbug.com/127520
535 } 536 }
536 537
537 void NativeTextfieldViews::HandleFocus() { 538 void NativeTextfieldViews::HandleFocus() {
538 GetRenderText()->set_focused(true); 539 GetRenderText()->set_focused(true);
539 is_cursor_visible_ = true; 540 is_cursor_visible_ = true;
540 SchedulePaint(); 541 SchedulePaint();
541 OnCaretBoundsChanged(); 542 OnCaretBoundsChanged();
542 // Start blinking cursor. 543 // Start blinking cursor.
543 MessageLoop::current()->PostDelayedTask( 544 MessageLoop::current()->PostDelayedTask(
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 !textfield_->placeholder_text().empty()) { 910 !textfield_->placeholder_text().empty()) {
910 canvas->DrawStringInt( 911 canvas->DrawStringInt(
911 textfield_->placeholder_text(), 912 textfield_->placeholder_text(),
912 GetRenderText()->GetFont(), 913 GetRenderText()->GetFont(),
913 textfield_->placeholder_text_color(), 914 textfield_->placeholder_text_color(),
914 GetRenderText()->display_rect()); 915 GetRenderText()->display_rect());
915 } 916 }
916 canvas->Restore(); 917 canvas->Restore();
917 } 918 }
918 919
919 bool NativeTextfieldViews::HandleKeyEvent(const KeyEvent& key_event) { 920 bool NativeTextfieldViews::HandleKeyEvent(const ui::KeyEvent& key_event) {
920 // TODO(oshima): Refactor and consolidate with ExecuteCommand. 921 // TODO(oshima): Refactor and consolidate with ExecuteCommand.
921 if (key_event.type() == ui::ET_KEY_PRESSED) { 922 if (key_event.type() == ui::ET_KEY_PRESSED) {
922 ui::KeyboardCode key_code = key_event.key_code(); 923 ui::KeyboardCode key_code = key_event.key_code();
923 // TODO(oshima): shift-tab does not work. Figure out why and fix. 924 // TODO(oshima): shift-tab does not work. Figure out why and fix.
924 if (key_code == ui::VKEY_TAB) 925 if (key_code == ui::VKEY_TAB)
925 return false; 926 return false;
926 927
927 OnBeforeUserAction(); 928 OnBeforeUserAction();
928 bool editable = !textfield_->read_only(); 929 bool editable = !textfield_->read_only();
929 bool readable = !textfield_->IsObscured(); 930 bool readable = !textfield_->IsObscured();
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 // Filter out all control characters, including tab and new line characters, 1222 // Filter out all control characters, including tab and new line characters,
1222 // and all characters with Alt modifier. But we need to allow characters with 1223 // and all characters with Alt modifier. But we need to allow characters with
1223 // AltGr modifier. 1224 // AltGr modifier.
1224 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different 1225 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different
1225 // flag that we don't care about. 1226 // flag that we don't care about.
1226 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && 1227 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) &&
1227 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; 1228 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN;
1228 } 1229 }
1229 1230
1230 } // namespace views 1231 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/native_textfield_views.h ('k') | ui/views/controls/textfield/native_textfield_views_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698