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/base_event_utils.h" | 9 #include "ui/events/base_event_utils.h" |
10 #include "ui/events/keycodes/keyboard_codes.h" | 10 #include "ui/events/keycodes/keyboard_codes.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 blink::WebGestureDevice source_device) { | 162 blink::WebGestureDevice source_device) { |
163 WebGestureEvent result = Build(WebInputEvent::GestureFlingStart, | 163 WebGestureEvent result = Build(WebInputEvent::GestureFlingStart, |
164 source_device); | 164 source_device); |
165 result.data.flingStart.velocityX = velocity_x; | 165 result.data.flingStart.velocityX = velocity_x; |
166 result.data.flingStart.velocityY = velocity_y; | 166 result.data.flingStart.velocityY = velocity_y; |
167 return result; | 167 return result; |
168 } | 168 } |
169 | 169 |
170 SyntheticWebTouchEvent::SyntheticWebTouchEvent() : WebTouchEvent() { | 170 SyntheticWebTouchEvent::SyntheticWebTouchEvent() : WebTouchEvent() { |
171 uniqueTouchEventId = ui::GetNextTouchEventId(); | 171 uniqueTouchEventId = ui::GetNextTouchEventId(); |
172 SetTimestamp(base::TimeTicks::Now() - base::TimeTicks()); | 172 SetTimestamp(base::TimeTicks::Now()); |
173 } | 173 } |
174 | 174 |
175 void SyntheticWebTouchEvent::ResetPoints() { | 175 void SyntheticWebTouchEvent::ResetPoints() { |
176 int point = 0; | 176 int point = 0; |
177 for (unsigned int i = 0; i < touchesLength; ++i) { | 177 for (unsigned int i = 0; i < touchesLength; ++i) { |
178 if (touches[i].state == WebTouchPoint::StateReleased) | 178 if (touches[i].state == WebTouchPoint::StateReleased) |
179 continue; | 179 continue; |
180 | 180 |
181 touches[point] = touches[i]; | 181 touches[point] = touches[i]; |
182 touches[point].state = WebTouchPoint::StateStationary; | 182 touches[point].state = WebTouchPoint::StateStationary; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 } | 229 } |
230 | 230 |
231 void SyntheticWebTouchEvent::CancelPoint(int index) { | 231 void SyntheticWebTouchEvent::CancelPoint(int index) { |
232 CHECK_GE(index, 0); | 232 CHECK_GE(index, 0); |
233 CHECK_LT(index, touchesLengthCap); | 233 CHECK_LT(index, touchesLengthCap); |
234 touches[index].state = WebTouchPoint::StateCancelled; | 234 touches[index].state = WebTouchPoint::StateCancelled; |
235 WebTouchEventTraits::ResetType( | 235 WebTouchEventTraits::ResetType( |
236 WebInputEvent::TouchCancel, timeStampSeconds, this); | 236 WebInputEvent::TouchCancel, timeStampSeconds, this); |
237 } | 237 } |
238 | 238 |
239 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) { | 239 void SyntheticWebTouchEvent::SetTimestamp(base::TimeTicks timestamp) { |
240 timeStampSeconds = timestamp.InSecondsF(); | 240 timeStampSeconds = ui::EventTimeStampToSeconds(timestamp); |
241 } | 241 } |
242 | 242 |
243 } // namespace content | 243 } // namespace content |
OLD | NEW |