Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: content/common/input/synthetic_web_input_event_builders.cc

Issue 999423003: Set the unique_event_id when converting from TouchEvent to WebTouchEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 float velocity_y, 144 float velocity_y,
144 blink::WebGestureDevice source_device) { 145 blink::WebGestureDevice source_device) {
145 WebGestureEvent result = Build(WebInputEvent::GestureFlingStart, 146 WebGestureEvent result = Build(WebInputEvent::GestureFlingStart,
146 source_device); 147 source_device);
147 result.data.flingStart.velocityX = velocity_x; 148 result.data.flingStart.velocityX = velocity_x;
148 result.data.flingStart.velocityY = velocity_y; 149 result.data.flingStart.velocityY = velocity_y;
149 return result; 150 return result;
150 } 151 }
151 152
152 SyntheticWebTouchEvent::SyntheticWebTouchEvent() : WebTouchEvent() { 153 SyntheticWebTouchEvent::SyntheticWebTouchEvent() : WebTouchEvent() {
154 uniqueTouchEventId = ui::GetNextTouchEventId();
153 SetTimestamp(base::TimeTicks::Now() - base::TimeTicks()); 155 SetTimestamp(base::TimeTicks::Now() - base::TimeTicks());
154 } 156 }
155 157
156 void SyntheticWebTouchEvent::ResetPoints() { 158 void SyntheticWebTouchEvent::ResetPoints() {
157 int point = 0; 159 int point = 0;
158 for (unsigned int i = 0; i < touchesLength; ++i) { 160 for (unsigned int i = 0; i < touchesLength; ++i) {
159 if (touches[i].state == WebTouchPoint::StateReleased) 161 if (touches[i].state == WebTouchPoint::StateReleased)
160 continue; 162 continue;
161 163
162 touches[point] = touches[i]; 164 touches[point] = touches[i];
163 touches[point].state = WebTouchPoint::StateStationary; 165 touches[point].state = WebTouchPoint::StateStationary;
164 ++point; 166 ++point;
165 } 167 }
166 touchesLength = point; 168 touchesLength = point;
167 type = WebInputEvent::Undefined; 169 type = WebInputEvent::Undefined;
168 causesScrollingIfUncanceled = false; 170 causesScrollingIfUncanceled = false;
169 } 171 }
170 172
171 int SyntheticWebTouchEvent::PressPoint(float x, float y) { 173 int SyntheticWebTouchEvent::PressPoint(float x, float y) {
172 if (touchesLength == touchesLengthCap) 174 if (touchesLength == touchesLengthCap)
173 return -1; 175 return -1;
174 WebTouchPoint& point = touches[touchesLength]; 176 WebTouchPoint& point = touches[touchesLength];
jdduke (slow) 2015/04/28 16:26:58 At some point, we'll probably need to assign a new
175 point.id = touchesLength; 177 point.id = touchesLength;
176 point.position.x = point.screenPosition.x = x; 178 point.position.x = point.screenPosition.x = x;
177 point.position.y = point.screenPosition.y = y; 179 point.position.y = point.screenPosition.y = y;
178 point.state = WebTouchPoint::StatePressed; 180 point.state = WebTouchPoint::StatePressed;
179 point.radiusX = point.radiusY = 1.f; 181 point.radiusX = point.radiusY = 1.f;
180 point.rotationAngle = 1.f; 182 point.rotationAngle = 1.f;
181 point.force = 1.f; 183 point.force = 1.f;
182 ++touchesLength; 184 ++touchesLength;
183 WebTouchEventTraits::ResetType( 185 WebTouchEventTraits::ResetType(
184 WebInputEvent::TouchStart, timeStampSeconds, this); 186 WebInputEvent::TouchStart, timeStampSeconds, this);
(...skipping 28 matching lines...) Expand all
213 touches[index].state = WebTouchPoint::StateCancelled; 215 touches[index].state = WebTouchPoint::StateCancelled;
214 WebTouchEventTraits::ResetType( 216 WebTouchEventTraits::ResetType(
215 WebInputEvent::TouchCancel, timeStampSeconds, this); 217 WebInputEvent::TouchCancel, timeStampSeconds, this);
216 } 218 }
217 219
218 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) { 220 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) {
219 timeStampSeconds = timestamp.InSecondsF(); 221 timeStampSeconds = timestamp.InSecondsF();
220 } 222 }
221 223
222 } // namespace content 224 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698