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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 { | 42 { |
43 memset(&m_data, 0, sizeof(m_data)); | 43 memset(&m_data, 0, sizeof(m_data)); |
44 } | 44 } |
45 | 45 |
46 PlatformGestureEvent(Type type, const IntPoint& position, const IntPoint& gl obalPosition, const IntSize& area, double timestamp, bool shiftKey, bool ctrlKey , bool altKey, bool metaKey, float deltaX, float deltaY, float velocityX, float velocityY) | 46 PlatformGestureEvent(Type type, const IntPoint& position, const IntPoint& gl obalPosition, const IntSize& area, double timestamp, bool shiftKey, bool ctrlKey , bool altKey, bool metaKey, float deltaX, float deltaY, float velocityX, float velocityY) |
47 : PlatformEvent(type, shiftKey, ctrlKey, altKey, metaKey, timestamp) | 47 : PlatformEvent(type, shiftKey, ctrlKey, altKey, metaKey, timestamp) |
48 , m_position(position) | 48 , m_position(position) |
49 , m_globalPosition(globalPosition) | 49 , m_globalPosition(globalPosition) |
50 , m_area(area) | 50 , m_area(area) |
51 { | 51 { |
52 ASSERT(type == PlatformEvent::GestureScrollBegin | 52 memset(&m_data, 0, sizeof(m_data)); |
53 if (type == PlatformEvent::GestureScrollBegin | |
53 || type == PlatformEvent::GestureScrollEnd | 54 || type == PlatformEvent::GestureScrollEnd |
54 || type == PlatformEvent::GestureScrollUpdate | 55 || type == PlatformEvent::GestureScrollUpdate |
55 || type == PlatformEvent::GestureScrollUpdateWithoutPropagation); | 56 || type == PlatformEvent::GestureScrollUpdateWithoutPropagation) { |
56 memset(&m_data, 0, sizeof(m_data)); | 57 m_data.m_scrollUpdate.m_deltaX = deltaX; |
57 m_data.m_scrollUpdate.m_deltaX = deltaX; | 58 m_data.m_scrollUpdate.m_deltaY = deltaY; |
58 m_data.m_scrollUpdate.m_deltaY = deltaY; | 59 m_data.m_scrollUpdate.m_velocityX = velocityX; |
59 m_data.m_scrollUpdate.m_velocityX = velocityX; | 60 m_data.m_scrollUpdate.m_velocityY = velocityY; |
60 m_data.m_scrollUpdate.m_velocityY = velocityY; | 61 } |
61 } | 62 } |
62 | 63 |
63 const IntPoint& position() const { return m_position; } // PlatformWindow co ordinates. | 64 const IntPoint& position() const { return m_position; } // PlatformWindow co ordinates. |
64 const IntPoint& globalPosition() const { return m_globalPosition; } // Scree n coordinates. | 65 const IntPoint& globalPosition() const { return m_globalPosition; } // Scree n coordinates. |
65 | 66 |
66 const IntSize& area() const { return m_area; } | 67 const IntSize& area() const { return m_area; } |
67 | 68 |
68 float deltaX() const | 69 float deltaX() const |
69 { | 70 { |
70 ASSERT(m_type == PlatformEvent::GestureScrollUpdate | 71 ASSERT(m_type == PlatformEvent::GestureScrollUpdate |
(...skipping 27 matching lines...) Expand all Loading... | |
98 || m_type == PlatformEvent::GestureScrollUpdateWithoutPropagation); | 99 || m_type == PlatformEvent::GestureScrollUpdateWithoutPropagation); |
99 return m_data.m_scrollUpdate.m_velocityY; | 100 return m_data.m_scrollUpdate.m_velocityY; |
100 } | 101 } |
101 | 102 |
102 float scale() const | 103 float scale() const |
103 { | 104 { |
104 ASSERT(m_type == PlatformEvent::GesturePinchUpdate); | 105 ASSERT(m_type == PlatformEvent::GesturePinchUpdate); |
105 return m_data.m_pinchUpdate.m_scale; | 106 return m_data.m_pinchUpdate.m_scale; |
106 } | 107 } |
107 | 108 |
109 void applyTouchAdjustment(const IntPoint& adjustedPosition) | |
110 { | |
111 // Update the window-relative position of the event so that the node tha t was | |
112 // ultimately hit is under this point (i.e. elementFromPoint for the cli ent | |
113 // co-ordinates in a 'click' event should yield the target). The global | |
114 // position is intentionally left unmodified because it's intended to re flect | |
115 // raw co-ordinates unrelated to any content. | |
116 m_position = adjustedPosition; | |
117 } | |
118 | |
119 bool isScrollEvent() const | |
120 { | |
121 switch (m_type) { | |
122 case GestureScrollBegin: | |
123 case GestureScrollEnd: | |
124 case GestureScrollUpdate: | |
125 case GestureScrollUpdateWithoutPropagation: | |
126 case GestureFlingStart: | |
127 return true; | |
128 default: | |
129 return false; | |
esprehn
2014/06/27 08:33:58
Can you list them all instead? Then when someone a
Rick Byers
2014/06/27 15:38:24
Done.
| |
130 } | |
131 } | |
132 | |
108 protected: | 133 protected: |
109 IntPoint m_position; | 134 IntPoint m_position; |
110 IntPoint m_globalPosition; | 135 IntPoint m_globalPosition; |
111 IntSize m_area; | 136 IntSize m_area; |
112 | 137 |
113 union { | 138 union { |
114 struct { | 139 struct { |
115 int m_tapCount; | 140 int m_tapCount; |
116 } m_tap; | 141 } m_tap; |
117 | 142 |
118 struct { | 143 struct { |
119 float m_deltaX; | 144 float m_deltaX; |
120 float m_deltaY; | 145 float m_deltaY; |
121 float m_velocityX; | 146 float m_velocityX; |
122 float m_velocityY; | 147 float m_velocityY; |
123 } m_scrollUpdate; | 148 } m_scrollUpdate; |
124 | 149 |
125 struct { | 150 struct { |
126 float m_scale; | 151 float m_scale; |
127 } m_pinchUpdate; | 152 } m_pinchUpdate; |
128 } m_data; | 153 } m_data; |
129 }; | 154 }; |
130 | 155 |
131 } // namespace WebCore | 156 } // namespace WebCore |
132 | 157 |
133 #endif // PlatformGestureEvent_h | 158 #endif // PlatformGestureEvent_h |
OLD | NEW |