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/keycodes/keyboard_codes.h" | 9 #include "ui/events/keycodes/keyboard_codes.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 namespace { | |
14 | |
15 uint64 get_next_event_id() { | |
tdresser
2015/04/08 12:24:26
Can we factor this method out into a helper somewh
lanwei
2015/04/09 04:14:28
Done.
| |
16 // Set the first unique_id_ to 1 because we set id to 0 for other types | |
17 // of events. | |
18 static uint64 id = 1; | |
19 if (id==0) | |
20 id++; | |
21 DCHECK_NE(id, 0UL); | |
22 return id++; | |
23 } | |
24 | |
25 } // namespace | |
26 | |
13 using blink::WebInputEvent; | 27 using blink::WebInputEvent; |
14 using blink::WebKeyboardEvent; | 28 using blink::WebKeyboardEvent; |
15 using blink::WebGestureEvent; | 29 using blink::WebGestureEvent; |
16 using blink::WebMouseEvent; | 30 using blink::WebMouseEvent; |
17 using blink::WebMouseWheelEvent; | 31 using blink::WebMouseWheelEvent; |
18 using blink::WebTouchEvent; | 32 using blink::WebTouchEvent; |
19 using blink::WebTouchPoint; | 33 using blink::WebTouchPoint; |
20 | 34 |
21 WebMouseEvent SyntheticWebMouseEventBuilder::Build( | 35 WebMouseEvent SyntheticWebMouseEventBuilder::Build( |
22 blink::WebInputEvent::Type type) { | 36 blink::WebInputEvent::Type type) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 float velocity_y, | 157 float velocity_y, |
144 blink::WebGestureDevice source_device) { | 158 blink::WebGestureDevice source_device) { |
145 WebGestureEvent result = Build(WebInputEvent::GestureFlingStart, | 159 WebGestureEvent result = Build(WebInputEvent::GestureFlingStart, |
146 source_device); | 160 source_device); |
147 result.data.flingStart.velocityX = velocity_x; | 161 result.data.flingStart.velocityX = velocity_x; |
148 result.data.flingStart.velocityY = velocity_y; | 162 result.data.flingStart.velocityY = velocity_y; |
149 return result; | 163 return result; |
150 } | 164 } |
151 | 165 |
152 SyntheticWebTouchEvent::SyntheticWebTouchEvent() : WebTouchEvent() { | 166 SyntheticWebTouchEvent::SyntheticWebTouchEvent() : WebTouchEvent() { |
167 uniqueTouchEventId = get_next_event_id(); | |
153 SetTimestamp(base::TimeTicks::Now() - base::TimeTicks()); | 168 SetTimestamp(base::TimeTicks::Now() - base::TimeTicks()); |
154 } | 169 } |
155 | 170 |
156 void SyntheticWebTouchEvent::ResetPoints() { | 171 void SyntheticWebTouchEvent::ResetPoints() { |
157 int point = 0; | 172 int point = 0; |
158 for (unsigned int i = 0; i < touchesLength; ++i) { | 173 for (unsigned int i = 0; i < touchesLength; ++i) { |
159 if (touches[i].state == WebTouchPoint::StateReleased) | 174 if (touches[i].state == WebTouchPoint::StateReleased) |
160 continue; | 175 continue; |
161 | 176 |
162 touches[point] = touches[i]; | 177 touches[point] = touches[i]; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 touches[index].state = WebTouchPoint::StateCancelled; | 228 touches[index].state = WebTouchPoint::StateCancelled; |
214 WebTouchEventTraits::ResetType( | 229 WebTouchEventTraits::ResetType( |
215 WebInputEvent::TouchCancel, timeStampSeconds, this); | 230 WebInputEvent::TouchCancel, timeStampSeconds, this); |
216 } | 231 } |
217 | 232 |
218 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) { | 233 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) { |
219 timeStampSeconds = timestamp.InSecondsF(); | 234 timeStampSeconds = timestamp.InSecondsF(); |
220 } | 235 } |
221 | 236 |
222 } // namespace content | 237 } // namespace content |
OLD | NEW |