Commit 690a89ee authored by Dmitry Gozman's avatar Dmitry Gozman Committed by Commit Bot

[DevTools] Route synthetic gestures to OOPIF's widget hosts

This follows mouse and touch events in input handler.

Bug: 746266
Change-Id: I10e08dbc6af952e240e6426a145bf1257ccd93ae
Reviewed-on: https://chromium-review.googlesource.com/947470
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541019}
parent e10b1a04
...@@ -889,7 +889,16 @@ void InputHandler::SynthesizePinchGesture( ...@@ -889,7 +889,16 @@ void InputHandler::SynthesizePinchGesture(
return; return;
} }
host_->GetRenderWidgetHost()->QueueSyntheticGesture( gfx::PointF transformed;
RenderWidgetHostImpl* widget_host =
FindTargetWidgetHost(gesture_params.anchor, &transformed);
gesture_params.anchor = transformed;
if (!widget_host) {
callback->sendFailure(Response::InternalError());
return;
}
widget_host->QueueSyntheticGesture(
SyntheticGesture::Create(gesture_params), SyntheticGesture::Create(gesture_params),
base::BindOnce(&SendSynthesizePinchGestureResponse, std::move(callback))); base::BindOnce(&SendSynthesizePinchGestureResponse, std::move(callback)));
} }
...@@ -947,34 +956,50 @@ void InputHandler::SynthesizeScrollGesture( ...@@ -947,34 +956,50 @@ void InputHandler::SynthesizeScrollGesture(
return; return;
} }
gfx::PointF transformed;
RenderWidgetHostImpl* widget_host =
FindTargetWidgetHost(gesture_params.anchor, &transformed);
gesture_params.anchor = transformed;
if (!widget_host) {
callback->sendFailure(Response::InternalError());
return;
}
SynthesizeRepeatingScroll( SynthesizeRepeatingScroll(
gesture_params, repeat_count.fromMaybe(0), widget_host->GetWeakPtr(), gesture_params, repeat_count.fromMaybe(0),
base::TimeDelta::FromMilliseconds(repeat_delay_ms.fromMaybe(250)), base::TimeDelta::FromMilliseconds(repeat_delay_ms.fromMaybe(250)),
interaction_marker_name.fromMaybe(""), ++last_id_, std::move(callback)); interaction_marker_name.fromMaybe(""), ++last_id_, std::move(callback));
} }
void InputHandler::SynthesizeRepeatingScroll( void InputHandler::SynthesizeRepeatingScroll(
base::WeakPtr<RenderWidgetHostImpl> widget_host,
SyntheticSmoothScrollGestureParams gesture_params, SyntheticSmoothScrollGestureParams gesture_params,
int repeat_count, int repeat_count,
base::TimeDelta repeat_delay, base::TimeDelta repeat_delay,
std::string interaction_marker_name, std::string interaction_marker_name,
int id, int id,
std::unique_ptr<SynthesizeScrollGestureCallback> callback) { std::unique_ptr<SynthesizeScrollGestureCallback> callback) {
if (!widget_host) {
callback->sendFailure(Response::Error("Frame was detached"));
return;
}
if (!interaction_marker_name.empty()) { if (!interaction_marker_name.empty()) {
// TODO(alexclarke): Can we move this elsewhere? It doesn't really fit here. // TODO(alexclarke): Can we move this elsewhere? It doesn't really fit here.
TRACE_EVENT_COPY_ASYNC_BEGIN0("benchmark", interaction_marker_name.c_str(), TRACE_EVENT_COPY_ASYNC_BEGIN0("benchmark", interaction_marker_name.c_str(),
id); id);
} }
host_->GetRenderWidgetHost()->QueueSyntheticGesture( widget_host->QueueSyntheticGesture(
SyntheticGesture::Create(gesture_params), SyntheticGesture::Create(gesture_params),
base::BindOnce(&InputHandler::OnScrollFinished, base::BindOnce(&InputHandler::OnScrollFinished,
weak_factory_.GetWeakPtr(), gesture_params, repeat_count, weak_factory_.GetWeakPtr(), widget_host, gesture_params,
repeat_delay, interaction_marker_name, id, repeat_count, repeat_delay, interaction_marker_name, id,
std::move(callback))); std::move(callback)));
} }
void InputHandler::OnScrollFinished( void InputHandler::OnScrollFinished(
base::WeakPtr<RenderWidgetHostImpl> widget_host,
SyntheticSmoothScrollGestureParams gesture_params, SyntheticSmoothScrollGestureParams gesture_params,
int repeat_count, int repeat_count,
base::TimeDelta repeat_delay, base::TimeDelta repeat_delay,
...@@ -991,7 +1016,7 @@ void InputHandler::OnScrollFinished( ...@@ -991,7 +1016,7 @@ void InputHandler::OnScrollFinished(
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&InputHandler::SynthesizeRepeatingScroll, base::BindOnce(&InputHandler::SynthesizeRepeatingScroll,
weak_factory_.GetWeakPtr(), gesture_params, weak_factory_.GetWeakPtr(), widget_host, gesture_params,
repeat_count - 1, repeat_delay, interaction_marker_name, repeat_count - 1, repeat_delay, interaction_marker_name,
id, std::move(callback)), id, std::move(callback)),
repeat_delay); repeat_delay);
...@@ -1038,10 +1063,19 @@ void InputHandler::SynthesizeTapGesture( ...@@ -1038,10 +1063,19 @@ void InputHandler::SynthesizeTapGesture(
return; return;
} }
gfx::PointF transformed;
RenderWidgetHostImpl* widget_host =
FindTargetWidgetHost(gesture_params.position, &transformed);
gesture_params.position = transformed;
if (!widget_host) {
callback->sendFailure(Response::InternalError());
return;
}
TapGestureResponse* response = TapGestureResponse* response =
new TapGestureResponse(std::move(callback), count); new TapGestureResponse(std::move(callback), count);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
host_->GetRenderWidgetHost()->QueueSyntheticGesture( widget_host->QueueSyntheticGesture(
SyntheticGesture::Create(gesture_params), SyntheticGesture::Create(gesture_params),
base::BindOnce(&TapGestureResponse::OnGestureResult, base::BindOnce(&TapGestureResponse::OnGestureResult,
base::Unretained(response))); base::Unretained(response)));
......
...@@ -127,6 +127,7 @@ class InputHandler : public DevToolsDomainHandler, public Input::Backend { ...@@ -127,6 +127,7 @@ class InputHandler : public DevToolsDomainHandler, public Input::Backend {
class InputInjector; class InputInjector;
void SynthesizeRepeatingScroll( void SynthesizeRepeatingScroll(
base::WeakPtr<RenderWidgetHostImpl> widget_host,
SyntheticSmoothScrollGestureParams gesture_params, SyntheticSmoothScrollGestureParams gesture_params,
int repeat_count, int repeat_count,
base::TimeDelta repeat_delay, base::TimeDelta repeat_delay,
...@@ -135,6 +136,7 @@ class InputHandler : public DevToolsDomainHandler, public Input::Backend { ...@@ -135,6 +136,7 @@ class InputHandler : public DevToolsDomainHandler, public Input::Backend {
std::unique_ptr<SynthesizeScrollGestureCallback> callback); std::unique_ptr<SynthesizeScrollGestureCallback> callback);
void OnScrollFinished( void OnScrollFinished(
base::WeakPtr<RenderWidgetHostImpl> widget_host,
SyntheticSmoothScrollGestureParams gesture_params, SyntheticSmoothScrollGestureParams gesture_params,
int repeat_count, int repeat_count,
base::TimeDelta repeat_delay, base::TimeDelta repeat_delay,
......
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