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