Commit 92801d31 authored by jdduke's avatar jdduke Committed by Commit bot

[Android] Properly filter GestureFlingCancel events

The browser will drop GestureFlingCancel events when it believes the
renderer has no active fling animations. However, this filtering would
report the event as "consumed", inadverently triggering tap suppression
logic for the subsequent tap.

Instead, report "no consumer exists" for the filtered GestureFlingCancel
events, avoiding spurious tap suppression.

BUG=474882

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

Cr-Commit-Position: refs/heads/master@{#324288}
parent 057915a0
...@@ -552,36 +552,42 @@ void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event, ...@@ -552,36 +552,42 @@ void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event,
} }
} }
bool ContentViewCoreImpl::FilterInputEvent(const blink::WebInputEvent& event) { InputEventAckState ContentViewCoreImpl::FilterInputEvent(
const blink::WebInputEvent& event) {
if (event.type != WebInputEvent::GestureTap && if (event.type != WebInputEvent::GestureTap &&
event.type != WebInputEvent::GestureDoubleTap && event.type != WebInputEvent::GestureDoubleTap &&
event.type != WebInputEvent::GestureLongTap && event.type != WebInputEvent::GestureLongTap &&
event.type != WebInputEvent::GestureLongPress && event.type != WebInputEvent::GestureLongPress &&
event.type != WebInputEvent::GestureFlingCancel) event.type != WebInputEvent::GestureFlingCancel) {
return false; return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
}
JNIEnv* env = AttachCurrentThread(); JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
if (j_obj.is_null()) if (j_obj.is_null())
return false; return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
if (event.type == WebInputEvent::GestureFlingCancel) { if (event.type == WebInputEvent::GestureFlingCancel) {
// If no fling is active, either in the compositor or externally-driven, // If no fling is active, either in the compositor or externally-driven,
// there's no need to explicitly cancel the fling. // there's no need to explicitly cancel the fling.
bool may_need_fling_cancel = bool may_need_fling_cancel =
Java_ContentViewCore_isScrollInProgress(env, j_obj.obj()); Java_ContentViewCore_isScrollInProgress(env, j_obj.obj());
return !may_need_fling_cancel; return may_need_fling_cancel ? INPUT_EVENT_ACK_STATE_NOT_CONSUMED
: INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
} }
const blink::WebGestureEvent& gesture = const blink::WebGestureEvent& gesture =
static_cast<const blink::WebGestureEvent&>(event); static_cast<const blink::WebGestureEvent&>(event);
int gesture_type = ToGestureEventType(event.type); int gesture_type = ToGestureEventType(event.type);
return Java_ContentViewCore_filterTapOrPressEvent(env, if (Java_ContentViewCore_filterTapOrPressEvent(env,
j_obj.obj(), j_obj.obj(),
gesture_type, gesture_type,
gesture.x * dpi_scale(), gesture.x * dpi_scale(),
gesture.y * dpi_scale()); gesture.y * dpi_scale())) {
return INPUT_EVENT_ACK_STATE_CONSUMED;
}
return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
// TODO(jdduke): Also report double-tap UMA, crbug/347568. // TODO(jdduke): Also report double-tap UMA, crbug/347568.
} }
......
...@@ -239,7 +239,7 @@ class ContentViewCoreImpl : public ContentViewCore, ...@@ -239,7 +239,7 @@ class ContentViewCoreImpl : public ContentViewCore,
bool HasFocus(); bool HasFocus();
void OnGestureEventAck(const blink::WebGestureEvent& event, void OnGestureEventAck(const blink::WebGestureEvent& event,
InputEventAckState ack_result); InputEventAckState ack_result);
bool FilterInputEvent(const blink::WebInputEvent& event); InputEventAckState FilterInputEvent(const blink::WebInputEvent& event);
void OnSelectionChanged(const std::string& text); void OnSelectionChanged(const std::string& text);
void OnSelectionEvent(ui::SelectionEventType event, void OnSelectionEvent(ui::SelectionEventType event,
const gfx::PointF& anchor_position); const gfx::PointF& anchor_position);
......
...@@ -1686,9 +1686,12 @@ InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent( ...@@ -1686,9 +1686,12 @@ InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent(
return INPUT_EVENT_ACK_STATE_CONSUMED; return INPUT_EVENT_ACK_STATE_CONSUMED;
} }
if (content_view_core_ && if (content_view_core_) {
content_view_core_->FilterInputEvent(input_event)) InputEventAckState ack_result =
return INPUT_EVENT_ACK_STATE_CONSUMED; content_view_core_->FilterInputEvent(input_event);
if (ack_result != INPUT_EVENT_ACK_STATE_NOT_CONSUMED)
return ack_result;
}
if (!host_) if (!host_)
return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
......
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