Stop counting flings in Android gesture listener
This patch changes the Android GestureListenerManagerImpl class to track
ongoing flings as a binary on/off switch, rather than counting
outstanding GestureFlingStarts.
This was previously an integer count as the flings would be processed in
the renderer so the start/end were asynchronous. Now that fling has been
moved into the browser process, we can be immediately sure there's at
most one fling running at any given time.
The attached bug was reproducing because fling boosting
GestureFlingStart events would ACK as consumed [1] to the
GestureListenerManagerImpl class but they wouldn't cause a
GestureFlingEnd. This meant the class would accumulate outstanding
gesture flings, preventing a resize from the URL bar [2] because the class
believed we were still in a scroll.
[1] FlingControllerFilterEvent in InputRouterImpl::SendGestureEvent
[2] GestureStateListener:onScrollingStateChanged in Tab.java
Bug: 848122
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I69508c3eae88bd528236d7f21cb75136d5f8cc2d
Reviewed-on: https://chromium-review.googlesource.com/1112776
Commit-Queue: David Bokan <[email protected]>
Reviewed-by: Bo <[email protected]>
Reviewed-by: Sadrul Chowdhury <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#573200}
diff --git a/ui/android/event_forwarder.cc b/ui/android/event_forwarder.cc
index 74e29f4..aa6d68e 100644
--- a/ui/android/event_forwarder.cc
+++ b/ui/android/event_forwarder.cc
@@ -153,7 +153,8 @@
ScalePoint(view_->GetLocationOnScreen(x, y), 1.f / dip_scale);
return view_->OnGestureEvent(GestureEventAndroid(
type, gfx::PointF(x / dip_scale, y / dip_scale), root_location, time_ms,
- scale, 0, 0, 0, 0, false, false));
+ scale, 0, 0, 0, 0, /*target_viewport*/ false, /*synthetic_scroll*/ false,
+ /*prevent_boosting*/ false));
}
jboolean EventForwarder::OnGenericMotionEvent(
@@ -207,7 +208,8 @@
float dip_scale = view_->GetDipScale();
view_->OnGestureEvent(GestureEventAndroid(
GESTURE_EVENT_TYPE_DOUBLE_TAP, gfx::PointF(x / dip_scale, y / dip_scale),
- gfx::PointF(), time_ms, 0, 0, 0, 0, 0, true, false));
+ gfx::PointF(), time_ms, 0, 0, 0, 0, 0, /*target_viewport*/ true,
+ /*synthetic_scroll*/ false, /*prevent_boosting*/ false));
}
void EventForwarder::StartFling(JNIEnv* env,
@@ -215,25 +217,31 @@
jlong time_ms,
jfloat velocity_x,
jfloat velocity_y,
- jboolean synthetic_scroll) {
- CancelFling(env, jobj, time_ms);
+ jboolean synthetic_scroll,
+ jboolean prevent_boosting) {
+ CancelFling(env, jobj, time_ms, prevent_boosting);
+
if (velocity_x == 0 && velocity_y == 0)
return;
// Use velocity as delta in scroll event.
view_->OnGestureEvent(GestureEventAndroid(
GESTURE_EVENT_TYPE_SCROLL_START, gfx::PointF(), gfx::PointF(), time_ms, 0,
- velocity_x, velocity_y, 0, 0, true, synthetic_scroll));
+ velocity_x, velocity_y, 0, 0, /*target_viewport*/ true, synthetic_scroll,
+ /*prevent_boosting*/ false));
view_->OnGestureEvent(GestureEventAndroid(
GESTURE_EVENT_TYPE_FLING_START, gfx::PointF(), gfx::PointF(), time_ms, 0,
- 0, 0, velocity_x, velocity_y, true, synthetic_scroll));
+ 0, 0, velocity_x, velocity_y, /*target_viewport*/ true, synthetic_scroll,
+ /*prevent_boosting*/ false));
}
void EventForwarder::CancelFling(JNIEnv* env,
const JavaParamRef<jobject>& jobj,
- jlong time_ms) {
- view_->OnGestureEvent(
- GestureEventAndroid(GESTURE_EVENT_TYPE_FLING_CANCEL, gfx::PointF(),
- gfx::PointF(), time_ms, 0, 0, 0, 0, 0, false, false));
+ jlong time_ms,
+ jboolean prevent_boosting) {
+ view_->OnGestureEvent(GestureEventAndroid(
+ GESTURE_EVENT_TYPE_FLING_CANCEL, gfx::PointF(), gfx::PointF(), time_ms, 0,
+ 0, 0, 0, 0,
+ /*target_viewport*/ false, /*synthetic_scroll*/ false, prevent_boosting));
}
} // namespace ui