| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 keyboard_event->type = WebInputEvent::KeyDown; | 57 keyboard_event->type = WebInputEvent::KeyDown; |
| 58 keyboard_event->text[0] = key_code; | 58 keyboard_event->text[0] = key_code; |
| 59 keyboard_event->setKeyIdentifierFromWindowsKeyCode(); | 59 keyboard_event->setKeyIdentifierFromWindowsKeyCode(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Like InterpretKeyEvent, but with pressing down OSModifier+|key_code|. | 62 // Like InterpretKeyEvent, but with pressing down OSModifier+|key_code|. |
| 63 // OSModifier is the platform's standard modifier key: control on most | 63 // OSModifier is the platform's standard modifier key: control on most |
| 64 // platforms, but meta (command) on Mac. | 64 // platforms, but meta (command) on Mac. |
| 65 const char* InterpretOSModifierKeyPress(char key_code) { | 65 const char* InterpretOSModifierKeyPress(char key_code) { |
| 66 WebKeyboardEvent keyboard_event; | 66 WebKeyboardEvent keyboard_event; |
| 67 #if defined(OS_WIN) || defined(OS_LINUX) | 67 #if defined(OS_MACOSX) |
| 68 WebInputEvent::Modifiers os_modifier = WebInputEvent::MetaKey; |
| 69 #else |
| 68 WebInputEvent::Modifiers os_modifier = WebInputEvent::ControlKey; | 70 WebInputEvent::Modifiers os_modifier = WebInputEvent::ControlKey; |
| 69 #elif defined(OS_MACOSX) | |
| 70 WebInputEvent::Modifiers os_modifier = WebInputEvent::MetaKey; | |
| 71 #endif | 71 #endif |
| 72 SetupKeyDownEvent(&keyboard_event, key_code, os_modifier); | 72 SetupKeyDownEvent(&keyboard_event, key_code, os_modifier); |
| 73 return InterpretKeyEvent(keyboard_event, PlatformKeyboardEvent::RawKeyDown); | 73 return InterpretKeyEvent(keyboard_event, PlatformKeyboardEvent::RawKeyDown); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Like InterpretKeyEvent, but with pressing down ctrl+|key_code|. | 76 // Like InterpretKeyEvent, but with pressing down ctrl+|key_code|. |
| 77 const char* InterpretCtrlKeyPress(char key_code) { | 77 const char* InterpretCtrlKeyPress(char key_code) { |
| 78 WebKeyboardEvent keyboard_event; | 78 WebKeyboardEvent keyboard_event; |
| 79 SetupKeyDownEvent(&keyboard_event, key_code, WebInputEvent::ControlKey); | 79 SetupKeyDownEvent(&keyboard_event, key_code, WebInputEvent::ControlKey); |
| 80 return InterpretKeyEvent(keyboard_event, PlatformKeyboardEvent::RawKeyDown); | 80 return InterpretKeyEvent(keyboard_event, PlatformKeyboardEvent::RawKeyDown); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 TEST_F(KeyboardTest, TestInsertNewline3) { | 170 TEST_F(KeyboardTest, TestInsertNewline3) { |
| 171 EXPECT_STREQ("InsertNewline", InterpretNewLine(WebInputEvent::AltKey)); | 171 EXPECT_STREQ("InsertNewline", InterpretNewLine(WebInputEvent::AltKey)); |
| 172 } | 172 } |
| 173 | 173 |
| 174 TEST_F(KeyboardTest, TestInsertNewline4) { | 174 TEST_F(KeyboardTest, TestInsertNewline4) { |
| 175 int modifiers = WebInputEvent::AltKey | WebInputEvent::ShiftKey; | 175 int modifiers = WebInputEvent::AltKey | WebInputEvent::ShiftKey; |
| 176 const char* result = InterpretNewLine(modifiers); | 176 const char* result = InterpretNewLine(modifiers); |
| 177 EXPECT_STREQ("InsertNewline", result); | 177 EXPECT_STREQ("InsertNewline", result); |
| 178 } | 178 } |
| OLD | NEW |