| 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/web_touch_event_traits.h" | 5 #include "content/common/input/web_touch_event_traits.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| 11 using blink::WebInputEvent; | 11 using blink::WebInputEvent; |
| 12 using blink::WebTouchEvent; | 12 using blink::WebTouchEvent; |
| 13 using blink::WebTouchPoint; | 13 using blink::WebTouchPoint; |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 bool WebTouchEventTraits::AllTouchPointsHaveState( | 17 bool WebTouchEventTraits::AllTouchPointsHaveState( |
| 18 const WebTouchEvent& event, | 18 const WebTouchEvent& event, |
| 19 blink::WebTouchPoint::State state) { | 19 blink::WebTouchPoint::State state) { |
| 20 if (!event.touchesLength) | 20 if (!event.touchesLength) |
| 21 return false; | 21 return false; |
| 22 for (size_t i = 0; i < event.touchesLength; ++i) { | 22 for (size_t i = 0; i < event.touchesLength; ++i) { |
| 23 if (event.touches[i].state != state) | 23 if (event.touches[i].state != state) |
| 24 return false; | 24 return false; |
| 25 } | 25 } |
| 26 return true; | 26 return true; |
| 27 } | 27 } |
| 28 | 28 |
| 29 bool WebTouchEventTraits::IsTouchSequenceStart(const WebTouchEvent& event) { | 29 bool WebTouchEventTraits::IsTouchSequenceStart(const WebTouchEvent& event) { |
| 30 DCHECK(event.touchesLength); | 30 DCHECK(event.touchesLength || |
| 31 event.type == WebInputEvent::TouchScrollStarted); |
| 31 if (event.type != WebInputEvent::TouchStart) | 32 if (event.type != WebInputEvent::TouchStart) |
| 32 return false; | 33 return false; |
| 33 return AllTouchPointsHaveState(event, blink::WebTouchPoint::StatePressed); | 34 return AllTouchPointsHaveState(event, blink::WebTouchPoint::StatePressed); |
| 34 } | 35 } |
| 35 | 36 |
| 36 bool WebTouchEventTraits::IsTouchSequenceEnd(const WebTouchEvent& event) { | 37 bool WebTouchEventTraits::IsTouchSequenceEnd(const WebTouchEvent& event) { |
| 37 if (event.type != WebInputEvent::TouchEnd && | 38 if (event.type != WebInputEvent::TouchEnd && |
| 38 event.type != WebInputEvent::TouchCancel) | 39 event.type != WebInputEvent::TouchCancel) |
| 39 return false; | 40 return false; |
| 40 if (!event.touchesLength) | 41 if (!event.touchesLength) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 break; | 78 break; |
| 78 default: | 79 default: |
| 79 NOTREACHED(); | 80 NOTREACHED(); |
| 80 break; | 81 break; |
| 81 } | 82 } |
| 82 for (size_t i = 0; i < event->touchesLength; ++i) | 83 for (size_t i = 0; i < event->touchesLength; ++i) |
| 83 event->touches[i].state = newState; | 84 event->touches[i].state = newState; |
| 84 } | 85 } |
| 85 | 86 |
| 86 } // namespace content | 87 } // namespace content |
| OLD | NEW |