| 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 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| 11 #else |
| 12 // This file defines all the windows VK_ key codes in the WebCore namespace. |
| 13 #include "KeyboardCodes.h" |
| 11 #endif | 14 #endif |
| 12 | 15 |
| 13 #include "StringImpl.h" // This is so that the KJS build works | 16 #include "StringImpl.h" // This is so that the KJS build works |
| 14 | 17 |
| 15 MSVC_PUSH_WARNING_LEVEL(0); | 18 MSVC_PUSH_WARNING_LEVEL(0); |
| 16 #include "PlatformKeyboardEvent.h" | 19 #include "PlatformKeyboardEvent.h" |
| 17 #include "PlatformMouseEvent.h" | 20 #include "PlatformMouseEvent.h" |
| 18 #include "PlatformWheelEvent.h" | 21 #include "PlatformWheelEvent.h" |
| 19 #include "Widget.h" | 22 #include "Widget.h" |
| 20 MSVC_POP_WARNING(); | 23 MSVC_POP_WARNING(); |
| 21 | 24 |
| 22 #undef LOG | 25 #undef LOG |
| 23 #include "base/gfx/point.h" | 26 #include "base/gfx/point.h" |
| 24 #include "base/logging.h" | 27 #include "base/logging.h" |
| 25 #include "webkit/glue/event_conversion.h" | 28 #include "webkit/glue/event_conversion.h" |
| 26 #include "webkit/glue/webinputevent.h" | 29 #include "webkit/glue/webinputevent.h" |
| 27 #include "webkit/glue/webkit_glue.h" | 30 #include "webkit/glue/webkit_glue.h" |
| 28 | 31 |
| 29 using namespace WebCore; | 32 using namespace WebCore; |
| 30 | 33 |
| 31 // MakePlatformMouseEvent ----------------------------------------------------- | 34 // MakePlatformMouseEvent ----------------------------------------------------- |
| 32 | 35 |
| 33 int MakePlatformMouseEvent::last_click_count_ = 0; | 36 int MakePlatformMouseEvent::last_click_count_ = 0; |
| 34 uint32 MakePlatformMouseEvent::last_click_time_ = 0; | 37 uint32 MakePlatformMouseEvent::last_click_time_ = 0; |
| 35 | 38 |
| 36 MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget, | 39 MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget, |
| 37 const WebMouseEvent& e) | 40 const WebMouseEvent& e) |
| 38 #if defined(OS_WIN) | 41 #if defined(OS_WIN) || defined(OS_LINUX) |
| 39 { | 42 { |
| 40 #elif defined(OS_MACOSX) | 43 #elif defined(OS_MACOSX) |
| 41 : PlatformMouseEvent(e.mac_event.get()) { | 44 : PlatformMouseEvent(e.mac_event.get()) { |
| 42 #elif defined(OS_LINUX) | |
| 43 : PlatformMouseEvent() { | |
| 44 #endif | 45 #endif |
| 45 #if defined(OS_WIN) || defined(OS_LINUX) | 46 #if defined(OS_WIN) || defined(OS_LINUX) |
| 46 // TODO(mpcomplete): widget is always toplevel, unless it's a popup. We | 47 // TODO(mpcomplete): widget is always toplevel, unless it's a popup. We |
| 47 // may be able to get rid of this once we abstract popups into a WebKit API. | 48 // may be able to get rid of this once we abstract popups into a WebKit API. |
| 48 m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y)); | 49 m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y)); |
| 49 #endif | 50 #endif |
| 50 m_globalPosition = IntPoint(e.global_x, e.global_y); | 51 m_globalPosition = IntPoint(e.global_x, e.global_y); |
| 51 m_button = static_cast<MouseButton>(e.button); | 52 m_button = static_cast<MouseButton>(e.button); |
| 52 m_shiftKey = (e.modifiers & WebInputEvent::SHIFT_KEY) != 0; | 53 m_shiftKey = (e.modifiers & WebInputEvent::SHIFT_KEY) != 0; |
| 53 m_ctrlKey = (e.modifiers & WebInputEvent::CTRL_KEY) != 0; | 54 m_ctrlKey = (e.modifiers & WebInputEvent::CTRL_KEY) != 0; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 default: | 157 default: |
| 157 ASSERT_NOT_REACHED(); | 158 ASSERT_NOT_REACHED(); |
| 158 } | 159 } |
| 159 return PlatformKeyboardEvent::KeyDown; | 160 return PlatformKeyboardEvent::KeyDown; |
| 160 } | 161 } |
| 161 | 162 |
| 162 static inline String ToSingleCharacterString(UChar c) { | 163 static inline String ToSingleCharacterString(UChar c) { |
| 163 return String(&c, 1); | 164 return String(&c, 1); |
| 164 } | 165 } |
| 165 | 166 |
| 166 #if defined(OS_WIN) | |
| 167 static String GetKeyIdentifierForWindowsKeyCode(unsigned short keyCode) { | 167 static String GetKeyIdentifierForWindowsKeyCode(unsigned short keyCode) { |
| 168 switch (keyCode) { | 168 switch (keyCode) { |
| 169 case VK_MENU: | 169 case VK_MENU: |
| 170 return "Alt"; | 170 return "Alt"; |
| 171 case VK_CONTROL: | 171 case VK_CONTROL: |
| 172 return "Control"; | 172 return "Control"; |
| 173 case VK_SHIFT: | 173 case VK_SHIFT: |
| 174 return "Shift"; | 174 return "Shift"; |
| 175 case VK_CAPITAL: | 175 case VK_CAPITAL: |
| 176 return "CapsLock"; | 176 return "CapsLock"; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 return "Select"; | 259 return "Select"; |
| 260 case VK_UP: | 260 case VK_UP: |
| 261 return "Up"; | 261 return "Up"; |
| 262 // Standard says that DEL becomes U+007F. | 262 // Standard says that DEL becomes U+007F. |
| 263 case VK_DELETE: | 263 case VK_DELETE: |
| 264 return "U+007F"; | 264 return "U+007F"; |
| 265 default: | 265 default: |
| 266 return String::format("U+%04X", toupper(keyCode)); | 266 return String::format("U+%04X", toupper(keyCode)); |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 #else | |
| 270 static String GetKeyIdentifierForWindowsKeyCode(unsigned short keyCode) { | |
| 271 return String::format("U+%04X", toupper(keyCode)); | |
| 272 } | |
| 273 #endif | |
| 274 | 269 |
| 275 MakePlatformKeyboardEvent::MakePlatformKeyboardEvent(const WebKeyboardEvent& e) | 270 MakePlatformKeyboardEvent::MakePlatformKeyboardEvent(const WebKeyboardEvent& e) |
| 276 #if defined(OS_WIN) || defined(OS_LINUX) | 271 #if defined(OS_WIN) || defined(OS_LINUX) |
| 277 { | 272 { |
| 278 #elif defined(OS_MACOSX) | 273 #elif defined(OS_MACOSX) |
| 279 : PlatformKeyboardEvent(e.mac_event.get()) { | 274 : PlatformKeyboardEvent(e.mac_event.get()) { |
| 280 #endif | 275 #endif |
| 281 #if defined(OS_WIN) || defined(OS_LINUX) | 276 #if defined(OS_WIN) || defined(OS_LINUX) |
| 282 m_type = ToPlatformKeyboardEventType(e.type); | 277 m_type = ToPlatformKeyboardEventType(e.type); |
| 283 if (m_type == Char || m_type == KeyDown) | 278 if (m_type == Char || m_type == KeyDown) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 case VK_BACK: | 323 case VK_BACK: |
| 329 case VK_ESCAPE: | 324 case VK_ESCAPE: |
| 330 #endif | 325 #endif |
| 331 return false; | 326 return false; |
| 332 | 327 |
| 333 default: | 328 default: |
| 334 break; | 329 break; |
| 335 } | 330 } |
| 336 return true; | 331 return true; |
| 337 } | 332 } |
| 338 | |
| OLD | NEW |