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

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
« no previous file with comments | « ppapi/shared_impl/ppb_input_event_shared.h ('k') | ppapi/tests/all_c_includes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..cc280278bc0d8ce08d05249a5c2b89ad08206897 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,82 @@ void PPB_InputEvent_Shared::GetIMESelection(uint32_t* start, uint32_t* end) {
*end = data_.composition_selection_end;
}
+void PPB_InputEvent_Shared::AddTouchPoint(PP_TouchListType list,
+ const PP_TouchPoint& point) {
+ switch (list) {
+ case PP_TOUCHLIST_TYPE_TOUCHES:
+ data_.touches.push_back(point);
+ break;
+ case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES:
+ data_.changed_touches.push_back(point);
+ break;
+ case PP_TOUCHLIST_TYPE_TARGETTOUCHES:
+ data_.target_touches.push_back(point);
+ break;
+ default:
+ break;
+ }
+}
+
+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 PPB_InputEvent_Shared::GetTouchByIndex(PP_TouchListType list,
+ uint32_t index) {
+ std::vector<PP_TouchPoint>* 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 PPB_InputEvent_Shared::GetTouchById(PP_TouchListType list,
+ uint32_t id) {
+ const std::vector<PP_TouchPoint>* 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 (size_t i = 0; i < points->size(); i++) {
+ if (points->at(i).id == id)
+ return points->at(i);
+ }
+ return PP_MakeTouchPoint();
+}
+
//static
PP_Resource PPB_InputEvent_Shared::CreateIMEInputEvent(
ResourceObjectType type,
« no previous file with comments | « ppapi/shared_impl/ppb_input_event_shared.h ('k') | ppapi/tests/all_c_includes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698