| 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 #if defined(OS_WIN) |
| 52 keyboard_event->type = WebInputEvent::RAW_KEY_DOWN; |
| 53 #else |
| 51 keyboard_event->type = WebInputEvent::KEY_DOWN; | 54 keyboard_event->type = WebInputEvent::KEY_DOWN; |
| 52 #if defined(OS_LINUX) | 55 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 | 56 #endif |
| 58 } | 57 } |
| 59 | 58 |
| 60 // Like InterpretKeyEvent, but with pressing down OSModifier+|key_code|. | 59 // Like InterpretKeyEvent, but with pressing down OSModifier+|key_code|. |
| 61 // OSModifier is the platform's standard modifier key: control on most | 60 // OSModifier is the platform's standard modifier key: control on most |
| 62 // platforms, but meta (command) on Mac. | 61 // platforms, but meta (command) on Mac. |
| 63 const char* InterpretOSModifierKeyPress(char key_code) { | 62 const char* InterpretOSModifierKeyPress(char key_code) { |
| 64 WebKeyboardEvent keyboard_event; | 63 WebKeyboardEvent keyboard_event; |
| 65 #if defined(OS_WIN) || defined(OS_LINUX) | 64 #if defined(OS_WIN) || defined(OS_LINUX) |
| 66 WebInputEvent::Modifiers os_modifier = WebInputEvent::CTRL_KEY; | 65 WebInputEvent::Modifiers os_modifier = WebInputEvent::CTRL_KEY; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 154 |
| 156 TEST_F(KeyboardTest, TestInsertNewline3) { | 155 TEST_F(KeyboardTest, TestInsertNewline3) { |
| 157 EXPECT_STREQ("InsertNewline", InterpretNewLine(WebInputEvent::ALT_KEY)); | 156 EXPECT_STREQ("InsertNewline", InterpretNewLine(WebInputEvent::ALT_KEY)); |
| 158 } | 157 } |
| 159 | 158 |
| 160 TEST_F(KeyboardTest, TestInsertNewline4) { | 159 TEST_F(KeyboardTest, TestInsertNewline4) { |
| 161 int modifiers = WebInputEvent::ALT_KEY | WebInputEvent::SHIFT_KEY; | 160 int modifiers = WebInputEvent::ALT_KEY | WebInputEvent::SHIFT_KEY; |
| 162 const char* result = InterpretNewLine(modifiers); | 161 const char* result = InterpretNewLine(modifiers); |
| 163 EXPECT_STREQ("InsertNewline", result); | 162 EXPECT_STREQ("InsertNewline", result); |
| 164 } | 163 } |
| OLD | NEW |