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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, bool preventPropagation) | 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, bool preventPropagation) |
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 memset(&m_data, 0, sizeof(m_data)); | 52 memset(&m_data, 0, sizeof(m_data)); |
53 if (type == PlatformEvent::GestureScrollBegin | 53 if (type == PlatformEvent::GestureScrollBegin |
54 || type == PlatformEvent::GestureScrollEnd | 54 || type == PlatformEvent::GestureScrollEnd |
55 || type == PlatformEvent::GestureScrollUpdate | 55 || type == PlatformEvent::GestureScrollUpdate) { |
56 || type == PlatformEvent::GestureScrollUpdateWithoutPropagation) { | |
57 m_data.m_scrollUpdate.m_deltaX = deltaX; | 56 m_data.m_scrollUpdate.m_deltaX = deltaX; |
58 m_data.m_scrollUpdate.m_deltaY = deltaY; | 57 m_data.m_scrollUpdate.m_deltaY = deltaY; |
59 m_data.m_scrollUpdate.m_velocityX = velocityX; | 58 m_data.m_scrollUpdate.m_velocityX = velocityX; |
60 m_data.m_scrollUpdate.m_velocityY = velocityY; | 59 m_data.m_scrollUpdate.m_velocityY = velocityY; |
61 m_data.m_scrollUpdate.m_preventPropagation = preventPropagation; | 60 m_data.m_scrollUpdate.m_preventPropagation = preventPropagation; |
62 } | 61 } |
63 } | 62 } |
64 | 63 |
65 const IntPoint& position() const { return m_position; } // PlatformWindow co
ordinates. | 64 const IntPoint& position() const { return m_position; } // PlatformWindow co
ordinates. |
66 const IntPoint& globalPosition() const { return m_globalPosition; } // Scree
n coordinates. | 65 const IntPoint& globalPosition() const { return m_globalPosition; } // Scree
n coordinates. |
67 | 66 |
68 const IntSize& area() const { return m_area; } | 67 const IntSize& area() const { return m_area; } |
69 | 68 |
70 float deltaX() const | 69 float deltaX() const |
71 { | 70 { |
72 ASSERT(m_type == PlatformEvent::GestureScrollUpdate | 71 ASSERT(m_type == PlatformEvent::GestureScrollUpdate); |
73 || m_type == PlatformEvent::GestureScrollUpdateWithoutPropagation); | |
74 return m_data.m_scrollUpdate.m_deltaX; | 72 return m_data.m_scrollUpdate.m_deltaX; |
75 } | 73 } |
76 | 74 |
77 float deltaY() const | 75 float deltaY() const |
78 { | 76 { |
79 ASSERT(m_type == PlatformEvent::GestureScrollUpdate | 77 ASSERT(m_type == PlatformEvent::GestureScrollUpdate); |
80 || m_type == PlatformEvent::GestureScrollUpdateWithoutPropagation); | |
81 return m_data.m_scrollUpdate.m_deltaY; | 78 return m_data.m_scrollUpdate.m_deltaY; |
82 } | 79 } |
83 | 80 |
84 int tapCount() const | 81 int tapCount() const |
85 { | 82 { |
86 ASSERT(m_type == PlatformEvent::GestureTap); | 83 ASSERT(m_type == PlatformEvent::GestureTap); |
87 return m_data.m_tap.m_tapCount; | 84 return m_data.m_tap.m_tapCount; |
88 } | 85 } |
89 | 86 |
90 float velocityX() const | 87 float velocityX() const |
91 { | 88 { |
92 ASSERT(m_type == PlatformEvent::GestureScrollUpdate | 89 ASSERT(m_type == PlatformEvent::GestureScrollUpdate); |
93 || m_type == PlatformEvent::GestureScrollUpdateWithoutPropagation); | |
94 return m_data.m_scrollUpdate.m_velocityX; | 90 return m_data.m_scrollUpdate.m_velocityX; |
95 } | 91 } |
96 | 92 |
97 float velocityY() const | 93 float velocityY() const |
98 { | 94 { |
99 ASSERT(m_type == PlatformEvent::GestureScrollUpdate | 95 ASSERT(m_type == PlatformEvent::GestureScrollUpdate); |
100 || m_type == PlatformEvent::GestureScrollUpdateWithoutPropagation); | |
101 return m_data.m_scrollUpdate.m_velocityY; | 96 return m_data.m_scrollUpdate.m_velocityY; |
102 } | 97 } |
103 | 98 |
104 bool preventPropagation() const | 99 bool preventPropagation() const |
105 { | 100 { |
106 ASSERT(m_type == PlatformEvent::GestureScrollUpdate | 101 ASSERT(m_type == PlatformEvent::GestureScrollUpdate); |
107 || m_type == PlatformEvent::GestureScrollUpdateWithoutPropagation); | |
108 return m_data.m_scrollUpdate.m_preventPropagation; | 102 return m_data.m_scrollUpdate.m_preventPropagation; |
109 } | 103 } |
110 | 104 |
111 float scale() const | 105 float scale() const |
112 { | 106 { |
113 ASSERT(m_type == PlatformEvent::GesturePinchUpdate); | 107 ASSERT(m_type == PlatformEvent::GesturePinchUpdate); |
114 return m_data.m_pinchUpdate.m_scale; | 108 return m_data.m_pinchUpdate.m_scale; |
115 } | 109 } |
116 | 110 |
117 void applyTouchAdjustment(const IntPoint& adjustedPosition) | 111 void applyTouchAdjustment(const IntPoint& adjustedPosition) |
118 { | 112 { |
119 // Update the window-relative position of the event so that the node tha
t was | 113 // Update the window-relative position of the event so that the node tha
t was |
120 // ultimately hit is under this point (i.e. elementFromPoint for the cli
ent | 114 // ultimately hit is under this point (i.e. elementFromPoint for the cli
ent |
121 // co-ordinates in a 'click' event should yield the target). The global | 115 // co-ordinates in a 'click' event should yield the target). The global |
122 // position is intentionally left unmodified because it's intended to re
flect | 116 // position is intentionally left unmodified because it's intended to re
flect |
123 // raw co-ordinates unrelated to any content. | 117 // raw co-ordinates unrelated to any content. |
124 m_position = adjustedPosition; | 118 m_position = adjustedPosition; |
125 } | 119 } |
126 | 120 |
127 bool isScrollEvent() const | 121 bool isScrollEvent() const |
128 { | 122 { |
129 switch (m_type) { | 123 switch (m_type) { |
130 case GestureScrollBegin: | 124 case GestureScrollBegin: |
131 case GestureScrollEnd: | 125 case GestureScrollEnd: |
132 case GestureScrollUpdate: | 126 case GestureScrollUpdate: |
133 case GestureScrollUpdateWithoutPropagation: | |
134 case GestureFlingStart: | 127 case GestureFlingStart: |
135 case GesturePinchBegin: | 128 case GesturePinchBegin: |
136 case GesturePinchEnd: | 129 case GesturePinchEnd: |
137 case GesturePinchUpdate: | 130 case GesturePinchUpdate: |
138 return true; | 131 return true; |
139 case GestureTap: | 132 case GestureTap: |
140 case GestureTapUnconfirmed: | 133 case GestureTapUnconfirmed: |
141 case GestureTapDown: | 134 case GestureTapDown: |
142 case GestureShowPress: | 135 case GestureShowPress: |
143 case GestureTapDownCancel: | 136 case GestureTapDownCancel: |
(...skipping 27 matching lines...) Expand all Loading... |
171 | 164 |
172 struct { | 165 struct { |
173 float m_scale; | 166 float m_scale; |
174 } m_pinchUpdate; | 167 } m_pinchUpdate; |
175 } m_data; | 168 } m_data; |
176 }; | 169 }; |
177 | 170 |
178 } // namespace blink | 171 } // namespace blink |
179 | 172 |
180 #endif // PlatformGestureEvent_h | 173 #endif // PlatformGestureEvent_h |
OLD | NEW |