Skip to content

Commit

Permalink
Use Blink's flag to prevent fling boosting.
Browse files Browse the repository at this point in the history
This flag prevents the flingCancel event from being used
as a part of a fling boost event sequence.
The synthetic FlingCancel method works properly now and cancels flings
instantly, without deferring flingCancel event.

See: https://codereview.chromium.org/789223002

BUG=440886

Review URL: https://codereview.chromium.org/792833002

Cr-Commit-Position: refs/heads/master@{#308599}
  • Loading branch information
wjarosik authored and Commit bot committed Dec 16, 2014
1 parent a6fbe42 commit b6c0ec4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions content/browser/android/content_view_core_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,8 @@ void ContentViewCoreImpl::FlingStart(JNIEnv* env, jobject obj, jlong time_ms,
void ContentViewCoreImpl::FlingCancel(JNIEnv* env, jobject obj, jlong time_ms) {
WebGestureEvent event = MakeGestureEvent(
WebInputEvent::GestureFlingCancel, time_ms, 0, 0);
event.data.flingCancel.preventBoosting = true;

SendGestureEvent(event);
}

Expand Down
3 changes: 3 additions & 0 deletions content/renderer/input/input_handler_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ bool InputHandlerProxy::FilterInputEventForFlingBoosting(
const WebGestureEvent& gesture_event =
static_cast<const WebGestureEvent&>(event);
if (gesture_event.type == WebInputEvent::GestureFlingCancel) {
if (gesture_event.data.flingCancel.preventBoosting)
return false;

if (current_fling_velocity_.LengthSquared() < kMinBoostFlingSpeedSquare)
return false;

Expand Down
20 changes: 20 additions & 0 deletions content/renderer/input/input_handler_proxy_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,26 @@ TEST_F(InputHandlerProxyTest, NoFlingBoostIfFlingTooSlow) {
VERIFY_AND_RESET_MOCKS();
}

TEST_F(InputHandlerProxyTest, NoFlingBoostIfPreventBoostingFlagIsSet) {
base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
base::TimeTicks time = base::TimeTicks() + dt;
WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
WebPoint fling_point = WebPoint(7, 13);

StartFling(
time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point);

EXPECT_CALL(mock_input_handler_, ScrollEnd());

// Cancel the fling. The fling cancellation should not be deferred because of
// prevent boosting flag set.
gesture_.data.flingCancel.preventBoosting = true;
time += dt;
CancelFling(time);

// VERIFY_AND_RESET_MOCKS already called by CancelFling
}

TEST_F(InputHandlerProxyTest, FlingBoostTerminatedDuringScrollSequence) {
base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
base::TimeTicks time = base::TimeTicks() + dt;
Expand Down

0 comments on commit b6c0ec4

Please sign in to comment.