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

Side by Side Diff: content/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, 3 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
« no previous file with comments | « content/common/native_web_keyboard_event.h ('k') | content/content_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/common/native_web_keyboard_event.h"
6
7 #if defined(TOOLKIT_USES_GTK)
8 #include <gdk/gdk.h>
9 #endif
10
11 #include "base/logging.h"
12 #include "views/events/event.h"
13
14 namespace {
15
16 int ViewsFlagsToWebInputEventModifiers(int flags) {
17 return
18 (flags & ui::EF_SHIFT_DOWN ? WebKit::WebInputEvent::ShiftKey : 0) |
19 (flags & ui::EF_CONTROL_DOWN ? WebKit::WebInputEvent::ControlKey : 0) |
20 (flags & ui::EF_CAPS_LOCK_DOWN ? WebKit::WebInputEvent::CapsLockOn : 0) |
21 (flags & ui::EF_ALT_DOWN ? WebKit::WebInputEvent::AltKey : 0);
22 }
23
24 } // namespace
25
26 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
27 const views::KeyEvent& event)
28 : skip_in_browser(false) {
29 DCHECK(event.type() == ui::ET_KEY_PRESSED ||
30 event.type() == ui::ET_KEY_RELEASED);
31
32 if (event.type() == ui::ET_KEY_PRESSED)
33 type = WebKit::WebInputEvent::RawKeyDown;
34 else
35 type = WebKit::WebInputEvent::KeyUp;
36
37 modifiers = ViewsFlagsToWebInputEventModifiers(event.flags());
38 timeStampSeconds = event.time_stamp().ToDoubleT();
39 windowsKeyCode = event.key_code();
40 nativeKeyCode = windowsKeyCode;
41 text[0] = event.GetCharacter();
42 unmodifiedText[0] = event.GetUnmodifiedCharacter();
43 setKeyIdentifierFromWindowsKeyCode();
44
45 #if defined(OS_WIN)
46 // |os_event| is a MSG struct, so we can copy it directly.
47 os_event = event.native_event();
48 #elif defined(TOOLKIT_USES_GTK)
49 if (event.native_event()) {
50 os_event =
51 reinterpret_cast<GdkEventKey*>(gdk_event_copy(event.native_event()));
52 nativeKeyCode = os_event->keyval;
53 } else {
54 os_event = NULL;
55 }
56 #endif
57
58 #if defined(TOOLKIT_USES_GTK)
59 match_edit_command = false;
60 #endif
61 }
62
63 NativeWebKeyboardEvent::NativeWebKeyboardEvent(uint16 character,
64 int flags,
65 double time_stamp_seconds,
66 FromViewsEvent)
67 : skip_in_browser(true) {
68 type = WebKit::WebInputEvent::Char;
69 modifiers = ViewsFlagsToWebInputEventModifiers(flags);
70 timeStampSeconds = time_stamp_seconds;
71 windowsKeyCode = character;
72 nativeKeyCode = character;
73 text[0] = character;
74 unmodifiedText[0] = character;
75 isSystemKey = (flags & ui::EF_ALT_DOWN) != 0;
76
77 #if defined(OS_WIN)
78 memset(&os_event, 0, sizeof(os_event));
79 #elif defined(TOOLKIT_USES_GTK)
80 os_event = NULL;
81 #endif
82
83 #if defined(TOOLKIT_USES_GTK)
84 match_edit_command = false;
85 #endif
86 }
OLDNEW
« no previous file with comments | « content/common/native_web_keyboard_event.h ('k') | content/content_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698