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 11 matching lines...) Expand all Loading... |
22 #include "device/gamepad/public/cpp/gamepads.h" | 22 #include "device/gamepad/public/cpp/gamepads.h" |
23 #include "ppapi/c/pp_input_event.h" | 23 #include "ppapi/c/pp_input_event.h" |
24 #include "ppapi/shared_impl/ppb_input_event_shared.h" | 24 #include "ppapi/shared_impl/ppb_input_event_shared.h" |
25 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 25 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
26 #include "third_party/WebKit/public/platform/WebKeyboardEvent.h" | 26 #include "third_party/WebKit/public/platform/WebKeyboardEvent.h" |
27 #include "third_party/WebKit/public/platform/WebMouseWheelEvent.h" | 27 #include "third_party/WebKit/public/platform/WebMouseWheelEvent.h" |
28 #include "third_party/WebKit/public/platform/WebTouchEvent.h" | 28 #include "third_party/WebKit/public/platform/WebTouchEvent.h" |
29 #include "ui/events/keycodes/dom/keycode_converter.h" | 29 #include "ui/events/keycodes/dom/keycode_converter.h" |
30 | 30 |
31 using ppapi::InputEventData; | 31 using ppapi::InputEventData; |
| 32 using ppapi::TouchPointWithTilt; |
32 using blink::WebInputEvent; | 33 using blink::WebInputEvent; |
33 using blink::WebKeyboardEvent; | 34 using blink::WebKeyboardEvent; |
34 using blink::WebMouseEvent; | 35 using blink::WebMouseEvent; |
35 using blink::WebMouseWheelEvent; | 36 using blink::WebMouseWheelEvent; |
36 using blink::WebTouchEvent; | 37 using blink::WebTouchEvent; |
37 using blink::WebTouchPoint; | 38 using blink::WebTouchPoint; |
38 using blink::WebUChar; | 39 using blink::WebUChar; |
39 | 40 |
40 namespace content { | 41 namespace content { |
41 | 42 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 238 } |
238 | 239 |
239 enum IncludedTouchPointTypes { | 240 enum IncludedTouchPointTypes { |
240 ALL, // All pointers targetting the plugin. | 241 ALL, // All pointers targetting the plugin. |
241 ACTIVE, // Only pointers that are currently down. | 242 ACTIVE, // Only pointers that are currently down. |
242 CHANGED // Only pointers that have changed since the previous event. | 243 CHANGED // Only pointers that have changed since the previous event. |
243 }; | 244 }; |
244 void SetPPTouchPoints(const WebTouchPoint* touches, | 245 void SetPPTouchPoints(const WebTouchPoint* touches, |
245 uint32_t touches_length, | 246 uint32_t touches_length, |
246 IncludedTouchPointTypes included_types, | 247 IncludedTouchPointTypes included_types, |
247 std::vector<PP_TouchPoint>* result) { | 248 std::vector<TouchPointWithTilt>* result) { |
248 for (uint32_t i = 0; i < touches_length; i++) { | 249 for (uint32_t i = 0; i < touches_length; i++) { |
249 const WebTouchPoint& touch_point = touches[i]; | 250 const WebTouchPoint& touch_point = touches[i]; |
250 if (included_types == ACTIVE && | 251 if (included_types == ACTIVE && |
251 (touch_point.state == WebTouchPoint::kStateReleased || | 252 (touch_point.state == WebTouchPoint::kStateReleased || |
252 touch_point.state == WebTouchPoint::kStateCancelled)) { | 253 touch_point.state == WebTouchPoint::kStateCancelled)) { |
253 continue; | 254 continue; |
254 } | 255 } |
255 if (included_types == CHANGED && | 256 if (included_types == CHANGED && |
256 (touch_point.state == WebTouchPoint::kStateUndefined || | 257 (touch_point.state == WebTouchPoint::kStateUndefined || |
257 touch_point.state == WebTouchPoint::kStateStationary)) { | 258 touch_point.state == WebTouchPoint::kStateStationary)) { |
258 continue; | 259 continue; |
259 } | 260 } |
260 PP_TouchPoint pp_pt; | 261 PP_TouchPoint pp_pt; |
261 pp_pt.id = touch_point.id; | 262 pp_pt.id = touch_point.id; |
262 pp_pt.position.x = touch_point.position.x; | 263 pp_pt.position.x = touch_point.position.x; |
263 pp_pt.position.y = touch_point.position.y; | 264 pp_pt.position.y = touch_point.position.y; |
264 pp_pt.radius.x = touch_point.radius_x; | 265 pp_pt.radius.x = touch_point.radius_x; |
265 pp_pt.radius.y = touch_point.radius_y; | 266 pp_pt.radius.y = touch_point.radius_y; |
266 pp_pt.rotation_angle = touch_point.rotation_angle; | 267 pp_pt.rotation_angle = touch_point.rotation_angle; |
267 pp_pt.pressure = touch_point.force; | 268 pp_pt.pressure = touch_point.force; |
268 result->push_back(pp_pt); | 269 PP_FloatPoint pp_ft; |
| 270 pp_ft.x = touch_point.tilt_x; |
| 271 pp_ft.y = touch_point.tilt_y; |
| 272 TouchPointWithTilt touch_with_tilt{pp_pt, pp_ft}; |
| 273 result->push_back(touch_with_tilt); |
269 } | 274 } |
270 } | 275 } |
271 | 276 |
272 void AppendTouchEvent(const WebInputEvent& event, | 277 void AppendTouchEvent(const WebInputEvent& event, |
273 std::vector<InputEventData>* result_events) { | 278 std::vector<InputEventData>* result_events) { |
274 const WebTouchEvent& touch_event = | 279 const WebTouchEvent& touch_event = |
275 reinterpret_cast<const WebTouchEvent&>(event); | 280 reinterpret_cast<const WebTouchEvent&>(event); |
276 | 281 |
277 InputEventData result = GetEventWithCommonFieldsAndType(event); | 282 InputEventData result = GetEventWithCommonFieldsAndType(event); |
278 | 283 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 uint32_t id) { | 324 uint32_t id) { |
320 // Note: A brute force search to find the (potentially) existing touch point | 325 // Note: A brute force search to find the (potentially) existing touch point |
321 // is cheap given the small bound on |WebTouchEvent::kTouchesLengthCap|. | 326 // is cheap given the small bound on |WebTouchEvent::kTouchesLengthCap|. |
322 for (uint32_t i = 0; i < web_touches_length; ++i) { | 327 for (uint32_t i = 0; i < web_touches_length; ++i) { |
323 if (web_touches[i].id == static_cast<int>(id)) | 328 if (web_touches[i].id == static_cast<int>(id)) |
324 return true; | 329 return true; |
325 } | 330 } |
326 return false; | 331 return false; |
327 } | 332 } |
328 | 333 |
329 void SetWebTouchPointsIfNotYetSet(const std::vector<PP_TouchPoint>& pp_touches, | 334 void SetWebTouchPointsIfNotYetSet( |
330 WebTouchPoint::State state, | 335 const std::vector<TouchPointWithTilt>& pp_touches, |
331 WebTouchPoint* web_touches, | 336 WebTouchPoint::State state, |
332 uint32_t* web_touches_length) { | 337 WebTouchPoint* web_touches, |
| 338 uint32_t* web_touches_length) { |
333 const uint32_t initial_web_touches_length = *web_touches_length; | 339 const uint32_t initial_web_touches_length = *web_touches_length; |
334 const uint32_t touches_length = | 340 const uint32_t touches_length = |
335 std::min(static_cast<uint32_t>(pp_touches.size()), | 341 std::min(static_cast<uint32_t>(pp_touches.size()), |
336 static_cast<uint32_t>(WebTouchEvent::kTouchesLengthCap)); | 342 static_cast<uint32_t>(WebTouchEvent::kTouchesLengthCap)); |
337 for (uint32_t i = 0; i < touches_length; ++i) { | 343 for (uint32_t i = 0; i < touches_length; ++i) { |
338 const uint32_t touch_index = *web_touches_length; | 344 const uint32_t touch_index = *web_touches_length; |
339 if (touch_index >= static_cast<uint32_t>(WebTouchEvent::kTouchesLengthCap)) | 345 if (touch_index >= static_cast<uint32_t>(WebTouchEvent::kTouchesLengthCap)) |
340 return; | 346 return; |
341 | 347 |
342 const PP_TouchPoint& pp_pt = pp_touches[i]; | 348 const PP_TouchPoint& pp_pt = pp_touches[i].touch; |
343 if (HasTouchPointWithId(web_touches, initial_web_touches_length, pp_pt.id)) | 349 if (HasTouchPointWithId(web_touches, initial_web_touches_length, pp_pt.id)) |
344 continue; | 350 continue; |
345 | 351 |
346 web_touches[touch_index] = CreateWebTouchPoint(pp_pt, state); | 352 web_touches[touch_index] = CreateWebTouchPoint(pp_pt, state); |
347 ++(*web_touches_length); | 353 ++(*web_touches_length); |
348 } | 354 } |
349 } | 355 } |
350 | 356 |
351 WebTouchEvent* BuildTouchEvent(const InputEventData& event) { | 357 WebTouchEvent* BuildTouchEvent(const InputEventData& event) { |
352 WebTouchEvent* web_event = new WebTouchEvent(); | 358 WebTouchEvent* web_event = new WebTouchEvent(); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 return PP_INPUTEVENT_CLASS_TOUCH; | 766 return PP_INPUTEVENT_CLASS_TOUCH; |
761 case WebInputEvent::kTouchScrollStarted: | 767 case WebInputEvent::kTouchScrollStarted: |
762 return PP_InputEvent_Class(0); | 768 return PP_InputEvent_Class(0); |
763 default: | 769 default: |
764 CHECK(WebInputEvent::IsGestureEventType(event.GetType())); | 770 CHECK(WebInputEvent::IsGestureEventType(event.GetType())); |
765 return PP_InputEvent_Class(0); | 771 return PP_InputEvent_Class(0); |
766 } | 772 } |
767 } | 773 } |
768 | 774 |
769 } // namespace content | 775 } // namespace content |
OLD | NEW |