| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/input/gesture_event_stream_validator.h" | 5 #include "content/common/input/gesture_event_stream_validator.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "third_party/WebKit/public/platform/WebGestureEvent.h" | 9 #include "third_party/WebKit/public/platform/WebGestureEvent.h" |
| 10 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 10 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 11 #include "ui/events/blink/web_input_event_traits.h" | 11 #include "ui/events/blink/web_input_event_traits.h" |
| 12 | 12 |
| 13 using blink::WebInputEvent; | 13 using blink::WebInputEvent; |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 GestureEventStreamValidator::GestureEventStreamValidator() | 17 GestureEventStreamValidator::GestureEventStreamValidator() |
| 18 : scrolling_(false), pinching_(false), waiting_for_tap_end_(false) { | 18 : scrolling_(false), pinching_(false), waiting_for_tap_end_(false) { |
| 19 } | 19 } |
| 20 | 20 |
| 21 GestureEventStreamValidator::~GestureEventStreamValidator() { | 21 GestureEventStreamValidator::~GestureEventStreamValidator() { |
| 22 } | 22 } |
| 23 | 23 |
| 24 bool GestureEventStreamValidator::Validate(const blink::WebGestureEvent& event, | 24 bool GestureEventStreamValidator::Validate(const blink::WebGestureEvent& event, |
| 25 std::string* error_msg) { | 25 std::string* error_msg) { |
| 26 DCHECK(error_msg); | 26 DCHECK(error_msg); |
| 27 error_msg->clear(); | 27 error_msg->clear(); |
| 28 if (!WebInputEvent::isGestureEventType(event.type)) { | 28 if (!WebInputEvent::isGestureEventType(event.type())) { |
| 29 error_msg->append(base::StringPrintf("Invalid gesture type: %s", | 29 error_msg->append(base::StringPrintf("Invalid gesture type: %s", |
| 30 WebInputEvent::GetName(event.type))); | 30 WebInputEvent::GetName(event.type()))); |
| 31 } | 31 } |
| 32 switch (event.type) { | 32 switch (event.type()) { |
| 33 case WebInputEvent::GestureScrollBegin: | 33 case WebInputEvent::GestureScrollBegin: |
| 34 if (scrolling_) | 34 if (scrolling_) |
| 35 error_msg->append("Scroll begin during scroll\n"); | 35 error_msg->append("Scroll begin during scroll\n"); |
| 36 if (pinching_) | 36 if (pinching_) |
| 37 error_msg->append("Scroll begin during pinch\n"); | 37 error_msg->append("Scroll begin during pinch\n"); |
| 38 scrolling_ = true; | 38 scrolling_ = true; |
| 39 break; | 39 break; |
| 40 case WebInputEvent::GestureScrollUpdate: | 40 case WebInputEvent::GestureScrollUpdate: |
| 41 if (!scrolling_) | 41 if (!scrolling_) |
| 42 error_msg->append("Scroll update outside of scroll\n"); | 42 error_msg->append("Scroll update outside of scroll\n"); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // 'continuity check', requiring that all events between an initial tap-down | 105 // 'continuity check', requiring that all events between an initial tap-down |
| 106 // and whatever terminates the sequence to have the same source device type, | 106 // and whatever terminates the sequence to have the same source device type, |
| 107 // and that touchpad gestures are only found on ScrollEvents. | 107 // and that touchpad gestures are only found on ScrollEvents. |
| 108 if (event.sourceDevice == blink::WebGestureDeviceUninitialized) | 108 if (event.sourceDevice == blink::WebGestureDeviceUninitialized) |
| 109 error_msg->append("Gesture event source is uninitialized.\n"); | 109 error_msg->append("Gesture event source is uninitialized.\n"); |
| 110 | 110 |
| 111 return error_msg->empty(); | 111 return error_msg->empty(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 } // namespace content | 114 } // namespace content |
| OLD | NEW |