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

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

Issue 788923002: Touch Events - changedTouches list includes non-changed touch points on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit test for checking Pointer states when other than position changed. Created 5 years, 10 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/keycodes/keyboard_codes.h" 9 #include "ui/events/keycodes/keyboard_codes.h"
10 10
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 int SyntheticWebTouchEvent::PressPoint(float x, float y) { 171 int SyntheticWebTouchEvent::PressPoint(float x, float y) {
172 if (touchesLength == touchesLengthCap) 172 if (touchesLength == touchesLengthCap)
173 return -1; 173 return -1;
174 WebTouchPoint& point = touches[touchesLength]; 174 WebTouchPoint& point = touches[touchesLength];
175 point.id = touchesLength; 175 point.id = touchesLength;
176 point.position.x = point.screenPosition.x = x; 176 point.position.x = point.screenPosition.x = x;
177 point.position.y = point.screenPosition.y = y; 177 point.position.y = point.screenPosition.y = y;
178 point.state = WebTouchPoint::StatePressed; 178 point.state = WebTouchPoint::StatePressed;
179 point.radiusX = point.radiusY = 1.f; 179 point.radiusX = point.radiusY = 1.f;
180 // Lets give some default values for testing.
181 point.rotationAngle = 1.f;
182 point.force = 1.f;
183
180 ++touchesLength; 184 ++touchesLength;
181 WebTouchEventTraits::ResetType( 185 WebTouchEventTraits::ResetType(
182 WebInputEvent::TouchStart, timeStampSeconds, this); 186 WebInputEvent::TouchStart, timeStampSeconds, this);
183 return point.id; 187 return point.id;
184 } 188 }
185 189
186 void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) { 190 void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) {
187 CHECK_GE(index, 0); 191 CHECK_GE(index, 0);
188 CHECK_LT(index, touchesLengthCap); 192 CHECK_LT(index, touchesLengthCap);
189 // Always set this bit to avoid otherwise unexpected touchmove suppression. 193 // Always set this bit to avoid otherwise unexpected touchmove suppression.
190 // The caller can opt-out explicitly, if necessary. 194 // The caller can opt-out explicitly, if necessary.
191 causesScrollingIfUncanceled = true; 195 causesScrollingIfUncanceled = true;
192 WebTouchPoint& point = touches[index]; 196 WebTouchPoint& point = touches[index];
193 point.position.x = point.screenPosition.x = x; 197 point.position.x = point.screenPosition.x = x;
194 point.position.y = point.screenPosition.y = y; 198 point.position.y = point.screenPosition.y = y;
195 touches[index].state = WebTouchPoint::StateMoved; 199 touches[index].state = WebTouchPoint::StateMoved;
196 WebTouchEventTraits::ResetType( 200 WebTouchEventTraits::ResetType(
197 WebInputEvent::TouchMove, timeStampSeconds, this); 201 WebInputEvent::TouchMove, timeStampSeconds, this);
198 } 202 }
199 203
204 void SyntheticWebTouchEvent::ChangePointRadius(
205 int index,
206 float radiusX,
207 float radiusY) {
208 CHECK_GE(index, 0);
209 CHECK_LT(index, touchesLengthCap);
210 // Set this bit as in MovePoint().
211 causesScrollingIfUncanceled = true;
212 WebTouchPoint& point = touches[index];
213 point.radiusX = radiusX;
214 point.radiusY = radiusY;
215 touches[index].state = WebTouchPoint::StateMoved;
216 WebTouchEventTraits::ResetType(
217 WebInputEvent::TouchMove, timeStampSeconds, this);
218 }
219
220 void SyntheticWebTouchEvent::ChangePointRotationAngleAndForce(
221 int index,
222 float rotationAngle,
223 float force) {
224 CHECK_GE(index, 0);
225 CHECK_LT(index, touchesLengthCap);
226 // Set this bit as in MovePoint().
227 causesScrollingIfUncanceled = true;
228 WebTouchPoint& point = touches[index];
229 point.rotationAngle = rotationAngle;
230 point.force = force;
231 touches[index].state = WebTouchPoint::StateMoved;
232 WebTouchEventTraits::ResetType(
233 WebInputEvent::TouchMove, timeStampSeconds, this);
234 }
235
200 void SyntheticWebTouchEvent::ReleasePoint(int index) { 236 void SyntheticWebTouchEvent::ReleasePoint(int index) {
201 CHECK_GE(index, 0); 237 CHECK_GE(index, 0);
202 CHECK_LT(index, touchesLengthCap); 238 CHECK_LT(index, touchesLengthCap);
203 touches[index].state = WebTouchPoint::StateReleased; 239 touches[index].state = WebTouchPoint::StateReleased;
204 WebTouchEventTraits::ResetType( 240 WebTouchEventTraits::ResetType(
205 WebInputEvent::TouchEnd, timeStampSeconds, this); 241 WebInputEvent::TouchEnd, timeStampSeconds, this);
206 } 242 }
207 243
208 void SyntheticWebTouchEvent::CancelPoint(int index) { 244 void SyntheticWebTouchEvent::CancelPoint(int index) {
209 CHECK_GE(index, 0); 245 CHECK_GE(index, 0);
210 CHECK_LT(index, touchesLengthCap); 246 CHECK_LT(index, touchesLengthCap);
211 touches[index].state = WebTouchPoint::StateCancelled; 247 touches[index].state = WebTouchPoint::StateCancelled;
212 WebTouchEventTraits::ResetType( 248 WebTouchEventTraits::ResetType(
213 WebInputEvent::TouchCancel, timeStampSeconds, this); 249 WebInputEvent::TouchCancel, timeStampSeconds, this);
214 } 250 }
215 251
216 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) { 252 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) {
217 timeStampSeconds = timestamp.InSecondsF(); 253 timeStampSeconds = timestamp.InSecondsF();
218 } 254 }
219 255
220 } // namespace content 256 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698