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

Side by Side Diff: chrome/common/native_web_keyboard_event_views.cc

Issue 7766012: Move native_web_keyboard_event_views.cc to chrome, so that we don't have any views code in conten... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Get rid of the views constructor in content as well Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/common/native_web_keyboard_event.h" 5 #include "chrome/common/native_web_keyboard_event_views.h"
6 6
7 #if defined(TOOLKIT_USES_GTK) 7 #if defined(TOOLKIT_USES_GTK)
8 #include <gdk/gdk.h> 8 #include <gdk/gdk.h>
9 #endif 9 #endif
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "views/events/event.h" 12 #include "views/events/event.h"
13 13
14 namespace { 14 namespace {
15 15
16 int ViewsFlagsToWebInputEventModifiers(int flags) { 16 int ViewsFlagsToWebInputEventModifiers(int flags) {
17 return 17 return
18 (flags & ui::EF_SHIFT_DOWN ? WebKit::WebInputEvent::ShiftKey : 0) | 18 (flags & ui::EF_SHIFT_DOWN ? WebKit::WebInputEvent::ShiftKey : 0) |
19 (flags & ui::EF_CONTROL_DOWN ? WebKit::WebInputEvent::ControlKey : 0) | 19 (flags & ui::EF_CONTROL_DOWN ? WebKit::WebInputEvent::ControlKey : 0) |
20 (flags & ui::EF_CAPS_LOCK_DOWN ? WebKit::WebInputEvent::CapsLockOn : 0) | 20 (flags & ui::EF_CAPS_LOCK_DOWN ? WebKit::WebInputEvent::CapsLockOn : 0) |
21 (flags & ui::EF_ALT_DOWN ? WebKit::WebInputEvent::AltKey : 0); 21 (flags & ui::EF_ALT_DOWN ? WebKit::WebInputEvent::AltKey : 0);
22 } 22 }
23 23
24 } // namespace 24 } // namespace
25 25
26 NativeWebKeyboardEvent::NativeWebKeyboardEvent( 26 NativeWebKeyboardEventViews::NativeWebKeyboardEventViews(
27 const views::KeyEvent& event) 27 const views::KeyEvent& event) {
28 : skip_in_browser(false) { 28 skip_in_browser = false;
29 DCHECK(event.type() == ui::ET_KEY_PRESSED || 29 DCHECK(event.type() == ui::ET_KEY_PRESSED ||
30 event.type() == ui::ET_KEY_RELEASED); 30 event.type() == ui::ET_KEY_RELEASED);
31 31
32 if (event.type() == ui::ET_KEY_PRESSED) 32 if (event.type() == ui::ET_KEY_PRESSED)
33 type = WebKit::WebInputEvent::RawKeyDown; 33 type = WebKit::WebInputEvent::RawKeyDown;
34 else 34 else
35 type = WebKit::WebInputEvent::KeyUp; 35 type = WebKit::WebInputEvent::KeyUp;
36 36
37 modifiers = ViewsFlagsToWebInputEventModifiers(event.flags()); 37 modifiers = ViewsFlagsToWebInputEventModifiers(event.flags());
38 timeStampSeconds = event.time_stamp().ToDoubleT(); 38 timeStampSeconds = event.time_stamp().ToDoubleT();
(...skipping 14 matching lines...) Expand all
53 } else { 53 } else {
54 os_event = NULL; 54 os_event = NULL;
55 } 55 }
56 #endif 56 #endif
57 57
58 #if defined(TOOLKIT_USES_GTK) 58 #if defined(TOOLKIT_USES_GTK)
59 match_edit_command = false; 59 match_edit_command = false;
60 #endif 60 #endif
61 } 61 }
62 62
63 NativeWebKeyboardEvent::NativeWebKeyboardEvent(uint16 character, 63 NativeWebKeyboardEventViews::NativeWebKeyboardEventViews(
64 int flags, 64 uint16 character,
65 double time_stamp_seconds, 65 int flags,
66 FromViewsEvent) 66 double time_stamp_seconds,
67 : skip_in_browser(true) { 67 FromViewsEvent) {
68 skip_in_browser = true;
69
68 type = WebKit::WebInputEvent::Char; 70 type = WebKit::WebInputEvent::Char;
69 modifiers = ViewsFlagsToWebInputEventModifiers(flags); 71 modifiers = ViewsFlagsToWebInputEventModifiers(flags);
70 timeStampSeconds = time_stamp_seconds; 72 timeStampSeconds = time_stamp_seconds;
71 windowsKeyCode = character; 73 windowsKeyCode = character;
72 nativeKeyCode = character; 74 nativeKeyCode = character;
73 text[0] = character; 75 text[0] = character;
74 unmodifiedText[0] = character; 76 unmodifiedText[0] = character;
75 isSystemKey = (flags & ui::EF_ALT_DOWN) != 0; 77 isSystemKey = (flags & ui::EF_ALT_DOWN) != 0;
76 78
77 #if defined(OS_WIN) 79 #if defined(OS_WIN)
78 memset(&os_event, 0, sizeof(os_event)); 80 memset(&os_event, 0, sizeof(os_event));
79 #elif defined(TOOLKIT_USES_GTK) 81 #elif defined(TOOLKIT_USES_GTK)
80 os_event = NULL; 82 os_event = NULL;
81 #endif 83 #endif
82 84
83 #if defined(TOOLKIT_USES_GTK) 85 #if defined(TOOLKIT_USES_GTK)
84 match_edit_command = false; 86 match_edit_command = false;
85 #endif 87 #endif
86 } 88 }
89
90 NativeWebKeyboardEventViews::~NativeWebKeyboardEventViews() {
91 }
OLDNEW
« no previous file with comments | « chrome/common/native_web_keyboard_event_views.h ('k') | content/common/native_web_keyboard_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698