OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 | 8 |
9 MSVC_PUSH_WARNING_LEVEL(0); | 9 MSVC_PUSH_WARNING_LEVEL(0); |
10 #include "EventTarget.h" | 10 #include "EventTarget.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 MakePlatformKeyboardEvent evt(keyboard_event); | 39 MakePlatformKeyboardEvent evt(keyboard_event); |
40 evt.SetKeyType(key_type); | 40 evt.SetKeyType(key_type); |
41 RefPtr<KeyboardEvent> keyboardEvent = KeyboardEvent::create(evt, NULL); | 41 RefPtr<KeyboardEvent> keyboardEvent = KeyboardEvent::create(evt, NULL); |
42 return editor_impl.interpretKeyEvent(keyboardEvent.get()); | 42 return editor_impl.interpretKeyEvent(keyboardEvent.get()); |
43 } | 43 } |
44 | 44 |
45 // Set up a WebKeyboardEvent KEY_DOWN event with key code and modifiers. | 45 // Set up a WebKeyboardEvent KEY_DOWN event with key code and modifiers. |
46 void SetupKeyDownEvent(WebKeyboardEvent* keyboard_event, | 46 void SetupKeyDownEvent(WebKeyboardEvent* keyboard_event, |
47 char key_code, | 47 char key_code, |
48 int modifiers) { | 48 int modifiers) { |
49 keyboard_event->key_code = key_code; | 49 keyboard_event->windows_key_code = key_code; |
50 keyboard_event->modifiers = modifiers; | 50 keyboard_event->modifiers = modifiers; |
51 keyboard_event->type = WebInputEvent::KEY_DOWN; | 51 keyboard_event->type = WebInputEvent::KEY_DOWN; |
52 #if defined(OS_LINUX) | 52 keyboard_event->text[0] = key_code; |
53 keyboard_event->text = key_code; | |
54 #elif defined(OS_MACOSX) | |
55 keyboard_event->text.clear(); | |
56 keyboard_event->text.push_back(key_code); | |
57 #endif | |
58 } | 53 } |
59 | 54 |
60 // Like InterpretKeyEvent, but with pressing down OSModifier+|key_code|. | 55 // Like InterpretKeyEvent, but with pressing down OSModifier+|key_code|. |
61 // OSModifier is the platform's standard modifier key: control on most | 56 // OSModifier is the platform's standard modifier key: control on most |
62 // platforms, but meta (command) on Mac. | 57 // platforms, but meta (command) on Mac. |
63 const char* InterpretOSModifierKeyPress(char key_code) { | 58 const char* InterpretOSModifierKeyPress(char key_code) { |
64 WebKeyboardEvent keyboard_event; | 59 WebKeyboardEvent keyboard_event; |
65 #if defined(OS_WIN) || defined(OS_LINUX) | 60 #if defined(OS_WIN) || defined(OS_LINUX) |
66 WebInputEvent::Modifiers os_modifier = WebInputEvent::CTRL_KEY; | 61 WebInputEvent::Modifiers os_modifier = WebInputEvent::CTRL_KEY; |
67 #elif defined(OS_MACOSX) | 62 #elif defined(OS_MACOSX) |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 150 |
156 TEST_F(KeyboardTest, TestInsertNewline3) { | 151 TEST_F(KeyboardTest, TestInsertNewline3) { |
157 EXPECT_STREQ("InsertNewline", InterpretNewLine(WebInputEvent::ALT_KEY)); | 152 EXPECT_STREQ("InsertNewline", InterpretNewLine(WebInputEvent::ALT_KEY)); |
158 } | 153 } |
159 | 154 |
160 TEST_F(KeyboardTest, TestInsertNewline4) { | 155 TEST_F(KeyboardTest, TestInsertNewline4) { |
161 int modifiers = WebInputEvent::ALT_KEY | WebInputEvent::SHIFT_KEY; | 156 int modifiers = WebInputEvent::ALT_KEY | WebInputEvent::SHIFT_KEY; |
162 const char* result = InterpretNewLine(modifiers); | 157 const char* result = InterpretNewLine(modifiers); |
163 EXPECT_STREQ("InsertNewline", result); | 158 EXPECT_STREQ("InsertNewline", result); |
164 } | 159 } |
OLD | NEW |