| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef PlatformGestureEvent_h | 26 #ifndef PlatformGestureEvent_h |
| 27 #define PlatformGestureEvent_h | 27 #define PlatformGestureEvent_h |
| 28 | 28 |
| 29 #include "platform/PlatformEvent.h" | 29 #include "platform/PlatformEvent.h" |
| 30 #include "platform/geometry/FloatPoint.h" | 30 #include "platform/geometry/FloatPoint.h" |
| 31 #include "platform/geometry/IntPoint.h" | 31 #include "platform/geometry/IntPoint.h" |
| 32 #include "platform/geometry/IntSize.h" | 32 #include "platform/geometry/IntSize.h" |
| 33 #include "platform/scroll/ScrollTypes.h" |
| 33 #include "wtf/Assertions.h" | 34 #include "wtf/Assertions.h" |
| 34 #include <string.h> | 35 #include <string.h> |
| 35 | 36 |
| 36 namespace blink { | 37 namespace blink { |
| 37 | 38 |
| 38 enum PlatformGestureSource { | 39 enum PlatformGestureSource { |
| 39 PlatformGestureSourceUninitialized, | 40 PlatformGestureSourceUninitialized, |
| 40 PlatformGestureSourceTouchpad, | 41 PlatformGestureSourceTouchpad, |
| 41 PlatformGestureSourceTouchscreen | 42 PlatformGestureSourceTouchscreen |
| 42 }; | 43 }; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 55 PlatformEvent::Modifiers modifiers, PlatformGestureSource source) | 56 PlatformEvent::Modifiers modifiers, PlatformGestureSource source) |
| 56 : PlatformEvent(type, modifiers, timestamp) | 57 : PlatformEvent(type, modifiers, timestamp) |
| 57 , m_position(position) | 58 , m_position(position) |
| 58 , m_globalPosition(globalPosition) | 59 , m_globalPosition(globalPosition) |
| 59 , m_area(area) | 60 , m_area(area) |
| 60 , m_source(source) | 61 , m_source(source) |
| 61 { | 62 { |
| 62 memset(&m_data, 0, sizeof(m_data)); | 63 memset(&m_data, 0, sizeof(m_data)); |
| 63 } | 64 } |
| 64 | 65 |
| 65 void setScrollGestureData(float deltaX, float deltaY, float velocityX, float
velocityY, | 66 void setScrollGestureData(float deltaX, float deltaY, ScrollGranularity delt
aUnits, float velocityX, float velocityY, |
| 66 bool inertial, bool preventPropagation, int resendingPluginId) | 67 bool inertial, bool preventPropagation, int resendingPluginId) |
| 67 { | 68 { |
| 68 ASSERT(type() == PlatformEvent::GestureScrollBegin | 69 ASSERT(type() == PlatformEvent::GestureScrollBegin |
| 69 || type() == PlatformEvent::GestureScrollUpdate | 70 || type() == PlatformEvent::GestureScrollUpdate |
| 70 || type() == PlatformEvent::GestureScrollEnd); | 71 || type() == PlatformEvent::GestureScrollEnd); |
| 71 if (type() != GestureScrollUpdate) { | 72 if (type() != GestureScrollUpdate) { |
| 72 ASSERT(deltaX == 0); | 73 ASSERT(deltaX == 0); |
| 73 ASSERT(deltaY == 0); | 74 ASSERT(deltaY == 0); |
| 74 ASSERT(velocityX == 0); | 75 ASSERT(velocityX == 0); |
| 75 ASSERT(velocityY == 0); | 76 ASSERT(velocityY == 0); |
| 76 ASSERT(!preventPropagation); | 77 ASSERT(!preventPropagation); |
| 77 } | 78 } |
| 78 | 79 |
| 79 if (type() == PlatformEvent::GestureScrollBegin) | 80 if (type() == PlatformEvent::GestureScrollBegin) |
| 80 ASSERT(!inertial); | 81 ASSERT(!inertial); |
| 81 | 82 |
| 82 m_data.m_scroll.m_deltaX = deltaX; | 83 m_data.m_scroll.m_deltaX = deltaX; |
| 83 m_data.m_scroll.m_deltaY = deltaY; | 84 m_data.m_scroll.m_deltaY = deltaY; |
| 85 m_data.m_scroll.m_deltaUnits = deltaUnits; |
| 84 m_data.m_scroll.m_velocityX = velocityX; | 86 m_data.m_scroll.m_velocityX = velocityX; |
| 85 m_data.m_scroll.m_velocityY = velocityY; | 87 m_data.m_scroll.m_velocityY = velocityY; |
| 86 m_data.m_scroll.m_inertial = inertial; | 88 m_data.m_scroll.m_inertial = inertial; |
| 87 m_data.m_scroll.m_resendingPluginId = resendingPluginId; | 89 m_data.m_scroll.m_resendingPluginId = resendingPluginId; |
| 88 m_data.m_scroll.m_preventPropagation = preventPropagation; | 90 m_data.m_scroll.m_preventPropagation = preventPropagation; |
| 89 } | 91 } |
| 90 | 92 |
| 91 const IntPoint& position() const { return m_position; } // PlatformWindow co
ordinates. | 93 const IntPoint& position() const { return m_position; } // PlatformWindow co
ordinates. |
| 92 const IntPoint& globalPosition() const { return m_globalPosition; } // Scree
n coordinates. | 94 const IntPoint& globalPosition() const { return m_globalPosition; } // Scree
n coordinates. |
| 93 | 95 |
| 94 const IntSize& area() const { return m_area; } | 96 const IntSize& area() const { return m_area; } |
| 95 | 97 |
| 96 PlatformGestureSource source() const { return m_source; } | 98 PlatformGestureSource source() const { return m_source; } |
| 97 | 99 |
| 98 float deltaX() const | 100 float deltaX() const |
| 99 { | 101 { |
| 100 ASSERT(m_type == PlatformEvent::GestureScrollUpdate); | 102 ASSERT(m_type == PlatformEvent::GestureScrollUpdate); |
| 101 return m_data.m_scroll.m_deltaX; | 103 return m_data.m_scroll.m_deltaX; |
| 102 } | 104 } |
| 103 | 105 |
| 104 float deltaY() const | 106 float deltaY() const |
| 105 { | 107 { |
| 106 ASSERT(m_type == PlatformEvent::GestureScrollUpdate); | 108 ASSERT(m_type == PlatformEvent::GestureScrollUpdate); |
| 107 return m_data.m_scroll.m_deltaY; | 109 return m_data.m_scroll.m_deltaY; |
| 108 } | 110 } |
| 109 | 111 |
| 112 ScrollGranularity deltaUnits() const |
| 113 { |
| 114 ASSERT(m_type == PlatformEvent::GestureScrollUpdate); |
| 115 return m_data.m_scroll.m_deltaUnits; |
| 116 } |
| 117 |
| 110 int tapCount() const | 118 int tapCount() const |
| 111 { | 119 { |
| 112 ASSERT(m_type == PlatformEvent::GestureTap); | 120 ASSERT(m_type == PlatformEvent::GestureTap); |
| 113 return m_data.m_tap.m_tapCount; | 121 return m_data.m_tap.m_tapCount; |
| 114 } | 122 } |
| 115 | 123 |
| 116 float velocityX() const | 124 float velocityX() const |
| 117 { | 125 { |
| 118 ASSERT(m_type == PlatformEvent::GestureScrollUpdate || m_type == Platfor
mEvent::GestureFlingStart); | 126 ASSERT(m_type == PlatformEvent::GestureScrollUpdate || m_type == Platfor
mEvent::GestureFlingStart); |
| 119 return m_data.m_scroll.m_velocityX; | 127 return m_data.m_scroll.m_velocityX; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 int m_tapCount; | 213 int m_tapCount; |
| 206 } m_tap; | 214 } m_tap; |
| 207 | 215 |
| 208 struct { | 216 struct { |
| 209 float m_deltaX; | 217 float m_deltaX; |
| 210 float m_deltaY; | 218 float m_deltaY; |
| 211 float m_velocityX; | 219 float m_velocityX; |
| 212 float m_velocityY; | 220 float m_velocityY; |
| 213 int m_preventPropagation; | 221 int m_preventPropagation; |
| 214 bool m_inertial; | 222 bool m_inertial; |
| 223 ScrollGranularity m_deltaUnits; |
| 215 int m_resendingPluginId; | 224 int m_resendingPluginId; |
| 216 } m_scroll; | 225 } m_scroll; |
| 217 | 226 |
| 218 struct { | 227 struct { |
| 219 float m_scale; | 228 float m_scale; |
| 220 } m_pinchUpdate; | 229 } m_pinchUpdate; |
| 221 } m_data; | 230 } m_data; |
| 222 }; | 231 }; |
| 223 | 232 |
| 224 } // namespace blink | 233 } // namespace blink |
| 225 | 234 |
| 226 #endif // PlatformGestureEvent_h | 235 #endif // PlatformGestureEvent_h |
| OLD | NEW |