Index: ppapi/shared_impl/ppb_input_event_shared.cc |
diff --git a/ppapi/shared_impl/ppb_input_event_shared.cc b/ppapi/shared_impl/ppb_input_event_shared.cc |
index 7b07de9f502740cef4d2f1d58ee751246d144ef9..073b84bc3c05b1bd7d71f6a1c368feac84541f71 100644 |
--- a/ppapi/shared_impl/ppb_input_event_shared.cc |
+++ b/ppapi/shared_impl/ppb_input_event_shared.cc |
@@ -26,7 +26,10 @@ InputEventData::InputEventData() |
character_text(), |
composition_target_segment(-1), |
composition_selection_start(0), |
- composition_selection_end(0) { |
+ composition_selection_end(0), |
+ touches(), |
+ changed_touches(), |
+ target_touches() { |
} |
InputEventData::~InputEventData() { |
@@ -127,6 +130,65 @@ void PPB_InputEvent_Shared::GetIMESelection(uint32_t* start, uint32_t* end) { |
*end = data_.composition_selection_end; |
} |
+uint32_t PPB_InputEvent_Shared::GetTouchCount(PP_TouchListType list) { |
+ switch (list) { |
+ case PP_TOUCHLIST_TYPE_TOUCHES: |
+ return data_.touches.size(); |
+ case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES: |
+ return data_.changed_touches.size(); |
+ case PP_TOUCHLIST_TYPE_TARGETTOUCHES: |
+ return data_.target_touches.size(); |
+ default: |
+ return 0; |
+ } |
+ return data_.touches.size(); |
+} |
+ |
+PP_TouchPoint_Dev PPB_InputEvent_Shared::GetTouchByIndex(PP_TouchListType list, |
+ uint32_t index) { |
+ std::vector<PP_TouchPoint_Dev>* points; |
+ switch (list) { |
+ case PP_TOUCHLIST_TYPE_TOUCHES: |
+ points = &data_.touches; |
+ break; |
+ case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES: |
+ points = &data_.changed_touches; |
+ break; |
+ case PP_TOUCHLIST_TYPE_TARGETTOUCHES: |
+ points = &data_.target_touches; |
+ break; |
+ default: |
+ return PP_MakeTouchPoint(); |
+ } |
+ if (index >= points->size()) { |
+ return PP_MakeTouchPoint(); |
+ } |
+ return points->at(index); |
+} |
+ |
+PP_TouchPoint_Dev PPB_InputEvent_Shared::GetTouchById(PP_TouchListType list, |
+ uint32_t id) { |
+ const std::vector<PP_TouchPoint_Dev>* points; |
+ switch (list) { |
+ case PP_TOUCHLIST_TYPE_TOUCHES: |
+ points = &data_.touches; |
+ break; |
+ case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES: |
+ points = &data_.changed_touches; |
+ break; |
+ case PP_TOUCHLIST_TYPE_TARGETTOUCHES: |
+ points = &data_.target_touches; |
+ break; |
+ default: |
+ return PP_MakeTouchPoint(); |
+ } |
+ for (uint32_t i = 0; i < points->size(); i++) { |
brettw
2012/06/19 21:20:52
Can you use size_t here instead?
sadrul
2012/06/20 20:19:03
Done.
|
+ if (points->at(i).id == id) |
+ return points->at(i); |
+ } |
+ return PP_MakeTouchPoint(); |
+} |
+ |
//static |
PP_Resource PPB_InputEvent_Shared::CreateIMEInputEvent( |
ResourceObjectType type, |