Commit a7585d79 authored by chaopeng's avatar chaopeng Committed by Commit Bot

Ignored inertial scroll (fling) event should ignore in ReceivedEventACK()

An inertial scroll (fling) event from previous completed overscroll
gesture sequence should not modify scroll state in ReceivedEventACK().

Bug: 647140
Change-Id: I48c595124c7f0e2e37b92d256ab13dc50a1ec400
Reviewed-on: https://chromium-review.googlesource.com/1003214
Commit-Queue: Jianpeng Chao <chaopeng@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarMohsen Izadi <mohsen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549586}
parent f1baf9ec
......@@ -84,6 +84,19 @@ bool OverscrollController::ShouldProcessEvent(
return true;
}
bool OverscrollController::ShouldIgnoreInertialEvent(
const blink::WebInputEvent& event) const {
if (!ignore_following_inertial_events_ ||
event.GetType() != blink::WebInputEvent::kGestureScrollUpdate) {
return false;
}
const blink::WebGestureEvent& gesture =
static_cast<const blink::WebGestureEvent&>(event);
return gesture.data.scroll_update.inertial_phase ==
blink::WebGestureEvent::kMomentumPhase;
}
bool OverscrollController::WillHandleEvent(const blink::WebInputEvent& event) {
if (event.GetType() == blink::WebInputEvent::kGestureScrollBegin)
ignore_following_inertial_events_ = false;
......@@ -104,15 +117,8 @@ bool OverscrollController::WillHandleEvent(const blink::WebInputEvent& event) {
// Consume the scroll-update events if they are from a inertial scroll (fling)
// event that completed an overscroll gesture.
if (ignore_following_inertial_events_ &&
event.GetType() == blink::WebInputEvent::kGestureScrollUpdate) {
const blink::WebGestureEvent& gesture =
static_cast<const blink::WebGestureEvent&>(event);
if (gesture.data.scroll_update.inertial_phase ==
blink::WebGestureEvent::kMomentumPhase) {
return true;
}
}
if (ShouldIgnoreInertialEvent(event))
return true;
bool reset_scroll_state = false;
if (scroll_state_ != ScrollState::NONE || overscroll_delta_x_ ||
......@@ -175,6 +181,11 @@ void OverscrollController::ReceivedEventACK(const blink::WebInputEvent& event,
if (!ShouldProcessEvent(event))
return;
// An inertial scroll (fling) event from a completed overscroll gesture
// should not modify states below.
if (ShouldIgnoreInertialEvent(event))
return;
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,
......
......@@ -122,6 +122,9 @@ class CONTENT_EXPORT OverscrollController {
// triggered the overscroll gesture.
void SetOverscrollMode(OverscrollMode new_mode, OverscrollSource source);
// Whether this inertial event should be filtered out by the controller.
bool ShouldIgnoreInertialEvent(const blink::WebInputEvent& event) const;
// Whether this event should be processed or not handled by the controller.
bool ShouldProcessEvent(const blink::WebInputEvent& event);
......
......@@ -157,9 +157,9 @@ TEST_F(OverscrollControllerTest,
EXPECT_FALSE(SimulateGestureScrollUpdate(
100, 0, blink::kWebGestureDeviceTouchpad, true));
SimulateAck(false);
EXPECT_EQ(OVERSCROLL_EAST, controller_mode());
EXPECT_EQ(OverscrollSource::TOUCHPAD, controller_source());
EXPECT_EQ(OVERSCROLL_EAST, delegate()->current_mode());
EXPECT_EQ(OVERSCROLL_NONE, controller_mode());
EXPECT_EQ(OverscrollSource::NONE, controller_source());
EXPECT_EQ(OVERSCROLL_NONE, delegate()->current_mode());
EXPECT_EQ(OVERSCROLL_EAST, delegate()->completed_mode());
// Next Inertial update event would be consumed by overscroll controller.
......
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