| 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 #ifndef CONTENT_COMMON_INPUT_WEB_TOUCH_EVENT_TRAITS_H_ | 5 #ifndef CONTENT_COMMON_INPUT_WEB_TOUCH_EVENT_TRAITS_H_ |
| 6 #define CONTENT_COMMON_INPUT_WEB_TOUCH_EVENT_TRAITS_H_ | 6 #define CONTENT_COMMON_INPUT_WEB_TOUCH_EVENT_TRAITS_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "content/common/input/scoped_web_input_event.h" | 9 #include "content/common/input/scoped_web_input_event.h" |
| 10 #include "third_party/WebKit/public/web/WebInputEvent.h" | 10 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 // Utility class for performing operations on and with WebTouchEvents. | 14 // Utility class for performing operations on and with WebTouchEvents. |
| 15 class CONTENT_EXPORT WebTouchEventTraits { | 15 class CONTENT_EXPORT WebTouchEventTraits { |
| 16 public: | 16 public: |
| 17 // Returns whether all touches in the event have the specified state. | 17 // Returns whether all touches in the event have the specified state. |
| 18 static bool AllTouchPointsHaveState(const blink::WebTouchEvent& event, | 18 static bool AllTouchPointsHaveState(const blink::WebTouchEvent& event, |
| 19 blink::WebTouchPoint::State state); | 19 blink::WebTouchPoint::State state); |
| 20 | 20 |
| 21 // Returns whether this event represents a transition from no active | 21 // Returns whether this event represents a transition from no active |
| 22 // touches to some active touches (the start of a new "touch sequence"). | 22 // touches to some active touches (the start of a new "touch sequence"). |
| 23 static bool IsTouchSequenceStart(const blink::WebTouchEvent& event); | 23 static bool IsTouchSequenceStart(const blink::WebTouchEvent& event); |
| 24 | 24 |
| 25 // Returns whether this event represents a transition from active |
| 26 // touches to no active touches (the end of a "touch sequence"). |
| 27 static bool IsTouchSequenceEnd(const blink::WebTouchEvent& event); |
| 28 |
| 25 // Sets the type of |event| to |type|, resetting any other type-specific | 29 // Sets the type of |event| to |type|, resetting any other type-specific |
| 26 // properties and updating the timestamp. | 30 // properties and updating the timestamp. |
| 27 static void ResetType(blink::WebInputEvent::Type type, | 31 static void ResetType(blink::WebInputEvent::Type type, |
| 28 double timestamp_sec, | 32 double timestamp_sec, |
| 29 blink::WebTouchEvent* event); | 33 blink::WebTouchEvent* event); |
| 30 | 34 |
| 31 // Like ResetType but also resets the state of all active touches | 35 // Like ResetType but also resets the state of all active touches |
| 32 // to match the event type. This is particularly useful, for example, | 36 // to match the event type. This is particularly useful, for example, |
| 33 // in sending a touchcancel for all active touches. | 37 // in sending a touchcancel for all active touches. |
| 34 static void ResetTypeAndTouchStates(blink::WebInputEvent::Type type, | 38 static void ResetTypeAndTouchStates(blink::WebInputEvent::Type type, |
| 35 double timestamp_sec, | 39 double timestamp_sec, |
| 36 blink::WebTouchEvent* event); | 40 blink::WebTouchEvent* event); |
| 37 }; | 41 }; |
| 38 | 42 |
| 39 } // namespace content | 43 } // namespace content |
| 40 | 44 |
| 41 #endif // CONTENT_COMMON_INPUT_WEB_TOUCH_EVENT_TRAITS_H_ | 45 #endif // CONTENT_COMMON_INPUT_WEB_TOUCH_EVENT_TRAITS_H_ |
| OLD | NEW |