Commit 23a8406b authored by jdduke@chromium.org's avatar jdduke@chromium.org

[Android] Provide unhandled tap event notifications

Allow notifications of unhandled taps via the GestureStateListener.  This change
makes GestureTap events blocking, but there are several use-cases for which this
will be necessary, e.g., WebView and contextual search.

NOTRY=true

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261431 0039d316-1c4b-4281-b951-d872f2087c98
parent 67bb9684
......@@ -615,6 +615,12 @@ void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event,
case WebInputEvent::GesturePinchEnd:
Java_ContentViewCore_onPinchEndEventAck(env, j_obj.obj());
break;
case WebInputEvent::GestureTap:
if (ack_result != INPUT_EVENT_ACK_STATE_CONSUMED) {
Java_ContentViewCore_onTapEventNotConsumed(
env, j_obj.obj(), event.x * dpi_scale(), event.y * dpi_scale());
}
break;
case WebInputEvent::GestureDoubleTap:
Java_ContentViewCore_onDoubleTapEventAck(env, j_obj.obj());
break;
......
......@@ -1285,12 +1285,17 @@ TEST_F(InputRouterImplTest, DoubleTapGestureDependsOnFirstTap) {
EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
// The GestureTapUnconfirmed is converted into a tap, as the touch action is
// auto.
// none.
SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed,
WebGestureEvent::Touchscreen);
EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
// This test will become invalid if GestureTap stops requiring an ack.
ASSERT_TRUE(!WebInputEventTraits::IgnoresAckDisposition(
WebInputEvent::GestureTap));
EXPECT_EQ(2, client_->in_flight_event_count());
SendInputEventACK(WebInputEvent::GestureTap,
INPUT_EVENT_ACK_STATE_CONSUMED);
EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
EXPECT_EQ(1, client_->in_flight_event_count());
// This tap gesture is dropped, since the GestureTapUnconfirmed was turned
// into a tap.
......@@ -1312,8 +1317,10 @@ TEST_F(InputRouterImplTest, DoubleTapGestureDependsOnFirstTap) {
SimulateGestureEvent(WebInputEvent::GestureDoubleTap,
WebGestureEvent::Touchscreen);
// This test will become invalid if GestureDoubleTap stops requiring an ack.
DCHECK(!WebInputEventTraits::IgnoresAckDisposition(
ASSERT_TRUE(!WebInputEventTraits::IgnoresAckDisposition(
WebInputEvent::GestureDoubleTap));
EXPECT_EQ(1, client_->in_flight_event_count());
SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED);
EXPECT_EQ(0, client_->in_flight_event_count());
}
......
......@@ -322,7 +322,6 @@ bool WebInputEventTraits::IgnoresAckDisposition(
case WebInputEvent::GestureTapDown:
case WebInputEvent::GestureShowPress:
case WebInputEvent::GestureTapCancel:
case WebInputEvent::GestureTap:
case WebInputEvent::GesturePinchBegin:
case WebInputEvent::GesturePinchEnd:
case WebInputEvent::GestureScrollBegin:
......
......@@ -1286,6 +1286,15 @@ public class ContentViewCore
updateGestureStateListener(GestureEventType.PINCH_END);
}
@SuppressWarnings("unused")
@CalledByNative
private void onTapEventNotConsumed(int x, int y) {
for (mGestureStateListenersIterator.rewind();
mGestureStateListenersIterator.hasNext();) {
mGestureStateListenersIterator.next().onUnhandledTapEvent(x, y);
}
}
@SuppressWarnings("unused")
@CalledByNative
private void onDoubleTapEventAck() {
......
......@@ -61,4 +61,9 @@ public class GestureStateListener {
* Called when the scroll offsets or extents may have changed.
*/
public void onScrollOffsetOrExtentChanged(int scrollOffsetY, int scrollExtentY) {}
/*
* Called when a tap event was not handled by the renderer.
*/
public void onUnhandledTapEvent(int x, int y) {}
}
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