summaryrefslogtreecommitdiffstats
path: root/ppapi/shared_impl
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-21 23:15:10 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-21 23:15:10 +0000
commitcdf4e91a82d97b78c6b217a9423b762192a2fdcc (patch)
tree3eb688bef69938350a158531dac15b493be95ce0 /ppapi/shared_impl
parentdc169b24f5c68386dae030501f618cd9b805097a (diff)
downloadchromium_src-cdf4e91a82d97b78c6b217a9423b762192a2fdcc.zip
chromium_src-cdf4e91a82d97b78c6b217a9423b762192a2fdcc.tar.gz
chromium_src-cdf4e91a82d97b78c6b217a9423b762192a2fdcc.tar.bz2
ppapi: Add support for touch events.
The corresponding webkit side patch is at https://bugs.webkit.org/show_bug.cgi?id=89089 BUG=128236 TEST=manually, using the browser-plugin Review URL: https://chromiumcodereview.appspot.com/10543159 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl')
-rw-r--r--ppapi/shared_impl/ppb_input_event_shared.cc81
-rw-r--r--ppapi/shared_impl/ppb_input_event_shared.h12
2 files changed, 92 insertions, 1 deletions
diff --git a/ppapi/shared_impl/ppb_input_event_shared.cc b/ppapi/shared_impl/ppb_input_event_shared.cc
index 7b07de9..cc28027 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,
diff --git a/ppapi/shared_impl/ppb_input_event_shared.h b/ppapi/shared_impl/ppb_input_event_shared.h
index 74108b3..2518e9e 100644
--- a/ppapi/shared_impl/ppb_input_event_shared.h
+++ b/ppapi/shared_impl/ppb_input_event_shared.h
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "ppapi/c/ppb_input_event.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/thunk/ppb_input_event_api.h"
@@ -48,6 +49,10 @@ struct PPAPI_SHARED_EXPORT InputEventData {
int32_t composition_target_segment;
uint32_t composition_selection_start;
uint32_t composition_selection_end;
+
+ std::vector<PP_TouchPoint> touches;
+ std::vector<PP_TouchPoint> changed_touches;
+ std::vector<PP_TouchPoint> target_touches;
};
// This simple class implements the PPB_InputEvent_API in terms of the
@@ -83,6 +88,13 @@ class PPAPI_SHARED_EXPORT PPB_InputEvent_Shared
virtual uint32_t GetIMESegmentOffset(uint32_t index) OVERRIDE;
virtual int32_t GetIMETargetSegment() OVERRIDE;
virtual void GetIMESelection(uint32_t* start, uint32_t* end) OVERRIDE;
+ virtual void AddTouchPoint(PP_TouchListType list,
+ const PP_TouchPoint& point) OVERRIDE;
+ virtual uint32_t GetTouchCount(PP_TouchListType list) OVERRIDE;
+ virtual PP_TouchPoint GetTouchByIndex(PP_TouchListType list,
+ uint32_t index) OVERRIDE;
+ virtual PP_TouchPoint GetTouchById(PP_TouchListType list,
+ uint32_t id) OVERRIDE;
// Implementations for event creation.
static PP_Resource CreateIMEInputEvent(ResourceObjectType type,