Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(544)

Unified Diff: ppapi/shared_impl/ppb_input_event_shared.cc

Issue 10543159: ppapi: Add support for touch events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,

Powered by Google App Engine
This is Rietveld 408576698