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 285068b5eab3899bc7e2db66f30f2f227bc6365d..df2e17dfb0cac357d6a9e64eb8fececdc0b9ddde 100644 |
--- a/content/browser/renderer_host/render_widget_host_impl.cc |
+++ b/content/browser/renderer_host/render_widget_host_impl.cc |
@@ -38,6 +38,7 @@ |
#include "content/browser/renderer_host/input/synthetic_gesture_controller.h" |
#include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
#include "content/browser/renderer_host/input/timeout_monitor.h" |
+#include "content/browser/renderer_host/input/touch_emulator.h" |
#include "content/browser/renderer_host/overscroll_controller.h" |
#include "content/browser/renderer_host/render_process_host_impl.h" |
#include "content/browser/renderer_host/render_view_host_impl.h" |
@@ -243,6 +244,8 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
input_router_.reset(new InputRouterImpl(process_, this, this, routing_id_)); |
+ touch_emulator_.reset(); |
+ |
#if defined(USE_AURA) |
bool overscroll_enabled = CommandLine::ForCurrentProcess()-> |
GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; |
@@ -483,6 +486,8 @@ bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) { |
IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) |
IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnBlur) |
IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) |
+ IPC_MESSAGE_HANDLER(ViewHostMsg_SetTouchEventEmulationEnabled, |
+ OnSetTouchEventEmulationEnabled) |
IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged, |
OnTextInputTypeChanged) |
IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition, |
@@ -681,10 +686,16 @@ void RenderWidgetHostImpl::Blur() { |
if (overscroll_controller_) |
overscroll_controller_->Cancel(); |
+ if (touch_emulator_) |
+ touch_emulator_->CancelTouch(); |
+ |
Send(new InputMsg_SetFocus(routing_id_, false)); |
} |
void RenderWidgetHostImpl::LostCapture() { |
+ if (touch_emulator_) |
+ touch_emulator_->CancelTouch(); |
+ |
Send(new InputMsg_MouseCaptureLost(routing_id_)); |
} |
@@ -991,6 +1002,9 @@ void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( |
if (IgnoreInputEvents()) |
return; |
+ if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event)) |
+ return; |
+ |
input_router_->SendMouseEvent(MouseEventWithLatencyInfo(mouse_event, |
latency_info)); |
} |
@@ -1014,6 +1028,9 @@ void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( |
if (IgnoreInputEvents()) |
return; |
+ if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event)) |
+ return; |
+ |
input_router_->SendWheelEvent(MouseWheelEventWithLatencyInfo(wheel_event, |
latency_info)); |
} |
@@ -1138,6 +1155,9 @@ void RenderWidgetHostImpl::ForwardKeyboardEvent( |
suppress_next_char_events_ = false; |
} |
+ if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) |
+ return; |
+ |
input_router_->SendKeyboardEvent( |
key_event, |
CreateRWHLatencyInfoIfNotExist(NULL, key_event.type), |
@@ -1158,6 +1178,12 @@ void RenderWidgetHostImpl::QueueSyntheticGesture( |
} |
} |
+void RenderWidgetHostImpl::SetCursor(const WebCursor& cursor) { |
+ if (!view_) |
+ return; |
+ view_->UpdateCursor(cursor); |
+} |
+ |
void RenderWidgetHostImpl::SendCursorVisibilityState(bool is_visible) { |
Send(new InputMsg_CursorVisibilityChange(GetRoutingID(), is_visible)); |
} |
@@ -1812,10 +1838,16 @@ void RenderWidgetHostImpl::OnBlur() { |
} |
void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) { |
- if (!view_) { |
- return; |
+ SetCursor(cursor); |
+} |
+ |
+void RenderWidgetHostImpl::OnSetTouchEventEmulationEnabled(bool enabled) { |
+ if (enabled) { |
+ if (!touch_emulator_) |
+ touch_emulator_.reset(new TouchEmulator(this)); |
+ } else { |
+ touch_emulator_.reset(); |
} |
- view_->UpdateCursor(cursor); |
} |
void RenderWidgetHostImpl::OnTextInputTypeChanged( |
@@ -2150,6 +2182,10 @@ void RenderWidgetHostImpl::OnTouchEventAck( |
ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, 0); |
} |
ComputeTouchLatency(touch_event.latency); |
+ |
+ if (touch_emulator_ && touch_emulator_->HandleTouchEventAck(ack_result)) |
+ return; |
+ |
if (view_) |
view_->ProcessAckedTouchEvent(touch_event, ack_result); |
} |