1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/common/input/gesture_event_stream_validator.h"
7 #include "base/logging.h"
8 #include "third_party/WebKit/public/web/WebInputEvent.h"
10 using blink::WebInputEvent
;
14 GestureEventStreamValidator::GestureEventStreamValidator()
15 : scrolling_(false), pinching_(false), waiting_for_tap_end_(false) {
18 GestureEventStreamValidator::~GestureEventStreamValidator() {
21 bool GestureEventStreamValidator::Validate(const blink::WebGestureEvent
& event
,
22 std::string
* error_msg
) {
26 case WebInputEvent::GestureScrollBegin
:
27 if (scrolling_
|| pinching_
)
28 error_msg
->append("Scroll begin during scroll\n");
31 case WebInputEvent::GestureScrollUpdate
:
32 case WebInputEvent::GestureScrollUpdateWithoutPropagation
:
34 error_msg
->append("Scroll update outside of scroll\n");
36 case WebInputEvent::GestureScrollEnd
:
37 case WebInputEvent::GestureFlingStart
:
39 error_msg
->append("Scroll end outside of scroll\n");
41 error_msg
->append("Ending scroll while pinching\n");
44 case WebInputEvent::GesturePinchBegin
:
46 error_msg
->append("Pinch begin outside of scroll\n");
48 error_msg
->append("Pinch begin during pinch\n");
51 case WebInputEvent::GesturePinchUpdate
:
52 if (!pinching_
|| !scrolling_
)
53 error_msg
->append("Pinch update outside of pinch\n");
55 case WebInputEvent::GesturePinchEnd
:
56 if (!pinching_
|| !scrolling_
)
57 error_msg
->append("Pinch end outside of pinch\n");
60 case WebInputEvent::GestureTapDown
:
61 if (waiting_for_tap_end_
)
62 error_msg
->append("Missing tap end event\n");
63 waiting_for_tap_end_
= true;
65 case WebInputEvent::GestureTap
:
66 case WebInputEvent::GestureTapCancel
:
67 case WebInputEvent::GestureDoubleTap
:
68 if (!waiting_for_tap_end_
)
69 error_msg
->append("Missing GestureTapDown event\n");
70 waiting_for_tap_end_
= false;
75 return error_msg
->empty();
78 } // namespace content