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/touch_event_stream_validator.h" | 5 #include "content/common/input/touch_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 "content/common/input/web_touch_event_traits.h" | 9 #include "content/common/input/web_touch_event_traits.h" |
10 #include "ui/events/blink/web_input_event_traits.h" | 10 #include "ui/events/blink/web_input_event_traits.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 WebTouchEvent previous_event = previous_event_; | 55 WebTouchEvent previous_event = previous_event_; |
56 previous_event_ = event; | 56 previous_event_ = event; |
57 | 57 |
58 if (!event.touchesLength) { | 58 if (!event.touchesLength) { |
59 error_msg->append("Touch event is empty.\n"); | 59 error_msg->append("Touch event is empty.\n"); |
60 return false; | 60 return false; |
61 } | 61 } |
62 | 62 |
63 if (!WebInputEvent::isTouchEventType(event.type)) { | 63 if (!WebInputEvent::isTouchEventType(event.type)) { |
64 error_msg->append( | 64 error_msg->append(StringPrintf("Touch event has invalid type: %s\n", |
65 StringPrintf("Touch event has invalid type: %s\n", | 65 WebInputEvent::GetName(event.type))); |
66 ui::WebInputEventTraits::GetName(event.type))); | |
67 } | 66 } |
68 | 67 |
69 // Allow "hard" restarting of touch stream validation. This is necessary | 68 // Allow "hard" restarting of touch stream validation. This is necessary |
70 // in cases where touch event forwarding ceases in response to the event ack | 69 // in cases where touch event forwarding ceases in response to the event ack |
71 // or removal of touch handlers. | 70 // or removal of touch handlers. |
72 if (WebTouchEventTraits::IsTouchSequenceStart(event)) | 71 if (WebTouchEventTraits::IsTouchSequenceStart(event)) |
73 previous_event = WebTouchEvent(); | 72 previous_event = WebTouchEvent(); |
74 | 73 |
75 // Unreleased points from the previous event should exist in the latest event. | 74 // Unreleased points from the previous event should exist in the latest event. |
76 for (unsigned i = 0; i < previous_event.touchesLength; ++i) { | 75 for (unsigned i = 0; i < previous_event.touchesLength; ++i) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } else { | 153 } else { |
155 found_valid_state_for_type = true; | 154 found_valid_state_for_type = true; |
156 } | 155 } |
157 break; | 156 break; |
158 } | 157 } |
159 } | 158 } |
160 | 159 |
161 if (!found_valid_state_for_type) { | 160 if (!found_valid_state_for_type) { |
162 error_msg->append( | 161 error_msg->append( |
163 StringPrintf("No valid touch point corresponding to event type: %s\n", | 162 StringPrintf("No valid touch point corresponding to event type: %s\n", |
164 ui::WebInputEventTraits::GetName(event.type))); | 163 WebInputEvent::GetName(event.type))); |
165 } | 164 } |
166 | 165 |
167 return error_msg->empty(); | 166 return error_msg->empty(); |
168 } | 167 } |
169 | 168 |
170 } // namespace content | 169 } // namespace content |
OLD | NEW |