diff options
7 files changed, 32 insertions, 19 deletions
diff --git a/chrome/browser/renderer_host/gtk_im_context_wrapper.cc b/chrome/browser/renderer_host/gtk_im_context_wrapper.cc index e2b2ded..4b14e8a 100644 --- a/chrome/browser/renderer_host/gtk_im_context_wrapper.cc +++ b/chrome/browser/renderer_host/gtk_im_context_wrapper.cc @@ -302,11 +302,7 @@ void GtkIMContextWrapper::ProcessFilteredKeyPressEvent( // Prevent RenderView::UnhandledKeyboardEvent() from processing it. // Otherwise unexpected result may occur. For example if it's a // Backspace key event, the browser may go back to previous page. - if (wke->os_event) { - wke->os_event->keyval = GDK_VoidSymbol; - wke->os_event->hardware_keycode = 0; - wke->os_event->state = 0; - } + wke->skip_in_browser = true; } host_view_->ForwardKeyboardEvent(*wke); } @@ -330,6 +326,7 @@ void GtkIMContextWrapper::ProcessUnfilteredKeyPressEvent( // see WebInputEventFactory::keyboardEvent() for details. if (wke->text[0]) { wke->type = WebKit::WebInputEvent::Char; + wke->skip_in_browser = true; host_view_->ForwardKeyboardEvent(*wke); } } @@ -353,6 +350,7 @@ void GtkIMContextWrapper::ProcessInputMethodResult(const GdkEventKey* event, NativeWebKeyboardEvent char_event(commit_text_[0], event->state, base::Time::Now().ToDoubleT()); + char_event.skip_in_browser = true; host_view_->ForwardKeyboardEvent(char_event); } else { committed = true; diff --git a/chrome/browser/renderer_host/gtk_key_bindings_handler.cc b/chrome/browser/renderer_host/gtk_key_bindings_handler.cc index 6765ca2..162b352 100644 --- a/chrome/browser/renderer_host/gtk_key_bindings_handler.cc +++ b/chrome/browser/renderer_host/gtk_key_bindings_handler.cc @@ -29,8 +29,7 @@ GtkKeyBindingsHandler::~GtkKeyBindingsHandler() { bool GtkKeyBindingsHandler::Match(const NativeWebKeyboardEvent& wke, EditCommands* edit_commands) { - if (!enabled_ || wke.type == WebKit::WebInputEvent::Char || - !wke.os_event || wke.os_event->keyval == GDK_VoidSymbol) + if (!enabled_ || wke.type == WebKit::WebInputEvent::Char || !wke.os_event) return false; edit_commands_.clear(); diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index b54fb96..44a36bd 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -1064,7 +1064,7 @@ void RenderWidgetHost::ProcessKeyboardEventAck(int type, bool processed) { // We only send unprocessed key event upwards if we are not hidden, // because the user has moved away from us and no longer expect any effect // of this key event. - if (!processed && !is_hidden_) { + if (!processed && !is_hidden_ && !front_item.skip_in_browser) { UnhandledKeyboardEvent(front_item); // WARNING: This RenderWidgetHost can be deallocated at this point diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc index 338e960..a5792b4 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -815,7 +815,8 @@ void RenderWidgetHostViewGtk::ForwardKeyboardEvent( return; EditCommands edit_commands; - if (key_bindings_handler_->Match(event, &edit_commands)) { + if (!event.skip_in_browser && + key_bindings_handler_->Match(event, &edit_commands)) { host_->ForwardEditCommandsForNextKeyEvent(edit_commands); } host_->ForwardKeyboardEvent(event); diff --git a/chrome/common/native_web_keyboard_event.h b/chrome/common/native_web_keyboard_event.h index 438d159..381ad31 100644 --- a/chrome/common/native_web_keyboard_event.h +++ b/chrome/common/native_web_keyboard_event.h @@ -48,15 +48,16 @@ struct NativeWebKeyboardEvent : public WebKit::WebKeyboardEvent { MSG os_event; #elif defined(OS_MACOSX) NSEvent* os_event; +#elif defined(OS_LINUX) + GdkEventKey* os_event; +#endif // True if the browser should ignore this event if it's not handled by the // renderer. This happens for RawKeyDown events that are created while IME is // active and is necessary to prevent backspace from doing "history back" if // it is hit in ime mode. + // Currently, it's only used by Linux and Mac ports. bool skip_in_browser; -#elif defined(OS_LINUX) - GdkEventKey* os_event; -#endif }; #endif // CHROME_COMMON_NATIVE_WEB_KEYBOARD_EVENT_H_ diff --git a/chrome/common/native_web_keyboard_event_linux.cc b/chrome/common/native_web_keyboard_event_linux.cc index c671654..571550e 100644 --- a/chrome/common/native_web_keyboard_event_linux.cc +++ b/chrome/common/native_web_keyboard_event_linux.cc @@ -32,11 +32,13 @@ void FreeEvent(GdkEventKey* event) { NativeWebKeyboardEvent::NativeWebKeyboardEvent() - : os_event(NULL) { + : os_event(NULL), + skip_in_browser(false) { } NativeWebKeyboardEvent::NativeWebKeyboardEvent(const GdkEventKey* native_event) - : WebKeyboardEvent(WebInputEventFactory::keyboardEvent(native_event)) { + : WebKeyboardEvent(WebInputEventFactory::keyboardEvent(native_event)), + skip_in_browser(false) { CopyEventTo(native_event, &os_event); } @@ -46,11 +48,14 @@ NativeWebKeyboardEvent::NativeWebKeyboardEvent(wchar_t character, : WebKeyboardEvent(WebInputEventFactory::keyboardEvent(character, state, time_stamp_seconds)), - os_event(NULL) { + os_event(NULL), + skip_in_browser(false) { } NativeWebKeyboardEvent::NativeWebKeyboardEvent( - const NativeWebKeyboardEvent& other) : WebKeyboardEvent(other) { + const NativeWebKeyboardEvent& other) + : WebKeyboardEvent(other), + skip_in_browser(other.skip_in_browser) { CopyEventTo(other.os_event, &os_event); } @@ -60,6 +65,9 @@ NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=( FreeEvent(os_event); CopyEventTo(other.os_event, &os_event); + + skip_in_browser = other.skip_in_browser; + return *this; } diff --git a/chrome/common/native_web_keyboard_event_win.cc b/chrome/common/native_web_keyboard_event_win.cc index a2ba45f..7608ec6 100644 --- a/chrome/common/native_web_keyboard_event_win.cc +++ b/chrome/common/native_web_keyboard_event_win.cc @@ -9,14 +9,16 @@ using WebKit::WebInputEventFactory; using WebKit::WebKeyboardEvent; -NativeWebKeyboardEvent::NativeWebKeyboardEvent() { +NativeWebKeyboardEvent::NativeWebKeyboardEvent() + : skip_in_browser(false) { memset(&os_event, 0, sizeof(os_event)); } NativeWebKeyboardEvent::NativeWebKeyboardEvent( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) : WebKeyboardEvent( - WebInputEventFactory::keyboardEvent(hwnd, message, wparam, lparam)) { + WebInputEventFactory::keyboardEvent(hwnd, message, wparam, lparam)), + skip_in_browser(false) { os_event.hwnd = hwnd; os_event.message = message; os_event.wParam = wparam; @@ -25,7 +27,8 @@ NativeWebKeyboardEvent::NativeWebKeyboardEvent( NativeWebKeyboardEvent::NativeWebKeyboardEvent( const NativeWebKeyboardEvent& other) - : WebKeyboardEvent(other) { + : WebKeyboardEvent(other), + skip_in_browser(other.skip_in_browser) { os_event.hwnd = other.os_event.hwnd; os_event.message = other.os_event.message; os_event.wParam = other.os_event.wParam; @@ -40,6 +43,9 @@ NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=( os_event.message = other.os_event.message; os_event.wParam = other.os_event.wParam; os_event.lParam = other.os_event.lParam; + + skip_in_browser = other.skip_in_browser; + return *this; } |