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 "content/common/input/web_touch_event_traits.h" |
| 9 #include "ui/events/event_utils.h" |
9 #include "ui/events/keycodes/keyboard_codes.h" | 10 #include "ui/events/keycodes/keyboard_codes.h" |
10 | 11 |
11 namespace content { | 12 namespace content { |
12 | 13 |
13 using blink::WebInputEvent; | 14 using blink::WebInputEvent; |
14 using blink::WebKeyboardEvent; | 15 using blink::WebKeyboardEvent; |
15 using blink::WebGestureEvent; | 16 using blink::WebGestureEvent; |
16 using blink::WebMouseEvent; | 17 using blink::WebMouseEvent; |
17 using blink::WebMouseWheelEvent; | 18 using blink::WebMouseWheelEvent; |
18 using blink::WebTouchEvent; | 19 using blink::WebTouchEvent; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 float velocity_x, | 141 float velocity_x, |
141 float velocity_y, | 142 float velocity_y, |
142 WebGestureEvent::SourceDevice source_device) { | 143 WebGestureEvent::SourceDevice source_device) { |
143 WebGestureEvent result = Build(WebInputEvent::GestureFlingStart, | 144 WebGestureEvent result = Build(WebInputEvent::GestureFlingStart, |
144 source_device); | 145 source_device); |
145 result.data.flingStart.velocityX = velocity_x; | 146 result.data.flingStart.velocityX = velocity_x; |
146 result.data.flingStart.velocityY = velocity_y; | 147 result.data.flingStart.velocityY = velocity_y; |
147 return result; | 148 return result; |
148 } | 149 } |
149 | 150 |
150 SyntheticWebTouchEvent::SyntheticWebTouchEvent() : WebTouchEvent() {} | 151 SyntheticWebTouchEvent::SyntheticWebTouchEvent() : WebTouchEvent() { |
| 152 SetTimestamp(ui::EventTimeForNow()); |
| 153 } |
151 | 154 |
152 void SyntheticWebTouchEvent::ResetPoints() { | 155 void SyntheticWebTouchEvent::ResetPoints() { |
153 int point = 0; | 156 int point = 0; |
154 for (unsigned int i = 0; i < touchesLength; ++i) { | 157 for (unsigned int i = 0; i < touchesLength; ++i) { |
155 if (touches[i].state == WebTouchPoint::StateReleased) | 158 if (touches[i].state == WebTouchPoint::StateReleased) |
156 continue; | 159 continue; |
157 | 160 |
158 touches[point] = touches[i]; | 161 touches[point] = touches[i]; |
159 touches[point].state = WebTouchPoint::StateStationary; | 162 touches[point].state = WebTouchPoint::StateStationary; |
160 ++point; | 163 ++point; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 touches[index].state = WebTouchPoint::StateCancelled; | 203 touches[index].state = WebTouchPoint::StateCancelled; |
201 WebTouchEventTraits::ResetType( | 204 WebTouchEventTraits::ResetType( |
202 WebInputEvent::TouchCancel, timeStampSeconds, this); | 205 WebInputEvent::TouchCancel, timeStampSeconds, this); |
203 } | 206 } |
204 | 207 |
205 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) { | 208 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) { |
206 timeStampSeconds = timestamp.InSecondsF(); | 209 timeStampSeconds = timestamp.InSecondsF(); |
207 } | 210 } |
208 | 211 |
209 } // namespace content | 212 } // namespace content |
OLD | NEW |