Chromium Code Reviews| Index: content/browser/devtools/protocol/input_handler.cc |
| diff --git a/content/browser/devtools/protocol/input_handler.cc b/content/browser/devtools/protocol/input_handler.cc |
| index b963044209c287436628372f8df442313c35867a..dcfd8d8b4e75281ae5f60190bd65775e3bd9716f 100644 |
| --- a/content/browser/devtools/protocol/input_handler.cc |
| +++ b/content/browser/devtools/protocol/input_handler.cc |
| @@ -130,6 +130,7 @@ bool SetMouseEventType(blink::WebMouseEvent* event, const std::string& type) { |
| InputHandler::InputHandler() |
| : host_(NULL), |
| + input_queued_(false), |
| page_scale_factor_(1.0), |
| weak_factory_(this) { |
| } |
| @@ -137,8 +138,36 @@ InputHandler::InputHandler() |
| InputHandler::~InputHandler() { |
| } |
| +void InputHandler::OnInputEvent(const blink::WebInputEvent& event) { |
| + input_queued_ = true; |
| +} |
| + |
| +void InputHandler::OnInputEventAck(const blink::WebInputEvent& event) { |
| + if (blink::WebInputEvent::isKeyboardEventType(event.type) && |
| + !pending_key_command_ids_.empty()) { |
| + SendDispatchKeyEventResponse(pending_key_command_ids_.front()); |
| + pending_key_command_ids_.pop_front(); |
| + } else if (blink::WebInputEvent::isMouseEventType(event.type) && |
| + !pending_mouse_command_ids_.empty()) { |
| + SendDispatchMouseEventResponse(pending_mouse_command_ids_.front()); |
| + pending_mouse_command_ids_.pop_front(); |
| + } |
| +} |
| + |
| void InputHandler::SetRenderWidgetHost(RenderWidgetHostImpl* host) { |
| + for (const DevToolsCommandId& command_id : pending_key_command_ids_) |
|
dgozman
2016/11/21 19:14:39
You'll need to do the same on detach. See Detached
samuong
2016/11/21 22:28:43
I've added an InputHandler::Detached method, but t
samuong
2016/11/23 00:37:47
Done - added a call from RFDTAH::OnClientDetached
|
| + SendDispatchKeyEventResponse(command_id); |
| + pending_key_command_ids_.clear(); |
| + |
| + for (const DevToolsCommandId& command_id : pending_mouse_command_ids_) |
| + SendDispatchMouseEventResponse(command_id); |
| + pending_mouse_command_ids_.clear(); |
| + |
| + if (host_) |
| + host_->RemoveInputEventObserver(this); |
| host_ = host; |
| + if (host) |
| + host->AddInputEventObserver(this); |
| } |
| void InputHandler::SetClient(std::unique_ptr<Client> client) { |
| @@ -152,6 +181,7 @@ void InputHandler::OnSwapCompositorFrame( |
| } |
| Response InputHandler::DispatchKeyEvent( |
| + DevToolsCommandId command_id, |
| const std::string& type, |
| const int* modifiers, |
| const double* timestamp, |
| @@ -213,11 +243,17 @@ Response InputHandler::DispatchKeyEvent( |
| return Response::ServerError("Could not connect to view"); |
| host_->Focus(); |
| + input_queued_ = false; |
| host_->ForwardKeyboardEvent(event); |
| + if (input_queued_) |
| + pending_key_command_ids_.push_back(command_id); |
| + else |
| + SendDispatchKeyEventResponse(command_id); |
| return Response::OK(); |
| } |
| Response InputHandler::DispatchMouseEvent( |
| + DevToolsCommandId command_id, |
| const std::string& type, |
| int x, |
| int y, |
| @@ -249,7 +285,12 @@ Response InputHandler::DispatchMouseEvent( |
| return Response::ServerError("Could not connect to view"); |
| host_->Focus(); |
| + input_queued_ = false; |
| host_->ForwardMouseEvent(event); |
| + if (input_queued_) |
| + pending_mouse_command_ids_.push_back(command_id); |
| + else |
| + SendDispatchMouseEventResponse(command_id); |
| return Response::OK(); |
| } |
| @@ -479,6 +520,17 @@ Response InputHandler::DispatchTouchEvent( |
| return Response::FallThrough(); |
| } |
| +void InputHandler::SendDispatchKeyEventResponse(DevToolsCommandId command_id) { |
| + client_->SendDispatchKeyEventResponse( |
| + command_id, DispatchKeyEventResponse::Create()); |
| +} |
| + |
| +void InputHandler::SendDispatchMouseEventResponse( |
| + DevToolsCommandId command_id) { |
| + client_->SendDispatchMouseEventResponse( |
| + command_id, DispatchMouseEventResponse::Create()); |
| +} |
| + |
| void InputHandler::SendSynthesizePinchGestureResponse( |
| DevToolsCommandId command_id, |
| SyntheticGesture::Result result) { |