Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: content/common/input/touch_event_stream_validator.cc

Issue 537733003: [Android] Enable input event stream validation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review and fix tests Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/input/touch_event_stream_validator.cc
diff --git a/content/common/input/touch_event_stream_validator.cc b/content/common/input/touch_event_stream_validator.cc
index 85bc469443315e516f26d4b362b75fdbd1146903..3310036c5b430de3134e38b18d8d5cd1c6076750 100644
--- a/content/common/input/touch_event_stream_validator.cc
+++ b/content/common/input/touch_event_stream_validator.cc
@@ -38,6 +38,14 @@ bool TouchEventStreamValidator::Validate(const WebTouchEvent& event,
WebTouchEvent previous_event = previous_event_;
previous_event_ = event;
+ if (!event.touchesLength) {
+ error_msg->append("Touch event is empty.\n");
+ return false;
+ }
+
+ if (!WebInputEvent::isTouchEventType(event.type))
+ error_msg->append("Touch event has invalid type.\n");
+
// Allow "hard" restarting of touch stream validation. This is necessary
// in cases where touch event forwarding ceases in response to the event ack
// or removal of touch handlers.
@@ -56,6 +64,7 @@ bool TouchEventStreamValidator::Validate(const WebTouchEvent& event,
error_msg->append("Previously active touch point not in new event.\n");
}
+ bool found_valid_state_for_type = false;
for (unsigned i = 0; i < event.touchesLength; ++i) {
const WebTouchPoint& point = event.touches[i];
const WebTouchPoint* previous_point =
@@ -81,16 +90,22 @@ bool TouchEventStreamValidator::Validate(const WebTouchEvent& event,
case WebTouchPoint::StateReleased:
if (event.type != WebInputEvent::TouchEnd)
error_msg->append("Released touch point outside touchend.\n");
+ else
+ found_valid_state_for_type = true;
break;
case WebTouchPoint::StatePressed:
if (event.type != WebInputEvent::TouchStart)
error_msg->append("Pressed touch point outside touchstart.\n");
+ else
+ found_valid_state_for_type = true;
break;
case WebTouchPoint::StateMoved:
if (event.type != WebInputEvent::TouchMove)
error_msg->append("Moved touch point outside touchmove.\n");
+ else
+ found_valid_state_for_type = true;
break;
case WebTouchPoint::StateStationary:
@@ -99,9 +114,15 @@ bool TouchEventStreamValidator::Validate(const WebTouchEvent& event,
case WebTouchPoint::StateCancelled:
if (event.type != WebInputEvent::TouchCancel)
error_msg->append("Cancelled touch point outside touchcancel.\n");
+ else
+ found_valid_state_for_type = true;
break;
}
}
+
+ if (!found_valid_state_for_type)
+ error_msg->append("No valid touch point corresponding to event type.");
+
return error_msg->empty();
}
« no previous file with comments | « content/common/input/touch_event_stream_validator.h ('k') | content/common/input/touch_event_stream_validator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698