| Index: content/browser/renderer_host/overscroll_controller.cc
|
| diff --git a/content/browser/renderer_host/overscroll_controller.cc b/content/browser/renderer_host/overscroll_controller.cc
|
| index 14a82e6fe9460b916bcf12559ba1caef9755cabd..b6cafe1adfcdd3a6704529340c8144ba929c2a3c 100644
|
| --- a/content/browser/renderer_host/overscroll_controller.cc
|
| +++ b/content/browser/renderer_host/overscroll_controller.cc
|
| @@ -16,6 +16,7 @@ OverscrollController::OverscrollController(
|
| RenderWidgetHostImpl* render_widget_host)
|
| : render_widget_host_(render_widget_host),
|
| overscroll_mode_(OVERSCROLL_NONE),
|
| + scroll_state_(STATE_UNKNOWN),
|
| overscroll_delta_x_(0.f),
|
| overscroll_delta_y_(0.f),
|
| delegate_(NULL) {
|
| @@ -27,6 +28,25 @@ OverscrollController::~OverscrollController() {
|
| bool OverscrollController::WillDispatchEvent(
|
| const WebKit::WebInputEvent& event,
|
| const cc::LatencyInfo& latency_info) {
|
| + if (scroll_state_ != STATE_UNKNOWN) {
|
| + if (event.type == WebKit::WebInputEvent::GestureScrollEnd) {
|
| + scroll_state_ = STATE_UNKNOWN;
|
| + } else if (event.type == WebKit::WebInputEvent::GestureFlingStart) {
|
| + // Start of a fling indicates the end of a scroll, both from touchpad and
|
| + // touchscreen. So it is not necessary to check |sourceDevice| of the
|
| + // event.
|
| + scroll_state_ = STATE_UNKNOWN;
|
| + } else if (event.type == WebKit::WebInputEvent::MouseWheel) {
|
| + const WebKit::WebMouseWheelEvent& wheel =
|
| + static_cast<const WebKit::WebMouseWheelEvent&>(event);
|
| + if (wheel.hasPreciseScrollingDeltas &&
|
| + (wheel.phase == WebKit::WebMouseWheelEvent::PhaseEnded ||
|
| + wheel.phase == WebKit::WebMouseWheelEvent::PhaseCancelled)) {
|
| + scroll_state_ = STATE_UNKNOWN;
|
| + }
|
| + }
|
| + }
|
| +
|
| if (DispatchEventCompletesAction(event)) {
|
| CompleteAction();
|
|
|
| @@ -79,14 +99,24 @@ bool OverscrollController::WillDispatchEvent(
|
|
|
| void OverscrollController::ReceivedEventACK(const WebKit::WebInputEvent& event,
|
| bool processed) {
|
| - if (processed)
|
| + if (processed) {
|
| + // If a scroll event is consumed by the page, i.e. some content on the page
|
| + // has been scrolled, then there is not going to be an overscroll gesture,
|
| + // until the current scroll ends, and a new scroll gesture starts.
|
| + if (scroll_state_ == STATE_UNKNOWN &&
|
| + (event.type == WebKit::WebInputEvent::MouseWheel ||
|
| + event.type == WebKit::WebInputEvent::GestureScrollUpdate)) {
|
| + scroll_state_ = STATE_CONTENT_SCROLLING;
|
| + }
|
| return;
|
| + }
|
| ProcessEventForOverscroll(event);
|
| }
|
|
|
| void OverscrollController::Reset() {
|
| overscroll_mode_ = OVERSCROLL_NONE;
|
| overscroll_delta_x_ = overscroll_delta_y_ = 0.f;
|
| + scroll_state_ = STATE_UNKNOWN;
|
| }
|
|
|
| bool OverscrollController::DispatchEventCompletesAction (
|
| @@ -177,10 +207,11 @@ void OverscrollController::ProcessEventForOverscroll(
|
| case WebKit::WebInputEvent::MouseWheel: {
|
| const WebKit::WebMouseWheelEvent& wheel =
|
| static_cast<const WebKit::WebMouseWheelEvent&>(event);
|
| - if (wheel.hasPreciseScrollingDeltas) {
|
| - ProcessOverscroll(wheel.deltaX * wheel.accelerationRatioX,
|
| - wheel.deltaY * wheel.accelerationRatioY);
|
| - }
|
| + if (!wheel.hasPreciseScrollingDeltas)
|
| + return;
|
| +
|
| + ProcessOverscroll(wheel.deltaX * wheel.accelerationRatioX,
|
| + wheel.deltaY * wheel.accelerationRatioY);
|
| break;
|
| }
|
| case WebKit::WebInputEvent::GestureScrollUpdate: {
|
| @@ -223,6 +254,8 @@ void OverscrollController::ProcessEventForOverscroll(
|
| }
|
|
|
| void OverscrollController::ProcessOverscroll(float delta_x, float delta_y) {
|
| + if (scroll_state_ == STATE_CONTENT_SCROLLING)
|
| + return;
|
| overscroll_delta_x_ += delta_x;
|
| overscroll_delta_y_ += delta_y;
|
|
|
| @@ -292,6 +325,8 @@ void OverscrollController::SetOverscrollMode(OverscrollMode mode) {
|
| overscroll_mode_ = mode;
|
| if (overscroll_mode_ == OVERSCROLL_NONE)
|
| overscroll_delta_x_ = overscroll_delta_y_ = 0.f;
|
| + else
|
| + scroll_state_ = STATE_OVERSCROLLING;
|
| if (delegate_)
|
| delegate_->OnOverscrollModeChange(old_mode, overscroll_mode_);
|
| }
|
|
|