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 "ppapi/c/pp_errors.h" | 5 #include "ppapi/c/pp_errors.h" |
6 #include "ppapi/thunk/thunk.h" | |
7 #include "ppapi/thunk/enter.h" | 6 #include "ppapi/thunk/enter.h" |
8 #include "ppapi/thunk/ppb_input_event_api.h" | 7 #include "ppapi/thunk/ppb_input_event_api.h" |
9 #include "ppapi/thunk/ppb_instance_api.h" | 8 #include "ppapi/thunk/ppb_instance_api.h" |
10 #include "ppapi/thunk/resource_creation_api.h" | 9 #include "ppapi/thunk/resource_creation_api.h" |
| 10 #include "ppapi/thunk/thunk.h" |
11 | 11 |
12 namespace ppapi { | 12 namespace ppapi { |
13 namespace thunk { | 13 namespace thunk { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 typedef EnterResource<PPB_InputEvent_API> EnterInputEvent; | 17 typedef EnterResource<PPB_InputEvent_API> EnterInputEvent; |
18 | 18 |
19 // InputEvent ------------------------------------------------------------------ | 19 // InputEvent ------------------------------------------------------------------ |
20 | 20 |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 const PPB_IMEInputEvent_Dev_0_2 g_ppb_ime_input_event_0_2_thunk = { | 372 const PPB_IMEInputEvent_Dev_0_2 g_ppb_ime_input_event_0_2_thunk = { |
373 &CreateIMEInputEvent, | 373 &CreateIMEInputEvent, |
374 &IsIMEInputEvent, | 374 &IsIMEInputEvent, |
375 &GetIMEText, | 375 &GetIMEText, |
376 &GetIMESegmentNumber, | 376 &GetIMESegmentNumber, |
377 &GetIMESegmentOffset, | 377 &GetIMESegmentOffset, |
378 &GetIMETargetSegment, | 378 &GetIMETargetSegment, |
379 &GetIMESelection | 379 &GetIMESelection |
380 }; | 380 }; |
381 | 381 |
| 382 // Touch ----------------------------------------------------------------------- |
| 383 |
| 384 PP_Resource CreateTouchInputEvent(PP_Instance instance, |
| 385 PP_InputEvent_Type type, |
| 386 PP_TimeTicks time_stamp, |
| 387 uint32_t modifiers) { |
| 388 EnterResourceCreation enter(instance); |
| 389 if (enter.failed()) |
| 390 return 0; |
| 391 // TODO(sad): |
| 392 return 0; |
| 393 } |
| 394 |
| 395 void AddTouchPoint(PP_Resource touch_event, |
| 396 PP_TouchListType list, |
| 397 const PP_TouchPoint* point) { |
| 398 EnterInputEvent enter(touch_event, true); |
| 399 if (enter.failed()) |
| 400 return; |
| 401 return enter.object()->AddTouchPoint(list, *point); |
| 402 } |
| 403 |
| 404 PP_Bool IsTouchInputEvent(PP_Resource resource) { |
| 405 if (!IsInputEvent(resource)) |
| 406 return PP_FALSE; // Prevent warning log in GetType. |
| 407 PP_InputEvent_Type type = GetType(resource); |
| 408 return PP_FromBool(type == PP_INPUTEVENT_TYPE_TOUCHSTART || |
| 409 type == PP_INPUTEVENT_TYPE_TOUCHMOVE || |
| 410 type == PP_INPUTEVENT_TYPE_TOUCHEND || |
| 411 type == PP_INPUTEVENT_TYPE_TOUCHCANCEL); |
| 412 } |
| 413 |
| 414 uint32_t GetTouchCount(PP_Resource touch_event, PP_TouchListType list) { |
| 415 EnterInputEvent enter(touch_event, true); |
| 416 if (enter.failed()) |
| 417 return 0; |
| 418 return enter.object()->GetTouchCount(list); |
| 419 } |
| 420 |
| 421 struct PP_TouchPoint GetTouchByIndex(PP_Resource touch_event, |
| 422 PP_TouchListType list, |
| 423 uint32_t index) { |
| 424 EnterInputEvent enter(touch_event, true); |
| 425 if (enter.failed()) |
| 426 return PP_MakeTouchPoint(); |
| 427 return enter.object()->GetTouchByIndex(list, index); |
| 428 } |
| 429 |
| 430 struct PP_TouchPoint GetTouchById(PP_Resource touch_event, |
| 431 PP_TouchListType list, |
| 432 uint32_t id) { |
| 433 EnterInputEvent enter(touch_event, true); |
| 434 if (enter.failed()) |
| 435 return PP_MakeTouchPoint(); |
| 436 return enter.object()->GetTouchById(list, id); |
| 437 } |
| 438 |
| 439 const PPB_TouchInputEvent_1_0 g_ppb_touch_input_event_thunk = { |
| 440 &CreateTouchInputEvent, |
| 441 &AddTouchPoint, |
| 442 &IsTouchInputEvent, |
| 443 &GetTouchCount, |
| 444 &GetTouchByIndex, |
| 445 &GetTouchById |
| 446 }; |
| 447 |
382 } // namespace | 448 } // namespace |
383 | 449 |
384 const PPB_InputEvent_1_0* GetPPB_InputEvent_1_0_Thunk() { | 450 const PPB_InputEvent_1_0* GetPPB_InputEvent_1_0_Thunk() { |
385 return &g_ppb_input_event_thunk; | 451 return &g_ppb_input_event_thunk; |
386 } | 452 } |
387 | 453 |
388 const PPB_MouseInputEvent_1_0* GetPPB_MouseInputEvent_1_0_Thunk() { | 454 const PPB_MouseInputEvent_1_0* GetPPB_MouseInputEvent_1_0_Thunk() { |
389 return &g_ppb_mouse_input_event_1_0_thunk; | 455 return &g_ppb_mouse_input_event_1_0_thunk; |
390 } | 456 } |
391 | 457 |
(...skipping 15 matching lines...) Expand all Loading... |
407 } | 473 } |
408 | 474 |
409 const PPB_IMEInputEvent_Dev_0_1* GetPPB_IMEInputEvent_Dev_0_1_Thunk() { | 475 const PPB_IMEInputEvent_Dev_0_1* GetPPB_IMEInputEvent_Dev_0_1_Thunk() { |
410 return &g_ppb_ime_input_event_0_1_thunk; | 476 return &g_ppb_ime_input_event_0_1_thunk; |
411 } | 477 } |
412 | 478 |
413 const PPB_IMEInputEvent_Dev_0_2* GetPPB_IMEInputEvent_Dev_0_2_Thunk() { | 479 const PPB_IMEInputEvent_Dev_0_2* GetPPB_IMEInputEvent_Dev_0_2_Thunk() { |
414 return &g_ppb_ime_input_event_0_2_thunk; | 480 return &g_ppb_ime_input_event_0_2_thunk; |
415 } | 481 } |
416 | 482 |
| 483 const PPB_TouchInputEvent_1_0* GetPPB_TouchInputEvent_Thunk() { |
| 484 return &g_ppb_touch_input_event_thunk; |
| 485 } |
| 486 |
417 } // namespace thunk | 487 } // namespace thunk |
418 } // namespace ppapi | 488 } // namespace ppapi |
OLD | NEW |