| 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 bceb702cfeb4c991d2501f2ec1ad72a6458b355d..648448520d9167098941bd649bb643677d5c068f 100644
|
| --- a/content/browser/renderer_host/render_widget_host_impl.cc
|
| +++ b/content/browser/renderer_host/render_widget_host_impl.cc
|
| @@ -29,6 +29,7 @@
|
| #include "content/browser/renderer_host/render_view_host_impl.h"
|
| #include "content/browser/renderer_host/render_widget_helper.h"
|
| #include "content/browser/renderer_host/render_widget_host_delegate.h"
|
| +#include "content/browser/renderer_host/smooth_scroll_gesture_controller.h"
|
| #include "content/browser/renderer_host/tap_suppression_controller.h"
|
| #include "content/browser/renderer_host/touch_event_queue.h"
|
| #include "content/common/accessibility_messages.h"
|
| @@ -36,7 +37,6 @@
|
| #include "content/common/gpu/gpu_messages.h"
|
| #include "content/common/view_messages.h"
|
| #include "content/port/browser/render_widget_host_view_port.h"
|
| -#include "content/port/browser/smooth_scroll_gesture.h"
|
| #include "content/public/browser/compositor_util.h"
|
| #include "content/public/browser/native_web_keyboard_event.h"
|
| #include "content/public/browser/notification_service.h"
|
| @@ -87,9 +87,6 @@ namespace {
|
| // This timeout impacts the "choppiness" of our window resize perf.
|
| const int kPaintMsgTimeoutMS = 50;
|
|
|
| -// How many milliseconds apart synthetic scroll messages should be sent.
|
| -static const int kSyntheticScrollMessageIntervalMs = 8;
|
| -
|
| // Returns |true| if the two wheel events should be coalesced.
|
| bool ShouldCoalesceMouseWheelEvents(const WebMouseWheelEvent& last_event,
|
| const WebMouseWheelEvent& new_event) {
|
| @@ -164,7 +161,7 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
|
| allow_privileged_mouse_lock_(false),
|
| has_touch_handler_(false),
|
| ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
|
| - tick_active_smooth_scroll_gestures_task_posted_(false),
|
| + smooth_scroll_gesture_controller_(new SmoothScrollGestureController()),
|
| touch_event_queue_(new TouchEventQueue(this)),
|
| gesture_event_filter_(new GestureEventFilter(this)) {
|
| CHECK(delegate_);
|
| @@ -291,7 +288,7 @@ void RenderWidgetHostImpl::SendScreenRects() {
|
| }
|
|
|
| int RenderWidgetHostImpl::SyntheticScrollMessageInterval() const {
|
| - return kSyntheticScrollMessageIntervalMs;
|
| + return smooth_scroll_gesture_controller_->SyntheticScrollMessageInterval();
|
| }
|
|
|
| void RenderWidgetHostImpl::SetOverscrollControllerEnabled(bool enabled) {
|
| @@ -1175,6 +1172,7 @@ void RenderWidgetHostImpl::ForwardInputEvent(const WebInputEvent& input_event,
|
| coalesced_mouse_wheel_events_.clear();
|
| }
|
|
|
| + smooth_scroll_gesture_controller_->OnForwardInputEvent();
|
| SendInputEvent(input_event, event_size, is_keyboard_shortcut);
|
|
|
| // Any input event cancels a pending mouse move event. Note that
|
| @@ -1722,11 +1720,7 @@ void RenderWidgetHostImpl::OnInputEventAck(
|
| if (decrement_in_flight_event_count() == 0)
|
| StopHangMonitorTimeout();
|
|
|
| - // If an input ack is pending, then hold off ticking the gesture
|
| - // until we get an input ack.
|
| - if (in_process_event_types_.empty() &&
|
| - !active_smooth_scroll_gestures_.empty())
|
| - TickActiveSmoothScrollGesture();
|
| + smooth_scroll_gesture_controller_->OnInputEventACK(this);
|
|
|
| int type = static_cast<int>(event_type);
|
| if (type < WebInputEvent::Undefined) {
|
| @@ -1766,89 +1760,12 @@ void RenderWidgetHostImpl::OnInputEventAck(
|
| }
|
|
|
| void RenderWidgetHostImpl::OnBeginSmoothScroll(
|
| - int gesture_id, const ViewHostMsg_BeginSmoothScroll_Params ¶ms) {
|
| + const ViewHostMsg_BeginSmoothScroll_Params& params,
|
| + bool* smooth_scroll_started) {
|
| if (!view_)
|
| return;
|
| - active_smooth_scroll_gestures_.insert(
|
| - std::make_pair(gesture_id,
|
| - view_->CreateSmoothScrollGesture(
|
| - params.scroll_down, params.pixels_to_scroll,
|
| - params.mouse_event_x, params.mouse_event_y)));
|
| -
|
| - // If an input ack is pending, then hold off ticking the gesture
|
| - // until we get an input ack.
|
| - if (!in_process_event_types_.empty())
|
| - return;
|
| - if (tick_active_smooth_scroll_gestures_task_posted_)
|
| - return;
|
| - TickActiveSmoothScrollGesture();
|
| -}
|
| -
|
| -void RenderWidgetHostImpl::TickActiveSmoothScrollGesture() {
|
| - TRACE_EVENT0("input", "RenderWidgetHostImpl::TickActiveSmoothScrollGesture");
|
| - tick_active_smooth_scroll_gestures_task_posted_ = false;
|
| - if (active_smooth_scroll_gestures_.empty()) {
|
| - TRACE_EVENT_INSTANT0("input", "EarlyOut_NoActiveScrollGesture");
|
| - return;
|
| - }
|
| -
|
| - base::TimeTicks now = TimeTicks::HighResNow();
|
| - base::TimeDelta preferred_interval =
|
| - base::TimeDelta::FromMilliseconds(kSyntheticScrollMessageIntervalMs);
|
| - base::TimeDelta time_until_next_ideal_interval =
|
| - (last_smooth_scroll_gestures_tick_time_ + preferred_interval) -
|
| - now;
|
| - if (time_until_next_ideal_interval.InMilliseconds() > 0) {
|
| - TRACE_EVENT_INSTANT1(
|
| - "input", "EarlyOut_TickedTooRecently",
|
| - "delay", time_until_next_ideal_interval.InMilliseconds());
|
| - // Post a task.
|
| - tick_active_smooth_scroll_gestures_task_posted_ = true;
|
| - MessageLoop::current()->PostDelayedTask(
|
| - FROM_HERE,
|
| - base::Bind(&RenderWidgetHostImpl::TickActiveSmoothScrollGesture,
|
| - weak_factory_.GetWeakPtr()),
|
| - time_until_next_ideal_interval);
|
| - return;
|
| - }
|
| -
|
| - last_smooth_scroll_gestures_tick_time_ = now;
|
| -
|
| - // Separate ticking of gestures from sending their completion messages.
|
| - std::vector<int> ids_that_are_done;
|
| - for (SmoothScrollGestureMap::iterator it =
|
| - active_smooth_scroll_gestures_.begin();
|
| - it != active_smooth_scroll_gestures_.end();
|
| - ++it) {
|
| -
|
| - bool active = it->second->ForwardInputEvents(now, this);
|
| - if (!active)
|
| - ids_that_are_done.push_back(it->first);
|
| - }
|
| -
|
| - // Delete completed gestures and send their completion event.
|
| - for(size_t i = 0; i < ids_that_are_done.size(); i++) {
|
| - int id = ids_that_are_done[i];
|
| - SmoothScrollGestureMap::iterator it =
|
| - active_smooth_scroll_gestures_.find(id);
|
| - DCHECK(it != active_smooth_scroll_gestures_.end());
|
| - active_smooth_scroll_gestures_.erase(it);
|
| -
|
| - Send(new ViewMsg_SmoothScrollCompleted(routing_id_, id));
|
| - }
|
| -
|
| - // No need to post the next tick if an input is in flight.
|
| - if (!in_process_event_types_.empty())
|
| - return;
|
| -
|
| - TRACE_EVENT_INSTANT1("input", "PostTickTask",
|
| - "delay", preferred_interval.InMilliseconds());
|
| - tick_active_smooth_scroll_gestures_task_posted_ = true;
|
| - MessageLoop::current()->PostDelayedTask(
|
| - FROM_HERE,
|
| - base::Bind(&RenderWidgetHostImpl::TickActiveSmoothScrollGesture,
|
| - weak_factory_.GetWeakPtr()),
|
| - preferred_interval);
|
| + *smooth_scroll_started =
|
| + smooth_scroll_gesture_controller_->OnBeginSmoothScroll(view_, params);
|
| }
|
|
|
| void RenderWidgetHostImpl::OnSelectRangeAck() {
|
|
|