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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/shared_impl/ppb_input_event_shared.h" 5 #include "ppapi/shared_impl/ppb_input_event_shared.h"
6 6
7 #include "ppapi/shared_impl/var.h" 7 #include "ppapi/shared_impl/var.h"
8 8
9 using ppapi::thunk::PPB_InputEvent_API; 9 using ppapi::thunk::PPB_InputEvent_API;
10 10
11 namespace ppapi { 11 namespace ppapi {
12 12
13 InputEventData::InputEventData() 13 InputEventData::InputEventData()
14 : is_filtered(false), 14 : is_filtered(false),
15 event_type(PP_INPUTEVENT_TYPE_UNDEFINED), 15 event_type(PP_INPUTEVENT_TYPE_UNDEFINED),
16 event_time_stamp(0.0), 16 event_time_stamp(0.0),
17 event_modifiers(0), 17 event_modifiers(0),
18 mouse_button(PP_INPUTEVENT_MOUSEBUTTON_NONE), 18 mouse_button(PP_INPUTEVENT_MOUSEBUTTON_NONE),
19 mouse_position(PP_MakePoint(0, 0)), 19 mouse_position(PP_MakePoint(0, 0)),
20 mouse_click_count(0), 20 mouse_click_count(0),
21 mouse_movement(PP_MakePoint(0, 0)), 21 mouse_movement(PP_MakePoint(0, 0)),
22 wheel_delta(PP_MakeFloatPoint(0.0f, 0.0f)), 22 wheel_delta(PP_MakeFloatPoint(0.0f, 0.0f)),
23 wheel_ticks(PP_MakeFloatPoint(0.0f, 0.0f)), 23 wheel_ticks(PP_MakeFloatPoint(0.0f, 0.0f)),
24 wheel_scroll_by_page(false), 24 wheel_scroll_by_page(false),
25 key_code(0), 25 key_code(0),
26 character_text(), 26 character_text(),
27 composition_target_segment(-1), 27 composition_target_segment(-1),
28 composition_selection_start(0), 28 composition_selection_start(0),
29 composition_selection_end(0) { 29 composition_selection_end(0),
30 touches(),
31 changed_touches(),
32 target_touches() {
30 } 33 }
31 34
32 InputEventData::~InputEventData() { 35 InputEventData::~InputEventData() {
33 } 36 }
34 37
35 PPB_InputEvent_Shared::PPB_InputEvent_Shared(ResourceObjectType type, 38 PPB_InputEvent_Shared::PPB_InputEvent_Shared(ResourceObjectType type,
36 PP_Instance instance, 39 PP_Instance instance,
37 const InputEventData& data) 40 const InputEventData& data)
38 : Resource(type, instance), 41 : Resource(type, instance),
39 data_(data) { 42 data_(data) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return data_.composition_target_segment; 123 return data_.composition_target_segment;
121 } 124 }
122 125
123 void PPB_InputEvent_Shared::GetIMESelection(uint32_t* start, uint32_t* end) { 126 void PPB_InputEvent_Shared::GetIMESelection(uint32_t* start, uint32_t* end) {
124 if (start) 127 if (start)
125 *start = data_.composition_selection_start; 128 *start = data_.composition_selection_start;
126 if (end) 129 if (end)
127 *end = data_.composition_selection_end; 130 *end = data_.composition_selection_end;
128 } 131 }
129 132
133 uint32_t PPB_InputEvent_Shared::GetTouchCount(PP_TouchListType list) {
134 switch (list) {
135 case PP_TOUCHLIST_TYPE_TOUCHES:
136 return data_.touches.size();
137 case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES:
138 return data_.changed_touches.size();
139 case PP_TOUCHLIST_TYPE_TARGETTOUCHES:
140 return data_.target_touches.size();
141 default:
142 return 0;
143 }
144 return data_.touches.size();
145 }
146
147 PP_TouchPoint_Dev PPB_InputEvent_Shared::GetTouchByIndex(PP_TouchListType list,
148 uint32_t index) {
149 std::vector<PP_TouchPoint_Dev>* points;
150 switch (list) {
151 case PP_TOUCHLIST_TYPE_TOUCHES:
152 points = &data_.touches;
153 break;
154 case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES:
155 points = &data_.changed_touches;
156 break;
157 case PP_TOUCHLIST_TYPE_TARGETTOUCHES:
158 points = &data_.target_touches;
159 break;
160 default:
161 return PP_MakeTouchPoint();
162 }
163 if (index >= points->size()) {
164 return PP_MakeTouchPoint();
165 }
166 return points->at(index);
167 }
168
169 PP_TouchPoint_Dev PPB_InputEvent_Shared::GetTouchById(PP_TouchListType list,
170 uint32_t id) {
171 const std::vector<PP_TouchPoint_Dev>* points;
172 switch (list) {
173 case PP_TOUCHLIST_TYPE_TOUCHES:
174 points = &data_.touches;
175 break;
176 case PP_TOUCHLIST_TYPE_CHANGEDTOUCHES:
177 points = &data_.changed_touches;
178 break;
179 case PP_TOUCHLIST_TYPE_TARGETTOUCHES:
180 points = &data_.target_touches;
181 break;
182 default:
183 return PP_MakeTouchPoint();
184 }
185 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.
186 if (points->at(i).id == id)
187 return points->at(i);
188 }
189 return PP_MakeTouchPoint();
190 }
191
130 //static 192 //static
131 PP_Resource PPB_InputEvent_Shared::CreateIMEInputEvent( 193 PP_Resource PPB_InputEvent_Shared::CreateIMEInputEvent(
132 ResourceObjectType type, 194 ResourceObjectType type,
133 PP_Instance instance, 195 PP_Instance instance,
134 PP_InputEvent_Type event_type, 196 PP_InputEvent_Type event_type,
135 PP_TimeTicks time_stamp, 197 PP_TimeTicks time_stamp,
136 struct PP_Var text, 198 struct PP_Var text,
137 uint32_t segment_number, 199 uint32_t segment_number,
138 const uint32_t* segment_offsets, 200 const uint32_t* segment_offsets,
139 int32_t target_segment, 201 int32_t target_segment,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 data.event_time_stamp = time_stamp; 301 data.event_time_stamp = time_stamp;
240 data.event_modifiers = modifiers; 302 data.event_modifiers = modifiers;
241 data.wheel_delta = *wheel_delta; 303 data.wheel_delta = *wheel_delta;
242 data.wheel_ticks = *wheel_ticks; 304 data.wheel_ticks = *wheel_ticks;
243 data.wheel_scroll_by_page = PP_ToBool(scroll_by_page); 305 data.wheel_scroll_by_page = PP_ToBool(scroll_by_page);
244 306
245 return (new PPB_InputEvent_Shared(type, instance, data))->GetReference(); 307 return (new PPB_InputEvent_Shared(type, instance, data))->GetReference();
246 } 308 }
247 309
248 } // namespace ppapi 310 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698