OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/common/input/synthetic_web_input_event_builders.h" | 5 #include "content/common/input/synthetic_web_input_event_builders.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/common/input/web_touch_event_traits.h" |
8 #include "ui/events/keycodes/keyboard_codes.h" | 9 #include "ui/events/keycodes/keyboard_codes.h" |
9 | 10 |
10 namespace content { | 11 namespace content { |
11 | 12 |
12 using blink::WebInputEvent; | 13 using blink::WebInputEvent; |
13 using blink::WebKeyboardEvent; | 14 using blink::WebKeyboardEvent; |
14 using blink::WebGestureEvent; | 15 using blink::WebGestureEvent; |
15 using blink::WebMouseEvent; | 16 using blink::WebMouseEvent; |
16 using blink::WebMouseWheelEvent; | 17 using blink::WebMouseWheelEvent; |
17 using blink::WebTouchEvent; | 18 using blink::WebTouchEvent; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 int SyntheticWebTouchEvent::PressPoint(float x, float y) { | 163 int SyntheticWebTouchEvent::PressPoint(float x, float y) { |
163 if (touchesLength == touchesLengthCap) | 164 if (touchesLength == touchesLengthCap) |
164 return -1; | 165 return -1; |
165 WebTouchPoint& point = touches[touchesLength]; | 166 WebTouchPoint& point = touches[touchesLength]; |
166 point.id = touchesLength; | 167 point.id = touchesLength; |
167 point.position.x = point.screenPosition.x = x; | 168 point.position.x = point.screenPosition.x = x; |
168 point.position.y = point.screenPosition.y = y; | 169 point.position.y = point.screenPosition.y = y; |
169 point.state = WebTouchPoint::StatePressed; | 170 point.state = WebTouchPoint::StatePressed; |
170 point.radiusX = point.radiusY = 1.f; | 171 point.radiusX = point.radiusY = 1.f; |
171 ++touchesLength; | 172 ++touchesLength; |
172 type = WebInputEvent::TouchStart; | 173 WebTouchEventTraits::ResetType( |
| 174 WebInputEvent::TouchStart, timeStampSeconds, this); |
173 return point.id; | 175 return point.id; |
174 } | 176 } |
175 | 177 |
176 void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) { | 178 void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) { |
177 CHECK(index >= 0 && index < touchesLengthCap); | 179 CHECK(index >= 0 && index < touchesLengthCap); |
178 WebTouchPoint& point = touches[index]; | 180 WebTouchPoint& point = touches[index]; |
179 point.position.x = point.screenPosition.x = x; | 181 point.position.x = point.screenPosition.x = x; |
180 point.position.y = point.screenPosition.y = y; | 182 point.position.y = point.screenPosition.y = y; |
181 touches[index].state = WebTouchPoint::StateMoved; | 183 touches[index].state = WebTouchPoint::StateMoved; |
182 type = WebInputEvent::TouchMove; | 184 WebTouchEventTraits::ResetType( |
| 185 WebInputEvent::TouchMove, timeStampSeconds, this); |
183 } | 186 } |
184 | 187 |
185 void SyntheticWebTouchEvent::ReleasePoint(int index) { | 188 void SyntheticWebTouchEvent::ReleasePoint(int index) { |
186 CHECK(index >= 0 && index < touchesLengthCap); | 189 CHECK(index >= 0 && index < touchesLengthCap); |
187 touches[index].state = WebTouchPoint::StateReleased; | 190 touches[index].state = WebTouchPoint::StateReleased; |
188 type = WebInputEvent::TouchEnd; | 191 WebTouchEventTraits::ResetType( |
| 192 WebInputEvent::TouchEnd, timeStampSeconds, this); |
189 } | 193 } |
190 | 194 |
191 void SyntheticWebTouchEvent::CancelPoint(int index) { | 195 void SyntheticWebTouchEvent::CancelPoint(int index) { |
192 CHECK(index >= 0 && index < touchesLengthCap); | 196 CHECK(index >= 0 && index < touchesLengthCap); |
193 touches[index].state = WebTouchPoint::StateCancelled; | 197 touches[index].state = WebTouchPoint::StateCancelled; |
194 type = WebInputEvent::TouchCancel; | 198 WebTouchEventTraits::ResetType( |
| 199 WebInputEvent::TouchCancel, timeStampSeconds, this); |
195 } | 200 } |
196 | 201 |
197 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) { | 202 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) { |
198 timeStampSeconds = timestamp.InSecondsF(); | 203 timeStampSeconds = timestamp.InSecondsF(); |
199 } | 204 } |
200 | 205 |
201 SyntheticWebTouchEvent SyntheticWebTouchEventBuilder::Build( | |
202 WebInputEvent::Type type) { | |
203 DCHECK(WebInputEvent::isTouchEventType(type)); | |
204 SyntheticWebTouchEvent result; | |
205 result.type = type; | |
206 return result; | |
207 }; | |
208 | |
209 } // namespace content | 206 } // namespace content |
OLD | NEW |