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

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

Issue 2173073003: Move WebInputEvent into public/platform from public/web (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gn build failure with android Created 4 years, 5 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/base_event_utils.h"
10 #include "ui/events/keycodes/keyboard_codes.h" 10 #include "ui/events/keycodes/keyboard_codes.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 touches[point].state = WebTouchPoint::StateStationary; 182 touches[point].state = WebTouchPoint::StateStationary;
183 ++point; 183 ++point;
184 } 184 }
185 touchesLength = point; 185 touchesLength = point;
186 type = WebInputEvent::Undefined; 186 type = WebInputEvent::Undefined;
187 movedBeyondSlopRegion = false; 187 movedBeyondSlopRegion = false;
188 uniqueTouchEventId = ui::GetNextTouchEventId(); 188 uniqueTouchEventId = ui::GetNextTouchEventId();
189 } 189 }
190 190
191 int SyntheticWebTouchEvent::PressPoint(float x, float y) { 191 int SyntheticWebTouchEvent::PressPoint(float x, float y) {
192 if (touchesLength == touchesLengthCap) 192 if (touchesLength == kTouchesLengthCap)
193 return -1; 193 return -1;
194 WebTouchPoint& point = touches[touchesLength]; 194 WebTouchPoint& point = touches[touchesLength];
195 point.id = touchesLength; 195 point.id = touchesLength;
196 point.position.x = point.screenPosition.x = x; 196 point.position.x = point.screenPosition.x = x;
197 point.position.y = point.screenPosition.y = y; 197 point.position.y = point.screenPosition.y = y;
198 point.state = WebTouchPoint::StatePressed; 198 point.state = WebTouchPoint::StatePressed;
199 point.radiusX = point.radiusY = 1.f; 199 point.radiusX = point.radiusY = 1.f;
200 point.rotationAngle = 1.f; 200 point.rotationAngle = 1.f;
201 point.force = 1.f; 201 point.force = 1.f;
202 point.tiltX = point.tiltY = 0; 202 point.tiltX = point.tiltY = 0;
203 ++touchesLength; 203 ++touchesLength;
204 WebTouchEventTraits::ResetType( 204 WebTouchEventTraits::ResetType(
205 WebInputEvent::TouchStart, timeStampSeconds, this); 205 WebInputEvent::TouchStart, timeStampSeconds, this);
206 return point.id; 206 return point.id;
207 } 207 }
208 208
209 void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) { 209 void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) {
210 CHECK_GE(index, 0); 210 CHECK_GE(index, 0);
211 CHECK_LT(index, touchesLengthCap); 211 CHECK_LT(index, kTouchesLengthCap);
212 // Always set this bit to avoid otherwise unexpected touchmove suppression. 212 // Always set this bit to avoid otherwise unexpected touchmove suppression.
213 // The caller can opt-out explicitly, if necessary. 213 // The caller can opt-out explicitly, if necessary.
214 movedBeyondSlopRegion = true; 214 movedBeyondSlopRegion = true;
215 WebTouchPoint& point = touches[index]; 215 WebTouchPoint& point = touches[index];
216 point.position.x = point.screenPosition.x = x; 216 point.position.x = point.screenPosition.x = x;
217 point.position.y = point.screenPosition.y = y; 217 point.position.y = point.screenPosition.y = y;
218 touches[index].state = WebTouchPoint::StateMoved; 218 touches[index].state = WebTouchPoint::StateMoved;
219 WebTouchEventTraits::ResetType( 219 WebTouchEventTraits::ResetType(
220 WebInputEvent::TouchMove, timeStampSeconds, this); 220 WebInputEvent::TouchMove, timeStampSeconds, this);
221 } 221 }
222 222
223 void SyntheticWebTouchEvent::ReleasePoint(int index) { 223 void SyntheticWebTouchEvent::ReleasePoint(int index) {
224 CHECK_GE(index, 0); 224 CHECK_GE(index, 0);
225 CHECK_LT(index, touchesLengthCap); 225 CHECK_LT(index, kTouchesLengthCap);
226 touches[index].state = WebTouchPoint::StateReleased; 226 touches[index].state = WebTouchPoint::StateReleased;
227 WebTouchEventTraits::ResetType( 227 WebTouchEventTraits::ResetType(
228 WebInputEvent::TouchEnd, timeStampSeconds, this); 228 WebInputEvent::TouchEnd, timeStampSeconds, this);
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, kTouchesLengthCap);
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::TimeTicks timestamp) { 239 void SyntheticWebTouchEvent::SetTimestamp(base::TimeTicks timestamp) {
240 timeStampSeconds = ui::EventTimeStampToSeconds(timestamp); 240 timeStampSeconds = ui::EventTimeStampToSeconds(timestamp);
241 } 241 }
242 242
243 } // namespace content 243 } // namespace content
OLDNEW
« no previous file with comments | « content/common/input/event_with_latency_info.cc ('k') | content/renderer/pepper/event_conversion.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698