Commit 3c85191d authored by jdduke's avatar jdduke Committed by Commit bot

Allow synthetic Tap gestures without a preceding TapDown

While TapDown gestures are a typical part of the touch-gesture pipeline,
they are not required and probably even undesirable in the case of
synthetic Tap gestures (e.g., with tap disambiguation). Allow such
synthetic taps through the gesture stream validator.

BUG=414372

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

Cr-Commit-Position: refs/heads/master@{#295141}
parent 9858b4ad
...@@ -62,13 +62,19 @@ bool GestureEventStreamValidator::Validate(const blink::WebGestureEvent& event, ...@@ -62,13 +62,19 @@ bool GestureEventStreamValidator::Validate(const blink::WebGestureEvent& event,
error_msg->append("Missing tap end event\n"); error_msg->append("Missing tap end event\n");
waiting_for_tap_end_ = true; waiting_for_tap_end_ = true;
break; break;
case WebInputEvent::GestureTap: case WebInputEvent::GestureTapUnconfirmed:
if (!waiting_for_tap_end_)
error_msg->append("Missing TapDown event before TapUnconfirmed\n");
break;
case WebInputEvent::GestureTapCancel: case WebInputEvent::GestureTapCancel:
if (!waiting_for_tap_end_) if (!waiting_for_tap_end_)
error_msg->append("Missing GestureTapDown event\n"); error_msg->append("Missing TapDown event before TapCancel\n");
waiting_for_tap_end_ = false; waiting_for_tap_end_ = false;
break; break;
case WebInputEvent::GestureTap:
case WebInputEvent::GestureDoubleTap: case WebInputEvent::GestureDoubleTap:
// Both Tap and DoubleTap gestures may be synthetically inserted, and do
// not require a preceding TapDown.
waiting_for_tap_end_ = false; waiting_for_tap_end_ = false;
break; break;
default: default:
......
...@@ -165,7 +165,7 @@ TEST(GestureEventStreamValidator, ValidTap) { ...@@ -165,7 +165,7 @@ TEST(GestureEventStreamValidator, ValidTap) {
EXPECT_TRUE(validator.Validate(event, &error_msg)); EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty()); EXPECT_TRUE(error_msg.empty());
event = Build(WebInputEvent::GestureTap); event = Build(WebInputEvent::GestureTapCancel);
EXPECT_TRUE(validator.Validate(event, &error_msg)); EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty()); EXPECT_TRUE(error_msg.empty());
...@@ -173,11 +173,20 @@ TEST(GestureEventStreamValidator, ValidTap) { ...@@ -173,11 +173,20 @@ TEST(GestureEventStreamValidator, ValidTap) {
EXPECT_TRUE(validator.Validate(event, &error_msg)); EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty()); EXPECT_TRUE(error_msg.empty());
event = Build(WebInputEvent::GestureTapUnconfirmed);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
event = Build(WebInputEvent::GestureTapCancel); event = Build(WebInputEvent::GestureTapCancel);
EXPECT_TRUE(validator.Validate(event, &error_msg)); EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty()); EXPECT_TRUE(error_msg.empty());
// DoubleTap doesn't require a TapDown (unlike Tap and TapCancel). // Tap and DoubleTap do not require a TapDown (unlike TapUnconfirmed and
// TapCancel).
event = Build(WebInputEvent::GestureTap);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
event = Build(WebInputEvent::GestureDoubleTap); event = Build(WebInputEvent::GestureDoubleTap);
EXPECT_TRUE(validator.Validate(event, &error_msg)); EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty()); EXPECT_TRUE(error_msg.empty());
...@@ -189,7 +198,7 @@ TEST(GestureEventStreamValidator, InvalidTap) { ...@@ -189,7 +198,7 @@ TEST(GestureEventStreamValidator, InvalidTap) {
WebGestureEvent event; WebGestureEvent event;
// No preceding TapDown. // No preceding TapDown.
event = Build(WebInputEvent::GestureTap); event = Build(WebInputEvent::GestureTapUnconfirmed);
EXPECT_FALSE(validator.Validate(event, &error_msg)); EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty()); EXPECT_FALSE(error_msg.empty());
...@@ -209,6 +218,19 @@ TEST(GestureEventStreamValidator, InvalidTap) { ...@@ -209,6 +218,19 @@ TEST(GestureEventStreamValidator, InvalidTap) {
event = Build(WebInputEvent::GestureTapCancel); event = Build(WebInputEvent::GestureTapCancel);
EXPECT_FALSE(validator.Validate(event, &error_msg)); EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty()); EXPECT_FALSE(error_msg.empty());
// TapDown already terminated.
event = Build(WebInputEvent::GestureTapDown);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
event = Build(WebInputEvent::GestureTap);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
event = Build(WebInputEvent::GestureTapCancel);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
} }
} // namespace content } // namespace content
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