summaryrefslogtreecommitdiffstats
path: root/webkit/glue/event_conversion.cc
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 16:02:04 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 16:02:04 +0000
commit5a7f0b9b48976c5e043eabf4d6e54f0cf19f01c9 (patch)
treeff82b5f19bb106cbd67984c44604b414289ba12b /webkit/glue/event_conversion.cc
parent5982f1f39f5cab5a9e6d61ac2386d0f09c7cf0c7 (diff)
downloadchromium_src-5a7f0b9b48976c5e043eabf4d6e54f0cf19f01c9.zip
chromium_src-5a7f0b9b48976c5e043eabf4d6e54f0cf19f01c9.tar.gz
chromium_src-5a7f0b9b48976c5e043eabf4d6e54f0cf19f01c9.tar.bz2
Fixing WebKeyboardEvent. Third time's the charm.
Review URL: http://codereview.chromium.org/27332 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10794 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/event_conversion.cc')
-rw-r--r--webkit/glue/event_conversion.cc171
1 files changed, 10 insertions, 161 deletions
diff --git a/webkit/glue/event_conversion.cc b/webkit/glue/event_conversion.cc
index 0902778..39cdc90 100644
--- a/webkit/glue/event_conversion.cc
+++ b/webkit/glue/event_conversion.cc
@@ -22,6 +22,7 @@ MSVC_POP_WARNING();
#include "base/gfx/point.h"
#include "base/logging.h"
#include "webkit/glue/event_conversion.h"
+#include "webkit/glue/glue_util.h"
#include "webkit/glue/webinputevent.h"
#include "webkit/glue/webkit_glue.h"
@@ -141,6 +142,8 @@ static inline const PlatformKeyboardEvent::Type ToPlatformKeyboardEventType(
return PlatformKeyboardEvent::KeyUp;
case WebInputEvent::KEY_DOWN:
return PlatformKeyboardEvent::KeyDown;
+ case WebInputEvent::RAW_KEY_DOWN:
+ return PlatformKeyboardEvent::RawKeyDown;
case WebInputEvent::CHAR:
return PlatformKeyboardEvent::Char;
default:
@@ -149,175 +152,21 @@ static inline const PlatformKeyboardEvent::Type ToPlatformKeyboardEventType(
return PlatformKeyboardEvent::KeyDown;
}
-static inline String ToSingleCharacterString(UChar c) {
- return String(&c, 1);
-}
-
-#if !defined(OS_MACOSX)
-// This function is not used on Mac OS X, and gcc complains.
-static String GetKeyIdentifierForWindowsKeyCode(unsigned short keyCode) {
- switch (keyCode) {
- case VKEY_MENU:
- return "Alt";
- case VKEY_CONTROL:
- return "Control";
- case VKEY_SHIFT:
- return "Shift";
- case VKEY_CAPITAL:
- return "CapsLock";
- case VKEY_LWIN:
- case VKEY_RWIN:
- return "Win";
- case VKEY_CLEAR:
- return "Clear";
- case VKEY_DOWN:
- return "Down";
- // "End"
- case VKEY_END:
- return "End";
- // "Enter"
- case VKEY_RETURN:
- return "Enter";
- case VKEY_EXECUTE:
- return "Execute";
- case VKEY_F1:
- return "F1";
- case VKEY_F2:
- return "F2";
- case VKEY_F3:
- return "F3";
- case VKEY_F4:
- return "F4";
- case VKEY_F5:
- return "F5";
- case VKEY_F6:
- return "F6";
- case VKEY_F7:
- return "F7";
- case VKEY_F8:
- return "F8";
- case VKEY_F9:
- return "F9";
- case VKEY_F10:
- return "F11";
- case VKEY_F12:
- return "F12";
- case VKEY_F13:
- return "F13";
- case VKEY_F14:
- return "F14";
- case VKEY_F15:
- return "F15";
- case VKEY_F16:
- return "F16";
- case VKEY_F17:
- return "F17";
- case VKEY_F18:
- return "F18";
- case VKEY_F19:
- return "F19";
- case VKEY_F20:
- return "F20";
- case VKEY_F21:
- return "F21";
- case VKEY_F22:
- return "F22";
- case VKEY_F23:
- return "F23";
- case VKEY_F24:
- return "F24";
- case VKEY_HELP:
- return "Help";
- case VKEY_HOME:
- return "Home";
- case VKEY_INSERT:
- return "Insert";
- case VKEY_LEFT:
- return "Left";
- case VKEY_NEXT:
- return "PageDown";
- case VKEY_PRIOR:
- return "PageUp";
- case VKEY_PAUSE:
- return "Pause";
- case VKEY_SNAPSHOT:
- return "PrintScreen";
- case VKEY_RIGHT:
- return "Right";
- case VKEY_SCROLL:
- return "Scroll";
- case VKEY_SELECT:
- return "Select";
- case VKEY_UP:
- return "Up";
- // Standard says that DEL becomes U+007F.
- case VKEY_DELETE:
- return "U+007F";
- default:
- return String::format("U+%04X", toupper(keyCode));
- }
-}
-#endif // !defined(OS_MACOSX)
-
-MakePlatformKeyboardEvent::MakePlatformKeyboardEvent(const WebKeyboardEvent& e)
- {
+MakePlatformKeyboardEvent::MakePlatformKeyboardEvent(
+ const WebKeyboardEvent& e) {
m_type = ToPlatformKeyboardEventType(e.type);
- if (m_type == Char || m_type == KeyDown) {
-#if defined(OS_MACOSX)
- m_text = &e.text[0];
- m_unmodifiedText = &e.unmodified_text[0];
- m_keyIdentifier = &e.key_identifier[0];
-
- // Always use 13 for Enter/Return -- we don't want to use AppKit's
- // different character for Enter.
- if (m_windowsVirtualKeyCode == '\r') {
- m_text = "\r";
- m_unmodifiedText = "\r";
- }
-
- // The adjustments below are only needed in backward compatibility mode,
- // but we cannot tell what mode we are in from here.
-
- // Turn 0x7F into 8, because backspace needs to always be 8.
- if (m_text == "\x7F")
- m_text = "\x8";
- if (m_unmodifiedText == "\x7F")
- m_unmodifiedText = "\x8";
- // Always use 9 for tab -- we don't want to use AppKit's different character for shift-tab.
- if (m_windowsVirtualKeyCode == 9) {
- m_text = "\x9";
- m_unmodifiedText = "\x9";
- }
-#elif defined(OS_WIN)
- m_text = m_unmodifiedText = ToSingleCharacterString(e.key_code);
-#elif defined(OS_LINUX)
- m_text = m_unmodifiedText = ToSingleCharacterString(e.text);
-#endif
- }
-#if defined(OS_WIN) || defined(OS_LINUX)
- if (m_type != Char)
- m_keyIdentifier = GetKeyIdentifierForWindowsKeyCode(e.key_code);
-#endif
- if (m_type == Char || m_type == KeyDown || m_type == KeyUp ||
- m_type == RawKeyDown) {
- m_windowsVirtualKeyCode = e.key_code;
- } else {
- m_windowsVirtualKeyCode = 0;
- }
+ m_text = WebCore::String(e.text);
+ m_unmodifiedText = WebCore::String(e.unmodified_text);
+ m_keyIdentifier = WebCore::String(e.key_identifier);
m_autoRepeat = (e.modifiers & WebInputEvent::IS_AUTO_REPEAT) != 0;
+ m_windowsVirtualKeyCode = e.windows_key_code;
+ m_nativeVirtualKeyCode = e.native_key_code;
m_isKeypad = (e.modifiers & WebInputEvent::IS_KEYPAD) != 0;
m_shiftKey = (e.modifiers & WebInputEvent::SHIFT_KEY) != 0;
m_ctrlKey = (e.modifiers & WebInputEvent::CTRL_KEY) != 0;
m_altKey = (e.modifiers & WebInputEvent::ALT_KEY) != 0;
m_metaKey = (e.modifiers & WebInputEvent::META_KEY) != 0;
-#if defined(OS_WIN)
m_isSystemKey = e.system_key;
-// TODO(port): set this field properly for linux and mac.
-#elif defined(OS_LINUX)
- m_isSystemKey = m_altKey;
-#else
- m_isSystemKey = false;
-#endif
}
void MakePlatformKeyboardEvent::SetKeyType(Type type) {