| 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 <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/i18n/char_iterator.h" | 10 #include "base/i18n/char_iterator.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversion_utils.h" | 15 #include "base/strings/utf_string_conversion_utils.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "content/common/input/web_touch_event_traits.h" |
| 17 #include "content/renderer/pepper/common.h" | 18 #include "content/renderer/pepper/common.h" |
| 18 #include "content/renderer/pepper/usb_key_code_conversion.h" | 19 #include "content/renderer/pepper/usb_key_code_conversion.h" |
| 19 #include "ppapi/c/pp_input_event.h" | 20 #include "ppapi/c/pp_input_event.h" |
| 20 #include "ppapi/shared_impl/ppb_input_event_shared.h" | 21 #include "ppapi/shared_impl/ppb_input_event_shared.h" |
| 21 #include "ppapi/shared_impl/time_conversion.h" | 22 #include "ppapi/shared_impl/time_conversion.h" |
| 22 #include "third_party/WebKit/public/platform/WebGamepads.h" | 23 #include "third_party/WebKit/public/platform/WebGamepads.h" |
| 23 #include "third_party/WebKit/public/platform/WebString.h" | 24 #include "third_party/WebKit/public/platform/WebString.h" |
| 24 #include "third_party/WebKit/public/web/WebInputEvent.h" | 25 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 25 | 26 |
| 26 using ppapi::EventTimeToPPTimeTicks; | 27 using ppapi::EventTimeToPPTimeTicks; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 pt.radiusY = pp_pt.radius.y; | 285 pt.radiusY = pp_pt.radius.y; |
| 285 pt.rotationAngle = pp_pt.rotation_angle; | 286 pt.rotationAngle = pp_pt.rotation_angle; |
| 286 web_touches[i] = pt; | 287 web_touches[i] = pt; |
| 287 (*web_touches_length)++; | 288 (*web_touches_length)++; |
| 288 } | 289 } |
| 289 } | 290 } |
| 290 | 291 |
| 291 WebTouchEvent* BuildTouchEvent(const InputEventData& event) { | 292 WebTouchEvent* BuildTouchEvent(const InputEventData& event) { |
| 292 WebTouchEvent* web_event = new WebTouchEvent(); | 293 WebTouchEvent* web_event = new WebTouchEvent(); |
| 293 WebTouchPoint::State state = WebTouchPoint::StateUndefined; | 294 WebTouchPoint::State state = WebTouchPoint::StateUndefined; |
| 295 WebInputEvent::Type type = WebInputEvent::Undefined; |
| 294 switch (event.event_type) { | 296 switch (event.event_type) { |
| 295 case PP_INPUTEVENT_TYPE_TOUCHSTART: | 297 case PP_INPUTEVENT_TYPE_TOUCHSTART: |
| 296 web_event->type = WebInputEvent::TouchStart; | 298 type = WebInputEvent::TouchStart; |
| 297 state = WebTouchPoint::StatePressed; | 299 state = WebTouchPoint::StatePressed; |
| 298 break; | 300 break; |
| 299 case PP_INPUTEVENT_TYPE_TOUCHMOVE: | 301 case PP_INPUTEVENT_TYPE_TOUCHMOVE: |
| 300 web_event->type = WebInputEvent::TouchMove; | 302 type = WebInputEvent::TouchMove; |
| 301 state = WebTouchPoint::StateMoved; | 303 state = WebTouchPoint::StateMoved; |
| 302 break; | 304 break; |
| 303 case PP_INPUTEVENT_TYPE_TOUCHEND: | 305 case PP_INPUTEVENT_TYPE_TOUCHEND: |
| 304 web_event->type = WebInputEvent::TouchEnd; | 306 type = WebInputEvent::TouchEnd; |
| 305 state = WebTouchPoint::StateReleased; | 307 state = WebTouchPoint::StateReleased; |
| 306 break; | 308 break; |
| 307 case PP_INPUTEVENT_TYPE_TOUCHCANCEL: | 309 case PP_INPUTEVENT_TYPE_TOUCHCANCEL: |
| 308 web_event->type = WebInputEvent::TouchCancel; | 310 type = WebInputEvent::TouchCancel; |
| 309 state = WebTouchPoint::StateCancelled; | 311 state = WebTouchPoint::StateCancelled; |
| 310 break; | 312 break; |
| 311 default: | 313 default: |
| 312 NOTREACHED(); | 314 NOTREACHED(); |
| 313 } | 315 } |
| 316 WebTouchEventTraits::ResetType( |
| 317 type, PPTimeTicksToEventTime(event.event_time_stamp), web_event); |
| 314 | 318 |
| 315 TouchStateMap states_map; | 319 TouchStateMap states_map; |
| 316 for (uint32_t i = 0; i < event.changed_touches.size(); i++) | 320 for (uint32_t i = 0; i < event.changed_touches.size(); i++) |
| 317 states_map[event.changed_touches[i].id] = state; | 321 states_map[event.changed_touches[i].id] = state; |
| 318 | 322 |
| 319 web_event->timeStampSeconds = PPTimeTicksToEventTime(event.event_time_stamp); | |
| 320 | |
| 321 SetWebTouchPoints(event.changed_touches, | 323 SetWebTouchPoints(event.changed_touches, |
| 322 states_map, | 324 states_map, |
| 323 web_event->changedTouches, | 325 web_event->changedTouches, |
| 324 &web_event->changedTouchesLength); | 326 &web_event->changedTouchesLength); |
| 325 | 327 |
| 326 SetWebTouchPoints( | 328 SetWebTouchPoints( |
| 327 event.touches, states_map, web_event->touches, &web_event->touchesLength); | 329 event.touches, states_map, web_event->touches, &web_event->touchesLength); |
| 328 | 330 |
| 329 SetWebTouchPoints(event.target_touches, | 331 SetWebTouchPoints(event.target_touches, |
| 330 states_map, | 332 states_map, |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 case WebInputEvent::TouchStart: | 731 case WebInputEvent::TouchStart: |
| 730 return PP_INPUTEVENT_CLASS_TOUCH; | 732 return PP_INPUTEVENT_CLASS_TOUCH; |
| 731 case WebInputEvent::Undefined: | 733 case WebInputEvent::Undefined: |
| 732 default: | 734 default: |
| 733 NOTREACHED(); | 735 NOTREACHED(); |
| 734 return PP_InputEvent_Class(0); | 736 return PP_InputEvent_Class(0); |
| 735 } | 737 } |
| 736 } | 738 } |
| 737 | 739 |
| 738 } // namespace content | 740 } // namespace content |
| OLD | NEW |