OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/pepper/event_conversion.h" | 5 #include "content/renderer/pepper/event_conversion.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 pt.radiusY = pp_pt.radius.y; | 283 pt.radiusY = pp_pt.radius.y; |
284 pt.rotationAngle = pp_pt.rotation_angle; | 284 pt.rotationAngle = pp_pt.rotation_angle; |
285 pt.state = state; | 285 pt.state = state; |
286 return pt; | 286 return pt; |
287 } | 287 } |
288 | 288 |
289 bool HasTouchPointWithId(const WebTouchPoint* web_touches, | 289 bool HasTouchPointWithId(const WebTouchPoint* web_touches, |
290 uint32_t web_touches_length, | 290 uint32_t web_touches_length, |
291 uint32_t id) { | 291 uint32_t id) { |
292 // Note: A brute force search to find the (potentially) existing touch point | 292 // Note: A brute force search to find the (potentially) existing touch point |
293 // is cheap given the small bound on |WebTouchEvent::touchesLengthCap|. | 293 // is cheap given the small bound on |WebTouchEvent::kTouchesLengthCap|. |
294 for (uint32_t i = 0; i < web_touches_length; ++i) { | 294 for (uint32_t i = 0; i < web_touches_length; ++i) { |
295 if (web_touches[i].id == static_cast<int>(id)) | 295 if (web_touches[i].id == static_cast<int>(id)) |
296 return true; | 296 return true; |
297 } | 297 } |
298 return false; | 298 return false; |
299 } | 299 } |
300 | 300 |
301 void SetWebTouchPointsIfNotYetSet(const std::vector<PP_TouchPoint>& pp_touches, | 301 void SetWebTouchPointsIfNotYetSet(const std::vector<PP_TouchPoint>& pp_touches, |
302 WebTouchPoint::State state, | 302 WebTouchPoint::State state, |
303 WebTouchPoint* web_touches, | 303 WebTouchPoint* web_touches, |
304 uint32_t* web_touches_length) { | 304 uint32_t* web_touches_length) { |
305 const uint32_t initial_web_touches_length = *web_touches_length; | 305 const uint32_t initial_web_touches_length = *web_touches_length; |
306 const uint32_t touches_length = | 306 const uint32_t touches_length = |
307 std::min(static_cast<uint32_t>(pp_touches.size()), | 307 std::min(static_cast<uint32_t>(pp_touches.size()), |
308 static_cast<uint32_t>(WebTouchEvent::touchesLengthCap)); | 308 static_cast<uint32_t>(WebTouchEvent::kTouchesLengthCap)); |
309 for (uint32_t i = 0; i < touches_length; ++i) { | 309 for (uint32_t i = 0; i < touches_length; ++i) { |
310 const uint32_t touch_index = *web_touches_length; | 310 const uint32_t touch_index = *web_touches_length; |
311 if (touch_index >= static_cast<uint32_t>(WebTouchEvent::touchesLengthCap)) | 311 if (touch_index >= static_cast<uint32_t>(WebTouchEvent::kTouchesLengthCap)) |
312 return; | 312 return; |
313 | 313 |
314 const PP_TouchPoint& pp_pt = pp_touches[i]; | 314 const PP_TouchPoint& pp_pt = pp_touches[i]; |
315 if (HasTouchPointWithId(web_touches, initial_web_touches_length, pp_pt.id)) | 315 if (HasTouchPointWithId(web_touches, initial_web_touches_length, pp_pt.id)) |
316 continue; | 316 continue; |
317 | 317 |
318 web_touches[touch_index] = CreateWebTouchPoint(pp_pt, state); | 318 web_touches[touch_index] = CreateWebTouchPoint(pp_pt, state); |
319 ++(*web_touches_length); | 319 ++(*web_touches_length); |
320 } | 320 } |
321 } | 321 } |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 return PP_INPUTEVENT_CLASS_TOUCH; | 740 return PP_INPUTEVENT_CLASS_TOUCH; |
741 case WebInputEvent::TouchScrollStarted: | 741 case WebInputEvent::TouchScrollStarted: |
742 return PP_InputEvent_Class(0); | 742 return PP_InputEvent_Class(0); |
743 default: | 743 default: |
744 CHECK(WebInputEvent::isGestureEventType(type)); | 744 CHECK(WebInputEvent::isGestureEventType(type)); |
745 return PP_InputEvent_Class(0); | 745 return PP_InputEvent_Class(0); |
746 } | 746 } |
747 } | 747 } |
748 | 748 |
749 } // namespace content | 749 } // namespace content |
OLD | NEW |