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

Unified Diff: content/renderer/render_widget.cc

Issue 19220002: [WIP] BufferedInputRouter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix client assignment Created 7 years, 3 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
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index a64f1d1d0b2134cf0ebd7945cb4567d5ff351b65..a55946853546c39f60a750bdb7d7949092de4b6b 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -373,6 +373,7 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent)
+ IPC_MESSAGE_HANDLER(InputMsg_HandleEventPacket, OnHandleEventPacket)
IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange,
OnCursorVisibilityChange)
IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost)
@@ -811,17 +812,19 @@ void RenderWidget::OnViewContextSwapBuffersComplete() {
DoDeferredUpdateAndSendInputAck();
}
-void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event,
- const ui::LatencyInfo& latency_info,
- bool is_keyboard_shortcut) {
+InputEventDisposition RenderWidget::HandleWebEvent(
+ const WebKit::WebInputEvent* input_event,
+ const ui::LatencyInfo& latency_info,
+ bool is_keyboard_shortcut,
+ bool send_ack) {
handling_input_event_ = true;
if (!input_event) {
handling_input_event_ = false;
- return;
+ return INPUT_EVENT_COULD_NOT_DELIVER;
}
const char* const event_name = GetEventName(input_event->type);
- TRACE_EVENT1("renderer", "RenderWidget::OnHandleInputEvent",
+ TRACE_EVENT1("renderer", "RenderWidget::HandleInputEvent",
"event", event_name);
if (compositor_)
@@ -893,36 +896,39 @@ void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event,
INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
}
- IPC::Message* response =
- new InputHostMsg_HandleInputEvent_ACK(routing_id_,
- input_event->type,
- ack_result,
- latency_info);
- bool event_type_gets_rate_limited =
- input_event->type == WebInputEvent::MouseMove ||
- input_event->type == WebInputEvent::MouseWheel ||
- WebInputEvent::isTouchEventType(input_event->type);
-
- bool frame_pending = paint_aggregator_.HasPendingUpdate();
- if (is_accelerated_compositing_active_) {
- frame_pending = compositor_ &&
- compositor_->commitRequested();
- }
-
- if (event_type_gets_rate_limited && frame_pending && !is_hidden_) {
- // We want to rate limit the input events in this case, so we'll wait for
- // painting to finish before ACKing this message.
- if (pending_input_event_ack_) {
- // As two different kinds of events could cause us to postpone an ack
- // we send it now, if we have one pending. The Browser should never
- // send us the same kind of event we are delaying the ack for.
- Send(pending_input_event_ack_.release());
+ if (send_ack) {
+ IPC::Message* response =
+ new InputHostMsg_HandleInputEvent_ACK(routing_id_,
+ input_event->type,
+ ack_result,
+ latency_info);
+
+ bool event_type_gets_rate_limited =
+ input_event->type == WebInputEvent::MouseMove ||
+ input_event->type == WebInputEvent::MouseWheel ||
+ WebInputEvent::isTouchEventType(input_event->type);
+
+ bool frame_pending = paint_aggregator_.HasPendingUpdate();
+ if (is_accelerated_compositing_active_) {
+ frame_pending = compositor_ &&
+ compositor_->commitRequested();
+ }
+
+ if (event_type_gets_rate_limited && frame_pending && !is_hidden_) {
+ // We want to rate limit the input events in this case, so we'll wait for
+ // painting to finish before ACKing this message.
+ if (pending_input_event_ack_) {
+ // As two different kinds of events could cause us to postpone an ack
+ // we send it now, if we have one pending. The Browser should never
+ // send us the same kind of event we are delaying the ack for.
+ Send(pending_input_event_ack_.release());
+ }
+ pending_input_event_ack_.reset(response);
+ if (compositor_)
+ compositor_->NotifyInputThrottledUntilCommit();
+ } else {
+ Send(response);
}
- pending_input_event_ack_.reset(response);
- if (compositor_)
- compositor_->NotifyInputThrottledUntilCommit();
- } else {
- Send(response);
}
#if defined(OS_ANDROID)
@@ -942,6 +948,44 @@ void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event,
if (WebInputEvent::isTouchEventType(input_event->type))
DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event)));
}
+
+ return ToDisposition(ack_result, true, prevent_default);
+}
+
+InputEventDisposition RenderWidget::Dispatch(const IPC::Message& message) {
+ OnMessageReceived(message);
+ return INPUT_EVENT_MAIN_THREAD_CONSUMED;
+}
+
+InputEventDisposition RenderWidget::Dispatch(
+ int routing_id,
+ const WebKit::WebInputEvent* web_event,
+ const ui::LatencyInfo& latency_info,
+ bool is_keyboard_shortcut) {
+ DCHECK_EQ(routing_id_, routing_id);
+ return HandleWebEvent(web_event, latency_info, is_keyboard_shortcut, false);
+}
+
+void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event,
+ const ui::LatencyInfo& latency_info,
+ bool is_keyboard_shortcut) {
+ HandleWebEvent(input_event, latency_info, is_keyboard_shortcut, true);
+}
+
+void RenderWidget::OnHandleEventPacket(
+ const EventPacket& packet,
+ const InputEventDispositions& dispositions) {
+ TRACE_EVENT0("renderer", "OnHandleEventPacket");
+
+ RendererEventPacket renderer_packet(&packet, dispositions);
+
+ scoped_ptr<IPC::Message> dispatch_result =
+ renderer_packet.DispatchWith(this,
+ RendererEventPacket::THREAD_MAIN,
+ routing_id_);
+
+ DCHECK_EQ(InputHostMsg_HandleEventPacket_ACK::ID, dispatch_result->type());
+ Send(dispatch_result.release());
}
void RenderWidget::OnCursorVisibilityChange(bool is_visible) {
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698