| 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 17 matching lines...) Expand all Loading... |
| 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 "wtf/Assertions.h" | 33 #include "wtf/Assertions.h" |
| 34 #include <string.h> | 34 #include <string.h> |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 enum PlatformGestureSource { |
| 39 PlatformGestureSourceUninitialized, |
| 40 PlatformGestureSourceTouchpad, |
| 41 PlatformGestureSourceTouchscreen |
| 42 }; |
| 43 |
| 38 class PlatformGestureEvent : public PlatformEvent { | 44 class PlatformGestureEvent : public PlatformEvent { |
| 39 public: | 45 public: |
| 40 PlatformGestureEvent() | 46 PlatformGestureEvent() |
| 41 : PlatformEvent(PlatformEvent::GestureScrollBegin) | 47 : PlatformEvent(PlatformEvent::GestureScrollBegin) |
| 48 , m_source(PlatformGestureSourceUninitialized) |
| 42 { | 49 { |
| 43 memset(&m_data, 0, sizeof(m_data)); | 50 memset(&m_data, 0, sizeof(m_data)); |
| 44 } | 51 } |
| 45 | 52 |
| 46 PlatformGestureEvent(Type type, const IntPoint& position, | 53 PlatformGestureEvent(Type type, const IntPoint& position, |
| 47 const IntPoint& globalPosition, const IntSize& area, double timestamp, | 54 const IntPoint& globalPosition, const IntSize& area, double timestamp, |
| 48 PlatformEvent::Modifiers modifiers) | 55 PlatformEvent::Modifiers modifiers, PlatformGestureSource source) |
| 49 : PlatformEvent(type, modifiers, timestamp) | 56 : PlatformEvent(type, modifiers, timestamp) |
| 50 , m_position(position) | 57 , m_position(position) |
| 51 , m_globalPosition(globalPosition) | 58 , m_globalPosition(globalPosition) |
| 52 , m_area(area) | 59 , m_area(area) |
| 60 , m_source(source) |
| 53 { | 61 { |
| 54 memset(&m_data, 0, sizeof(m_data)); | 62 memset(&m_data, 0, sizeof(m_data)); |
| 55 } | 63 } |
| 56 | 64 |
| 57 void setScrollGestureData(float deltaX, float deltaY, float velocityX, float
velocityY, | 65 void setScrollGestureData(float deltaX, float deltaY, float velocityX, float
velocityY, |
| 58 bool inertial, bool preventPropagation, int resendingPluginId) | 66 bool inertial, bool preventPropagation, int resendingPluginId) |
| 59 { | 67 { |
| 60 ASSERT(type() == PlatformEvent::GestureScrollBegin | 68 ASSERT(type() == PlatformEvent::GestureScrollBegin |
| 61 || type() == PlatformEvent::GestureScrollUpdate | 69 || type() == PlatformEvent::GestureScrollUpdate |
| 62 || type() == PlatformEvent::GestureScrollEnd); | 70 || type() == PlatformEvent::GestureScrollEnd); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 78 m_data.m_scroll.m_inertial = inertial; | 86 m_data.m_scroll.m_inertial = inertial; |
| 79 m_data.m_scroll.m_resendingPluginId = resendingPluginId; | 87 m_data.m_scroll.m_resendingPluginId = resendingPluginId; |
| 80 m_data.m_scroll.m_preventPropagation = preventPropagation; | 88 m_data.m_scroll.m_preventPropagation = preventPropagation; |
| 81 } | 89 } |
| 82 | 90 |
| 83 const IntPoint& position() const { return m_position; } // PlatformWindow co
ordinates. | 91 const IntPoint& position() const { return m_position; } // PlatformWindow co
ordinates. |
| 84 const IntPoint& globalPosition() const { return m_globalPosition; } // Scree
n coordinates. | 92 const IntPoint& globalPosition() const { return m_globalPosition; } // Scree
n coordinates. |
| 85 | 93 |
| 86 const IntSize& area() const { return m_area; } | 94 const IntSize& area() const { return m_area; } |
| 87 | 95 |
| 96 PlatformGestureSource source() const { return m_source; } |
| 97 |
| 88 float deltaX() const | 98 float deltaX() const |
| 89 { | 99 { |
| 90 ASSERT(m_type == PlatformEvent::GestureScrollUpdate); | 100 ASSERT(m_type == PlatformEvent::GestureScrollUpdate); |
| 91 return m_data.m_scroll.m_deltaX; | 101 return m_data.m_scroll.m_deltaX; |
| 92 } | 102 } |
| 93 | 103 |
| 94 float deltaY() const | 104 float deltaY() const |
| 95 { | 105 { |
| 96 ASSERT(m_type == PlatformEvent::GestureScrollUpdate); | 106 ASSERT(m_type == PlatformEvent::GestureScrollUpdate); |
| 97 return m_data.m_scroll.m_deltaY; | 107 return m_data.m_scroll.m_deltaY; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 default: | 191 default: |
| 182 ASSERT_NOT_REACHED(); | 192 ASSERT_NOT_REACHED(); |
| 183 return false; | 193 return false; |
| 184 } | 194 } |
| 185 } | 195 } |
| 186 | 196 |
| 187 protected: | 197 protected: |
| 188 IntPoint m_position; | 198 IntPoint m_position; |
| 189 IntPoint m_globalPosition; | 199 IntPoint m_globalPosition; |
| 190 IntSize m_area; | 200 IntSize m_area; |
| 201 PlatformGestureSource m_source; |
| 191 | 202 |
| 192 union { | 203 union { |
| 193 struct { | 204 struct { |
| 194 int m_tapCount; | 205 int m_tapCount; |
| 195 } m_tap; | 206 } m_tap; |
| 196 | 207 |
| 197 struct { | 208 struct { |
| 198 float m_deltaX; | 209 float m_deltaX; |
| 199 float m_deltaY; | 210 float m_deltaY; |
| 200 float m_velocityX; | 211 float m_velocityX; |
| 201 float m_velocityY; | 212 float m_velocityY; |
| 202 int m_preventPropagation; | 213 int m_preventPropagation; |
| 203 bool m_inertial; | 214 bool m_inertial; |
| 204 int m_resendingPluginId; | 215 int m_resendingPluginId; |
| 205 } m_scroll; | 216 } m_scroll; |
| 206 | 217 |
| 207 struct { | 218 struct { |
| 208 float m_scale; | 219 float m_scale; |
| 209 } m_pinchUpdate; | 220 } m_pinchUpdate; |
| 210 } m_data; | 221 } m_data; |
| 211 }; | 222 }; |
| 212 | 223 |
| 213 } // namespace blink | 224 } // namespace blink |
| 214 | 225 |
| 215 #endif // PlatformGestureEvent_h | 226 #endif // PlatformGestureEvent_h |
| OLD | NEW |