Index: webkit/glue/webview_impl.cc |
=================================================================== |
--- webkit/glue/webview_impl.cc (revision 10468) |
+++ webkit/glue/webview_impl.cc (working copy) |
@@ -480,8 +480,7 @@ |
} |
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_ |
@@ -506,9 +505,9 @@ |
#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; |
} |
@@ -516,8 +515,10 @@ |
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; |
@@ -527,6 +528,19 @@ |
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); |
} |
@@ -534,19 +548,18 @@ |
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; |
@@ -680,7 +693,7 @@ |
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); |
@@ -689,9 +702,9 @@ |
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; |
@@ -716,7 +729,7 @@ |
} |
#if defined(OS_WIN) |
if (!event.system_key) { |
- return ScrollViewWithKeyboard(event.windows_key_code); |
+ return ScrollViewWithKeyboard(event.key_code); |
} |
#endif |
break; |
@@ -961,7 +974,6 @@ |
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)); |
@@ -1222,14 +1234,15 @@ |
// 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( |