diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-25 19:40:17 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-25 19:40:17 +0000 |
commit | b068e3357250547bee1fd3075d05e5f44f8bfafb (patch) | |
tree | 78008cf3d8882a3fdcfd652d55e485c54bae0bc4 /webkit/glue/webview_impl.cc | |
parent | 4c8e0e08a34050a8301856f00a65e4bc106e968e (diff) | |
download | chromium_src-b068e3357250547bee1fd3075d05e5f44f8bfafb.zip chromium_src-b068e3357250547bee1fd3075d05e5f44f8bfafb.tar.gz chromium_src-b068e3357250547bee1fd3075d05e5f44f8bfafb.tar.bz2 |
Revert "Fixing WebKeyboardEvent."
Review URL: http://codereview.appspot.com/21071
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webview_impl.cc')
-rw-r--r-- | webkit/glue/webview_impl.cc | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 99beb70..2705168 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -478,8 +478,7 @@ void WebViewImpl::MouseWheel(const WebMouseWheelEvent& event) { } bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) { - DCHECK((event.type == WebInputEvent::RAW_KEY_DOWN) || - (event.type == WebInputEvent::KEY_DOWN) || + DCHECK((event.type == WebInputEvent::KEY_DOWN) || (event.type == WebInputEvent::KEY_UP)); // Please refer to the comments explaining the suppress_next_keypress_event_ @@ -504,9 +503,9 @@ bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) { #if defined(OS_WIN) // TODO(pinkerton): figure out these keycodes on non-windows - if (((event.modifiers == 0) && (event.windows_key_code == VK_APPS)) || + if (((event.modifiers == 0) && (event.key_code == VK_APPS)) || ((event.modifiers == WebInputEvent::SHIFT_KEY) && - (event.windows_key_code == VK_F10))) { + (event.key_code == VK_F10))) { SendContextMenuEvent(event); return true; } @@ -514,8 +513,10 @@ bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) { MakePlatformKeyboardEvent evt(event); - if (WebInputEvent::RAW_KEY_DOWN == event.type) { +#if !defined(OS_MACOSX) + if (WebInputEvent::KEY_DOWN == event.type) { MakePlatformKeyboardEvent evt_rawkeydown = evt; + evt_rawkeydown.SetKeyType(WebCore::PlatformKeyboardEvent::RawKeyDown); if (handler->keyEvent(evt_rawkeydown) && !evt_rawkeydown.isSystemKey()) { suppress_next_keypress_event_ = true; return true; @@ -525,6 +526,19 @@ bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) { return true; } } +#else + // Windows and Cocoa handle events in rather different ways. On Windows, + // you get two events: WM_KEYDOWN/WM_KEYUP and WM_CHAR. In + // PlatformKeyboardEvent, RawKeyDown represents the raw messages. When + // processing them, we don't process text editing events, since we'll be + // getting the data soon enough. In Cocoa, we get one event with both the + // raw and processed data. Therefore we need to keep the type as KeyDown, so + // that we'll know that this is the only time we'll have the event and that + // we need to do our thing. + if (handler->keyEvent(evt)) { + return true; + } +#endif return KeyEventDefault(event); } @@ -532,19 +546,18 @@ bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) { bool WebViewImpl::AutocompleteHandleKeyEvent(const WebKeyboardEvent& event) { if (!autocomplete_popup_showing_ || // Home and End should be left to the text field to process. - event.windows_key_code == base::VKEY_HOME || - event.windows_key_code == base::VKEY_END) { + event.key_code == base::VKEY_HOME || event.key_code == base::VKEY_END) { return false; } - if (!autocomplete_popup_->isInterestedInEventForKey(event.windows_key_code)) + if (!autocomplete_popup_->isInterestedInEventForKey(event.key_code)) return false; if (autocomplete_popup_->handleKeyEvent(MakePlatformKeyboardEvent(event))) { #if defined(OS_WIN) // We need to ignore the next CHAR event after this otherwise pressing // enter when selecting an item in the menu will go to the page. - if (WebInputEvent::RAW_KEY_DOWN == event.type) + if (WebInputEvent::KEY_DOWN == event.type) suppress_next_keypress_event_ = true; #endif return true; @@ -678,7 +691,7 @@ bool WebViewImpl::KeyEventDefault(const WebKeyboardEvent& event) { case WebInputEvent::CHAR: { #if defined(OS_WIN) // TODO(pinkerton): hook this up for non-win32 - if (event.windows_key_code == VK_SPACE) { + if (event.key_code == VK_SPACE) { int key_code = ((event.modifiers & WebInputEvent::SHIFT_KEY) ? VK_PRIOR : VK_NEXT); return ScrollViewWithKeyboard(key_code); @@ -687,9 +700,9 @@ bool WebViewImpl::KeyEventDefault(const WebKeyboardEvent& event) { break; } - case WebInputEvent::RAW_KEY_DOWN: { + case WebInputEvent::KEY_DOWN: { if (event.modifiers == WebInputEvent::CTRL_KEY) { - switch (event.windows_key_code) { + switch (event.key_code) { case 'A': GetFocusedFrame()->SelectAll(); return true; @@ -714,7 +727,7 @@ bool WebViewImpl::KeyEventDefault(const WebKeyboardEvent& event) { } #if defined(OS_WIN) if (!event.system_key) { - return ScrollViewWithKeyboard(event.windows_key_code); + return ScrollViewWithKeyboard(event.key_code); } #endif break; @@ -959,7 +972,6 @@ bool WebViewImpl::HandleInputEvent(const WebInputEvent* input_event) { MouseUp(*static_cast<const WebMouseEvent*>(input_event)); break; - case WebInputEvent::RAW_KEY_DOWN: case WebInputEvent::KEY_DOWN: case WebInputEvent::KEY_UP: handled = KeyEvent(*static_cast<const WebKeyboardEvent*>(input_event)); @@ -1220,14 +1232,15 @@ void WebViewImpl::SetInitialFocus(bool reverse) { // Since we don't have a keyboard event, we'll create one. WebKeyboardEvent keyboard_event; - keyboard_event.type = WebInputEvent::RAW_KEY_DOWN; + keyboard_event.type = WebInputEvent::KEY_DOWN; if (reverse) keyboard_event.modifiers = WebInputEvent::SHIFT_KEY; // VK_TAB which is only defined on Windows. - keyboard_event.windows_key_code = 0x09; + keyboard_event.key_code = 0x09; MakePlatformKeyboardEvent platform_event(keyboard_event); // We have to set the key type explicitly to avoid an assert in the // KeyboardEvent constructor. + platform_event.SetKeyType(PlatformKeyboardEvent::RawKeyDown); RefPtr<KeyboardEvent> webkit_event = KeyboardEvent::create(platform_event, NULL); page()->focusController()->setInitialFocus( |