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 c966224b39dd177dec6e08158e20edf2fc95eab2..0a9c25ef8bd1086b6c4d0537d656b33fe72c95c3 100644 |
--- a/ppapi/shared_impl/ppb_input_event_shared.cc |
+++ b/ppapi/shared_impl/ppb_input_event_shared.cc |
@@ -121,15 +121,16 @@ void PPB_InputEvent_Shared::GetIMESelection(uint32_t* start, uint32_t* end) { |
void PPB_InputEvent_Shared::AddTouchPoint(PP_TouchListType list, |
const PP_TouchPoint& point) { |
+ TouchPointWithTilt point_with_tilt{point, {0, 0}}; |
switch (list) { |
case PP_TOUCHLIST_TYPE_TOUCHES: |
- data_.touches.push_back(point); |
+ data_.touches.push_back(point_with_tilt); |
break; |
case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES: |
- data_.changed_touches.push_back(point); |
+ data_.changed_touches.push_back(point_with_tilt); |
break; |
case PP_TOUCHLIST_TYPE_TARGETTOUCHES: |
- data_.target_touches.push_back(point); |
+ data_.target_touches.push_back(point_with_tilt); |
break; |
default: |
break; |
@@ -149,51 +150,71 @@ uint32_t PPB_InputEvent_Shared::GetTouchCount(PP_TouchListType list) { |
return 0; |
} |
-PP_TouchPoint PPB_InputEvent_Shared::GetTouchByIndex(PP_TouchListType list, |
- uint32_t index) { |
- std::vector<PP_TouchPoint>* points; |
+std::vector<TouchPointWithTilt>* PPB_InputEvent_Shared::GetTouchListByType( |
+ PP_TouchListType list) { |
switch (list) { |
case PP_TOUCHLIST_TYPE_TOUCHES: |
- points = &data_.touches; |
+ return &data_.touches; |
break; |
bbudge
2017/05/23 18:28:47
breaks are unreachable, remove.
jkwang
2017/05/23 22:07:57
Done.
|
case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES: |
- points = &data_.changed_touches; |
+ return &data_.changed_touches; |
break; |
case PP_TOUCHLIST_TYPE_TARGETTOUCHES: |
- points = &data_.target_touches; |
+ return &data_.target_touches; |
break; |
default: |
- return PP_MakeTouchPoint(); |
+ return nullptr; |
} |
- if (index >= points->size()) { |
+} |
+ |
+PP_TouchPoint PPB_InputEvent_Shared::GetTouchByIndex(PP_TouchListType list, |
+ uint32_t index) { |
+ std::vector<TouchPointWithTilt>* points = GetTouchListByType(list); |
+ |
+ if (!points || index >= points->size()) { |
return PP_MakeTouchPoint(); |
} |
- return points->at(index); |
+ return points->at(index).touch; |
} |
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(); |
- } |
+ std::vector<TouchPointWithTilt>* points = GetTouchListByType(list); |
+ |
+ if (!points) |
+ return PP_MakeTouchPoint(); |
+ |
for (size_t i = 0; i < points->size(); i++) { |
- if (points->at(i).id == id) |
- return points->at(i); |
+ if (points->at(i).touch.id == id) |
+ return points->at(i).touch; |
} |
bbudge
2017/05/23 18:28:47
You could further reduce duplication by adding ano
jkwang
2017/05/23 22:07:57
Done.
|
return PP_MakeTouchPoint(); |
bbudge
2017/05/23 18:28:46
Then this function body would be just:
return Get
jkwang
2017/05/23 22:07:57
Done.
|
} |
+PP_FloatPoint PPB_InputEvent_Shared::GetTouchTiltByIndex(PP_TouchListType list, |
+ uint32_t index) { |
+ std::vector<TouchPointWithTilt>* points = GetTouchListByType(list); |
+ |
+ if (!points || index >= points->size()) { |
+ return PP_MakeFloatPoint(0, 0); |
+ } |
+ return points->at(index).tilt; |
+} |
+ |
+PP_FloatPoint PPB_InputEvent_Shared::GetTouchTiltById(PP_TouchListType list, |
+ uint32_t id) { |
+ std::vector<TouchPointWithTilt>* points = GetTouchListByType(list); |
+ |
+ if (!points) |
+ return PP_MakeFloatPoint(0, 0); |
+ |
+ for (size_t i = 0; i < points->size(); i++) { |
+ if (points->at(i).touch.id == id) |
+ return points->at(i).tilt; |
+ } |
+ return PP_MakeFloatPoint(0, 0); |
+} |
+ |
// static |
PP_Resource PPB_InputEvent_Shared::CreateIMEInputEvent( |
ResourceObjectType type, |