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 16892a172a0dc70dc7b0efdd81ad30eaab68d82b..ec0de420ffd150de1c52a013b620d281b2c1c41f 100644 |
--- a/content/browser/renderer_host/render_widget_host_impl.cc |
+++ b/content/browser/renderer_host/render_widget_host_impl.cc |
@@ -1016,6 +1016,12 @@ void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( |
const MouseEventWithLatencyInfo& mouse_event) { |
TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", |
"x", mouse_event.event.x, "y", mouse_event.event.y); |
+ |
+ // First, let mouse event callbacks take a shot at handling the event. If a |
+ // callback handles the event, it should not be propagated to the renderer. |
+ if (MouseEventCallbacksHandleEvent(mouse_event.event)) |
jam
2013/08/27 16:17:53
nit: given the size of this function, why not just
wdzierzanowski
2013/08/27 19:29:51
In fact, I didn't care much for this being a separ
|
+ return; |
+ |
input_router_->SendMouseEvent(mouse_event); |
} |
@@ -1134,6 +1140,21 @@ void RenderWidgetHostImpl::RemoveKeyboardListener( |
keyboard_listeners_.RemoveObserver(listener); |
} |
+void RenderWidgetHostImpl::AddMouseEventCallback( |
+ const MouseEventCallback& callback) { |
+ mouse_event_callbacks_.push_back(callback); |
+} |
+ |
+void RenderWidgetHostImpl::RemoveMouseEventCallback( |
+ const MouseEventCallback& callback) { |
+ for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { |
+ if (mouse_event_callbacks_[i].Equals(callback)) { |
+ mouse_event_callbacks_.erase(mouse_event_callbacks_.begin() + i); |
+ return; |
+ } |
+ } |
+} |
+ |
void RenderWidgetHostImpl::GetWebScreenInfo(WebKit::WebScreenInfo* result) { |
TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::GetWebScreenInfo"); |
if (GetView()) |
@@ -1899,6 +1920,16 @@ bool RenderWidgetHostImpl::KeyPressListenersHandleEvent( |
return false; |
} |
+bool RenderWidgetHostImpl::MouseEventCallbacksHandleEvent( |
+ const WebMouseEvent& event) { |
+ for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { |
+ if (mouse_event_callbacks_[i].Run(event)) |
+ return true; |
+ } |
+ |
+ return false; |
+} |
+ |
InputEventAckState RenderWidgetHostImpl::FilterInputEvent( |
const WebKit::WebInputEvent& event, const ui::LatencyInfo& latency_info) { |
if (overscroll_controller() && |