Commit 1643da31 authored by David Bokan's avatar David Bokan Committed by Commit Bot

DevTools: Wait when sending touch emulation events

Injected input should force generate a frame before being dispatched so
that we ensure the compositor is aware of any touch event handlers and
other side effects that may have occurred prior to the input.

This was previously done for other modalities in this file in
https://crrev.com/c/2437695 but not for mouse emulating touch. This
causes the inspector-protocol/input/emulateTouchFromMouseEvent.js test
to start failing when input is routed through the compositor.

Bug: 915926
Change-Id: I135ecbcd8e69d3dad5ee3ff4bf3bd4de14e7a296
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2488543Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819852}
parent 804284af
......@@ -1213,18 +1213,44 @@ Response InputHandler::EmulateTouchFromMouseEvent(const std::string& type,
if (!host_ || !host_->GetRenderWidgetHost())
return Response::InternalError();
base::OnceCallback<void(bool)> forward_event_func;
if (wheel_event) {
host_->GetRenderWidgetHost()->ForwardWheelEvent(*wheel_event);
// Send a synthetic wheel event with phaseEnded to finish scrolling.
wheel_event->delta_x = 0;
wheel_event->delta_y = 0;
wheel_event->phase = blink::WebMouseWheelEvent::kPhaseEnded;
wheel_event->dispatch_type =
blink::WebInputEvent::DispatchType::kEventNonBlocking;
host_->GetRenderWidgetHost()->ForwardWheelEvent(*wheel_event);
forward_event_func = base::BindOnce(
[](base::WeakPtr<InputHandler> self, RenderWidgetHostImpl* widget_host,
blink::WebMouseWheelEvent* event,
ui::WebScopedInputEvent event_deleter, bool success) {
if (!self.get())
return;
widget_host->ForwardWheelEvent(*event);
// Send a synthetic wheel event with phaseEnded to finish scrolling.
event->delta_x = 0;
event->delta_y = 0;
event->phase = blink::WebMouseWheelEvent::kPhaseEnded;
event->dispatch_type =
blink::WebInputEvent::DispatchType::kEventNonBlocking;
widget_host->ForwardWheelEvent(*event);
},
weak_factory_.GetWeakPtr(), host_->GetRenderWidgetHost(), wheel_event,
std::move(event));
} else {
host_->GetRenderWidgetHost()->ForwardMouseEvent(*mouse_event);
}
forward_event_func = base::BindOnce(
[](base::WeakPtr<InputHandler> self, RenderWidgetHostImpl* widget_host,
blink::WebMouseEvent* event, ui::WebScopedInputEvent event_deleter,
bool success) {
if (!self.get())
return;
widget_host->ForwardMouseEvent(*event);
},
weak_factory_.GetWeakPtr(), host_->GetRenderWidgetHost(), mouse_event,
std::move(event));
}
// We make sure the compositor is up to date before sending a mouse event.
// Otherwise it wont be picked up by newly added event listeners on the main
// thread.
host_->GetRenderWidgetHost()->InsertVisualStateCallback(
std::move(forward_event_func));
return Response::Success();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment