Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 11779035: Centralize keypress listener handling in non-platform-specific code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 "
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698