Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_impl.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc |
| index be9a48967f1112c9d7354848c63b7fe10b31c614..b14d25bea865cbe9f1b497909ef015390b1ff79f 100644 |
| --- a/content/browser/renderer_host/render_widget_host_impl.cc |
| +++ b/content/browser/renderer_host/render_widget_host_impl.cc |
| @@ -1030,6 +1030,12 @@ void RenderWidgetHostImpl::ForwardGestureEventImmediately( |
| void RenderWidgetHostImpl::ForwardKeyboardEvent( |
| const NativeWebKeyboardEvent& key_event) { |
| TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardKeyboardEvent"); |
| + |
| + // First, let keypress listeners take a shot at handling the event. If a |
| + // listener handles the event, it should not be propagated to the renderer. |
| + if (KeyPressListenersHandleEvent(key_event)) |
|
Evan Stade
2013/01/08 20:54:56
should this come after the ignore input events che
Ilya Sherman
2013/01/08 21:01:45
Yeah, I wasn't sure either... but after some more
|
| + return; |
| + |
| if (ignore_input_events_ || process_->IgnoreInputEvents()) |
| return; |
| @@ -1163,20 +1169,6 @@ void RenderWidgetHostImpl::ForwardTouchEvent( |
| touch_event_queue_->QueueEvent(touch_event); |
| } |
| -bool RenderWidgetHostImpl::KeyPressListenersHandleEvent( |
| - const NativeWebKeyboardEvent& event) { |
| - if (event.type != WebKeyboardEvent::RawKeyDown) |
| - return false; |
| - |
| - for (std::list<KeyboardListener*>::iterator it = keyboard_listeners_.begin(); |
| - it != keyboard_listeners_.end(); ++it) { |
| - if ((*it)->HandleKeyPressEvent(event)) |
| - return true; |
| - } |
| - |
| - return false; |
| -} |
| - |
| void RenderWidgetHostImpl::AddKeyboardListener(KeyboardListener* listener) { |
| keyboard_listeners_.push_back(listener); |
| } |
| @@ -2086,6 +2078,20 @@ void RenderWidgetHostImpl::SetIgnoreInputEvents(bool ignore_input_events) { |
| ignore_input_events_ = ignore_input_events; |
| } |
| +bool RenderWidgetHostImpl::KeyPressListenersHandleEvent( |
| + const NativeWebKeyboardEvent& event) { |
| + if (event.skip_in_browser || event.type != WebKeyboardEvent::RawKeyDown) |
| + return false; |
| + |
| + for (std::list<KeyboardListener*>::iterator it = keyboard_listeners_.begin(); |
| + it != keyboard_listeners_.end(); ++it) { |
| + if ((*it)->HandleKeyPressEvent(event)) |
| + return true; |
| + } |
| + |
| + return false; |
| +} |
| + |
| void RenderWidgetHostImpl::ProcessKeyboardEventAck(int type, bool processed) { |
| if (key_queue_.empty()) { |
| LOG(ERROR) << "Got a KeyEvent back from the renderer but we " |