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

Side by Side Diff: content/browser/renderer_host/native_web_keyboard_event_aura.cc

Issue 8576005: IME (input method editor) support for Aura, part 3 of 3: Use ui::InputMethod in ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git mv desktop_host_unittest.cc desktop_host_ime_unittest.cc Created 9 years 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/public/browser/native_web_keyboard_event.h" 5 #include "content/public/browser/native_web_keyboard_event.h"
6 6
7 #include "base/logging.h"
7 #include "content/browser/renderer_host/web_input_event_aura.h" 8 #include "content/browser/renderer_host/web_input_event_aura.h"
9 #include "ui/base/events.h"
8 10
9 using WebKit::WebKeyboardEvent; 11 using WebKit::WebKeyboardEvent;
10 12
13 namespace {
14
15 int EventFlagsToWebInputEventModifiers(int flags) {
16 return
17 (flags & ui::EF_SHIFT_DOWN ? WebKit::WebInputEvent::ShiftKey : 0) |
18 (flags & ui::EF_CONTROL_DOWN ? WebKit::WebInputEvent::ControlKey : 0) |
19 (flags & ui::EF_CAPS_LOCK_DOWN ? WebKit::WebInputEvent::CapsLockOn : 0) |
20 (flags & ui::EF_ALT_DOWN ? WebKit::WebInputEvent::AltKey : 0);
21 }
22
23 } // namespace
24
11 NativeWebKeyboardEvent::NativeWebKeyboardEvent() 25 NativeWebKeyboardEvent::NativeWebKeyboardEvent()
12 : os_event(NULL), 26 : os_event(NULL),
13 skip_in_browser(false) { 27 skip_in_browser(false) {
14 } 28 }
15 29
16 NativeWebKeyboardEvent::NativeWebKeyboardEvent(gfx::NativeEvent native_event) 30 NativeWebKeyboardEvent::NativeWebKeyboardEvent(gfx::NativeEvent native_event)
17 : WebKeyboardEvent(content::MakeWebKeyboardEvent( 31 : WebKeyboardEvent(content::MakeWebKeyboardEvent(
18 reinterpret_cast<aura::KeyEvent*>(native_event))), 32 reinterpret_cast<aura::KeyEvent*>(native_event))),
19 os_event(native_event), 33 os_event(native_event),
20 skip_in_browser(false) { 34 skip_in_browser(false) {
21 } 35 }
22 36
23 NativeWebKeyboardEvent::NativeWebKeyboardEvent( 37 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
24 const NativeWebKeyboardEvent& other) 38 const NativeWebKeyboardEvent& other)
25 : WebKeyboardEvent(other), 39 : WebKeyboardEvent(other),
26 os_event(other.os_event), 40 os_event(other.os_event),
27 skip_in_browser(other.skip_in_browser) { 41 skip_in_browser(other.skip_in_browser) {
28 } 42 }
29 43
44 // From chrome/common/native_web_keyboard_event_views.cc.
sky 2011/12/01 17:01:09 Is this comment right (meaning I think you hat the
Yusuke Sato 2011/12/02 02:18:31 I actually copied (and then slightly modified) the
45 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
46 ui::EventType key_event_type,
47 bool is_char,
48 wchar_t character,
49 int state,
50 double time_stamp_seconds)
51 : os_event(NULL),
52 skip_in_browser(true /* already handled by the input method */) {
53 switch (key_event_type) {
54 case ui::ET_KEY_PRESSED:
55 type = is_char ? WebKit::WebInputEvent::Char :
56 WebKit::WebInputEvent::RawKeyDown;
57 break;
58 case ui::ET_KEY_RELEASED:
59 type = WebKit::WebInputEvent::KeyUp;
60 break;
61 default:
62 NOTREACHED();
63 }
64
65 modifiers = EventFlagsToWebInputEventModifiers(state);
66 timeStampSeconds = time_stamp_seconds;
67 windowsKeyCode = character;
68 nativeKeyCode = character;
69 text[0] = character;
70 unmodifiedText[0] = character;
71 isSystemKey = (state & ui::EF_ALT_DOWN) != 0;
72 }
73
30 NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=( 74 NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=(
31 const NativeWebKeyboardEvent& other) { 75 const NativeWebKeyboardEvent& other) {
32 WebKeyboardEvent::operator=(other); 76 WebKeyboardEvent::operator=(other);
33 77
34 os_event = other.os_event; 78 os_event = other.os_event;
35 skip_in_browser = other.skip_in_browser; 79 skip_in_browser = other.skip_in_browser;
36 80
37 return *this; 81 return *this;
38 } 82 }
39 83
40 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() { 84 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() {
41 } 85 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_aura.h » ('j') | ui/aura/desktop_host.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698