diff options
author | alexclarke <alexclarke@chromium.org> | 2015-08-18 03:43:14 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-18 10:43:55 +0000 |
commit | 20301011d994428bf5850842ae9c18bde9d24674 (patch) | |
tree | cd8f2991d14f73050bfc0992d84fb08a72f45ea4 | |
parent | ed0b72afc13b0bee0c49cebae912d57835dbb0ea (diff) | |
download | chromium_src-20301011d994428bf5850842ae9c18bde9d24674.zip chromium_src-20301011d994428bf5850842ae9c18bde9d24674.tar.gz chromium_src-20301011d994428bf5850842ae9c18bde9d24674.tar.bz2 |
Make synthesizeScrollGesture repetable and emit interaction markers
Adds new optional parameters to Input.synthesizeScrollGesture to make it
possible to generate repeating scrolls from the browser process. This
functionality will be used by smoothness.scrolling_tough_ad_cases.
Patch 1 of 4 to fix the overly long delay between
each scroll in smoothness.scrolling_tough_ad_cases caused by the render
thread being unresponsive.
Patch 2: https://codereview.chromium.org/1296993002/
Patch 3: https://codereview.chromium.org/1291513004/
Patch 4: https://codereview.chromium.org/1285133008/
BUG=510398
Review URL: https://codereview.chromium.org/1299643004
Cr-Commit-Position: refs/heads/master@{#343878}
-rw-r--r-- | content/browser/devtools/protocol/input_handler.cc | 75 | ||||
-rw-r--r-- | content/browser/devtools/protocol/input_handler.h | 30 |
2 files changed, 102 insertions, 3 deletions
diff --git a/content/browser/devtools/protocol/input_handler.cc b/content/browser/devtools/protocol/input_handler.cc index fb24b02..d5b2d8b 100644 --- a/content/browser/devtools/protocol/input_handler.cc +++ b/content/browser/devtools/protocol/input_handler.cc @@ -4,8 +4,10 @@ #include "content/browser/devtools/protocol/input_handler.h" +#include "base/message_loop/message_loop.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/trace_event/trace_event.h" #include "cc/output/compositor_frame_metadata.h" #include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/common/input/synthetic_pinch_gesture_params.h" @@ -346,6 +348,25 @@ Response InputHandler::SynthesizeScrollGesture( const bool* prevent_fling, const int* speed, const std::string* gesture_source_type) { + return SynthesizeScrollGesture( + command_id, x, y, x_distance, y_distance, x_overscroll, y_overscroll, + prevent_fling, speed, gesture_source_type, nullptr, nullptr, nullptr); +} + +Response InputHandler::SynthesizeScrollGesture( + DevToolsCommandId command_id, + int x, + int y, + const int* x_distance, + const int* y_distance, + const int* x_overscroll, + const int* y_overscroll, + const bool* prevent_fling, + const int* speed, + const std::string* gesture_source_type, + const int* repeat_count, + const int* repeat_delay_ms, + const std::string* interaction_marker_name) { if (!host_) return Response::ServerError("Could not connect to view"); @@ -378,12 +399,60 @@ Response InputHandler::SynthesizeScrollGesture( return Response::InvalidParams("gestureSourceType"); } + SynthesizeRepeatingScroll( + gesture_params, repeat_count ? *repeat_count : 0, + base::TimeDelta::FromMilliseconds(repeat_delay_ms ? *repeat_delay_ms + : 250), + interaction_marker_name ? *interaction_marker_name : "", command_id); + + return Response::OK(); +} + +void InputHandler::SynthesizeRepeatingScroll( + SyntheticSmoothScrollGestureParams gesture_params, + int repeat_count, + base::TimeDelta repeat_delay, + std::string interaction_marker_name, + DevToolsCommandId command_id) { + if (!interaction_marker_name.empty()) { + // Telemetry expects the interaction markers to be in the blink.console + // category. + // TODO(alexclarke): Can we move this elsewhere? It doesn't really fit here. + TRACE_EVENT_COPY_ASYNC_BEGIN0("blink.console", + interaction_marker_name.c_str(), command_id); + } + host_->QueueSyntheticGesture( SyntheticGesture::Create(gesture_params), - base::Bind(&InputHandler::SendSynthesizeScrollGestureResponse, - weak_factory_.GetWeakPtr(), command_id)); + base::Bind(&InputHandler::OnScrollFinished, weak_factory_.GetWeakPtr(), + gesture_params, repeat_count, repeat_delay, + interaction_marker_name, command_id)); +} - return Response::OK(); +void InputHandler::OnScrollFinished( + SyntheticSmoothScrollGestureParams gesture_params, + int repeat_count, + base::TimeDelta repeat_delay, + std::string interaction_marker_name, + DevToolsCommandId command_id, + SyntheticGesture::Result result) { + if (!interaction_marker_name.empty()) { + // Telemetry expects the interaction markers to be in the blink.console + // category. + TRACE_EVENT_COPY_ASYNC_END0("blink.console", + interaction_marker_name.c_str(), command_id); + } + + if (repeat_count > 0) { + base::MessageLoop::current()->task_runner()->PostDelayedTask( + FROM_HERE, + base::Bind(&InputHandler::SynthesizeRepeatingScroll, + weak_factory_.GetWeakPtr(), gesture_params, repeat_count - 1, + repeat_delay, interaction_marker_name, command_id), + repeat_delay); + } else { + SendSynthesizeScrollGestureResponse(command_id, result); + } } Response InputHandler::SynthesizeTapGesture( diff --git a/content/browser/devtools/protocol/input_handler.h b/content/browser/devtools/protocol/input_handler.h index c4de078..edebfa1 100644 --- a/content/browser/devtools/protocol/input_handler.h +++ b/content/browser/devtools/protocol/input_handler.h @@ -8,6 +8,7 @@ #include "base/memory/weak_ptr.h" #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" #include "content/browser/renderer_host/input/synthetic_gesture.h" +#include "content/common/input/synthetic_smooth_scroll_gesture_params.h" #include "ui/gfx/geometry/size_f.h" namespace cc { @@ -75,6 +76,7 @@ class InputHandler { const int* relative_speed, const std::string* gesture_source_type); + // TODO(alexclarke): remove this once the protocol patch lands. Response SynthesizeScrollGesture(DevToolsCommandId command_id, int x, int y, @@ -86,6 +88,20 @@ class InputHandler { const int* speed, const std::string* gesture_source_type); + Response SynthesizeScrollGesture(DevToolsCommandId command_id, + int x, + int y, + const int* x_distance, + const int* y_distance, + const int* x_overscroll, + const int* y_overscroll, + const bool* prevent_fling, + const int* speed, + const std::string* gesture_source_type, + const int* repeat_count, + const int* repeat_delay_ms, + const std::string* interaction_marker_name); + Response SynthesizeTapGesture(DevToolsCommandId command_id, int x, int y, @@ -104,6 +120,20 @@ class InputHandler { bool send_success, SyntheticGesture::Result result); + void SynthesizeRepeatingScroll( + SyntheticSmoothScrollGestureParams gesture_params, + int repeat_count, + base::TimeDelta repeat_delay, + std::string interaction_marker_name, + DevToolsCommandId command_id); + + void OnScrollFinished(SyntheticSmoothScrollGestureParams gesture_params, + int repeat_count, + base::TimeDelta repeat_delay, + std::string interaction_marker_name, + DevToolsCommandId command_id, + SyntheticGesture::Result result); + RenderWidgetHostImpl* host_; scoped_ptr<Client> client_; float page_scale_factor_; |