| OLD | NEW |
| 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 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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 code(), | 26 code(), |
| 27 character_text(), | 27 character_text(), |
| 28 composition_target_segment(-1), | 28 composition_target_segment(-1), |
| 29 composition_selection_start(0), | 29 composition_selection_start(0), |
| 30 composition_selection_end(0), | 30 composition_selection_end(0), |
| 31 touches(), | 31 touches(), |
| 32 changed_touches(), | 32 changed_touches(), |
| 33 target_touches() { | 33 target_touches() {} |
| 34 } | |
| 35 | 34 |
| 36 InputEventData::~InputEventData() { | 35 InputEventData::~InputEventData() {} |
| 37 } | |
| 38 | 36 |
| 39 PPB_InputEvent_Shared::PPB_InputEvent_Shared(ResourceObjectType type, | 37 PPB_InputEvent_Shared::PPB_InputEvent_Shared(ResourceObjectType type, |
| 40 PP_Instance instance, | 38 PP_Instance instance, |
| 41 const InputEventData& data) | 39 const InputEventData& data) |
| 42 : Resource(type, instance), | 40 : Resource(type, instance), data_(data) {} |
| 43 data_(data) { | |
| 44 } | |
| 45 | 41 |
| 46 PPB_InputEvent_API* PPB_InputEvent_Shared::AsPPB_InputEvent_API() { | 42 PPB_InputEvent_API* PPB_InputEvent_Shared::AsPPB_InputEvent_API() { |
| 47 return this; | 43 return this; |
| 48 } | 44 } |
| 49 | 45 |
| 50 const InputEventData& PPB_InputEvent_Shared::GetInputEventData() const { | 46 const InputEventData& PPB_InputEvent_Shared::GetInputEventData() const { |
| 51 return data_; | 47 return data_; |
| 52 } | 48 } |
| 53 | 49 |
| 54 PP_InputEvent_Type PPB_InputEvent_Shared::GetType() { | 50 PP_InputEvent_Type PPB_InputEvent_Shared::GetType() { return data_.event_type; } |
| 55 return data_.event_type; | |
| 56 } | |
| 57 | 51 |
| 58 PP_TimeTicks PPB_InputEvent_Shared::GetTimeStamp() { | 52 PP_TimeTicks PPB_InputEvent_Shared::GetTimeStamp() { |
| 59 return data_.event_time_stamp; | 53 return data_.event_time_stamp; |
| 60 } | 54 } |
| 61 | 55 |
| 62 uint32_t PPB_InputEvent_Shared::GetModifiers() { | 56 uint32_t PPB_InputEvent_Shared::GetModifiers() { return data_.event_modifiers; } |
| 63 return data_.event_modifiers; | |
| 64 } | |
| 65 | 57 |
| 66 PP_InputEvent_MouseButton PPB_InputEvent_Shared::GetMouseButton() { | 58 PP_InputEvent_MouseButton PPB_InputEvent_Shared::GetMouseButton() { |
| 67 return data_.mouse_button; | 59 return data_.mouse_button; |
| 68 } | 60 } |
| 69 | 61 |
| 70 PP_Point PPB_InputEvent_Shared::GetMousePosition() { | 62 PP_Point PPB_InputEvent_Shared::GetMousePosition() { |
| 71 return data_.mouse_position; | 63 return data_.mouse_position; |
| 72 } | 64 } |
| 73 | 65 |
| 74 int32_t PPB_InputEvent_Shared::GetMouseClickCount() { | 66 int32_t PPB_InputEvent_Shared::GetMouseClickCount() { |
| 75 return data_.mouse_click_count; | 67 return data_.mouse_click_count; |
| 76 } | 68 } |
| 77 | 69 |
| 78 PP_Point PPB_InputEvent_Shared::GetMouseMovement() { | 70 PP_Point PPB_InputEvent_Shared::GetMouseMovement() { |
| 79 return data_.mouse_movement; | 71 return data_.mouse_movement; |
| 80 } | 72 } |
| 81 | 73 |
| 82 PP_FloatPoint PPB_InputEvent_Shared::GetWheelDelta() { | 74 PP_FloatPoint PPB_InputEvent_Shared::GetWheelDelta() { |
| 83 return data_.wheel_delta; | 75 return data_.wheel_delta; |
| 84 } | 76 } |
| 85 | 77 |
| 86 PP_FloatPoint PPB_InputEvent_Shared::GetWheelTicks() { | 78 PP_FloatPoint PPB_InputEvent_Shared::GetWheelTicks() { |
| 87 return data_.wheel_ticks; | 79 return data_.wheel_ticks; |
| 88 } | 80 } |
| 89 | 81 |
| 90 PP_Bool PPB_InputEvent_Shared::GetWheelScrollByPage() { | 82 PP_Bool PPB_InputEvent_Shared::GetWheelScrollByPage() { |
| 91 return PP_FromBool(data_.wheel_scroll_by_page); | 83 return PP_FromBool(data_.wheel_scroll_by_page); |
| 92 } | 84 } |
| 93 | 85 |
| 94 uint32_t PPB_InputEvent_Shared::GetKeyCode() { | 86 uint32_t PPB_InputEvent_Shared::GetKeyCode() { return data_.key_code; } |
| 95 return data_.key_code; | |
| 96 } | |
| 97 | 87 |
| 98 PP_Var PPB_InputEvent_Shared::GetCharacterText() { | 88 PP_Var PPB_InputEvent_Shared::GetCharacterText() { |
| 99 return StringVar::StringToPPVar(data_.character_text); | 89 return StringVar::StringToPPVar(data_.character_text); |
| 100 } | 90 } |
| 101 | 91 |
| 102 PP_Var PPB_InputEvent_Shared::GetCode() { | 92 PP_Var PPB_InputEvent_Shared::GetCode() { |
| 103 return StringVar::StringToPPVar(data_.code); | 93 return StringVar::StringToPPVar(data_.code); |
| 104 } | 94 } |
| 105 | 95 |
| 106 uint32_t PPB_InputEvent_Shared::GetIMESegmentNumber() { | 96 uint32_t PPB_InputEvent_Shared::GetIMESegmentNumber() { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 default: | 184 default: |
| 195 return PP_MakeTouchPoint(); | 185 return PP_MakeTouchPoint(); |
| 196 } | 186 } |
| 197 for (size_t i = 0; i < points->size(); i++) { | 187 for (size_t i = 0; i < points->size(); i++) { |
| 198 if (points->at(i).id == id) | 188 if (points->at(i).id == id) |
| 199 return points->at(i); | 189 return points->at(i); |
| 200 } | 190 } |
| 201 return PP_MakeTouchPoint(); | 191 return PP_MakeTouchPoint(); |
| 202 } | 192 } |
| 203 | 193 |
| 204 //static | 194 // static |
| 205 PP_Resource PPB_InputEvent_Shared::CreateIMEInputEvent( | 195 PP_Resource PPB_InputEvent_Shared::CreateIMEInputEvent( |
| 206 ResourceObjectType type, | 196 ResourceObjectType type, |
| 207 PP_Instance instance, | 197 PP_Instance instance, |
| 208 PP_InputEvent_Type event_type, | 198 PP_InputEvent_Type event_type, |
| 209 PP_TimeTicks time_stamp, | 199 PP_TimeTicks time_stamp, |
| 210 struct PP_Var text, | 200 struct PP_Var text, |
| 211 uint32_t segment_number, | 201 uint32_t segment_number, |
| 212 const uint32_t* segment_offsets, | 202 const uint32_t* segment_offsets, |
| 213 int32_t target_segment, | 203 int32_t target_segment, |
| 214 uint32_t selection_start, | 204 uint32_t selection_start, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 232 if (segment_number != 0) { | 222 if (segment_number != 0) { |
| 233 data.composition_segment_offsets.assign( | 223 data.composition_segment_offsets.assign( |
| 234 &segment_offsets[0], &segment_offsets[segment_number + 1]); | 224 &segment_offsets[0], &segment_offsets[segment_number + 1]); |
| 235 } | 225 } |
| 236 data.composition_selection_start = selection_start; | 226 data.composition_selection_start = selection_start; |
| 237 data.composition_selection_end = selection_end; | 227 data.composition_selection_end = selection_end; |
| 238 | 228 |
| 239 return (new PPB_InputEvent_Shared(type, instance, data))->GetReference(); | 229 return (new PPB_InputEvent_Shared(type, instance, data))->GetReference(); |
| 240 } | 230 } |
| 241 | 231 |
| 242 //static | 232 // static |
| 243 PP_Resource PPB_InputEvent_Shared::CreateKeyboardInputEvent( | 233 PP_Resource PPB_InputEvent_Shared::CreateKeyboardInputEvent( |
| 244 ResourceObjectType type, | 234 ResourceObjectType type, |
| 245 PP_Instance instance, | 235 PP_Instance instance, |
| 246 PP_InputEvent_Type event_type, | 236 PP_InputEvent_Type event_type, |
| 247 PP_TimeTicks time_stamp, | 237 PP_TimeTicks time_stamp, |
| 248 uint32_t modifiers, | 238 uint32_t modifiers, |
| 249 uint32_t key_code, | 239 uint32_t key_code, |
| 250 struct PP_Var character_text, | 240 struct PP_Var character_text, |
| 251 struct PP_Var code) { | 241 struct PP_Var code) { |
| 252 if (event_type != PP_INPUTEVENT_TYPE_RAWKEYDOWN && | 242 if (event_type != PP_INPUTEVENT_TYPE_RAWKEYDOWN && |
| (...skipping 16 matching lines...) Expand all Loading... |
| 269 if (code.type == PP_VARTYPE_STRING) { | 259 if (code.type == PP_VARTYPE_STRING) { |
| 270 StringVar* code_str = StringVar::FromPPVar(code); | 260 StringVar* code_str = StringVar::FromPPVar(code); |
| 271 if (!code_str) | 261 if (!code_str) |
| 272 return 0; | 262 return 0; |
| 273 data.code = code_str->value(); | 263 data.code = code_str->value(); |
| 274 } | 264 } |
| 275 | 265 |
| 276 return (new PPB_InputEvent_Shared(type, instance, data))->GetReference(); | 266 return (new PPB_InputEvent_Shared(type, instance, data))->GetReference(); |
| 277 } | 267 } |
| 278 | 268 |
| 279 //static | 269 // static |
| 280 PP_Resource PPB_InputEvent_Shared::CreateMouseInputEvent( | 270 PP_Resource PPB_InputEvent_Shared::CreateMouseInputEvent( |
| 281 ResourceObjectType type, | 271 ResourceObjectType type, |
| 282 PP_Instance instance, | 272 PP_Instance instance, |
| 283 PP_InputEvent_Type event_type, | 273 PP_InputEvent_Type event_type, |
| 284 PP_TimeTicks time_stamp, | 274 PP_TimeTicks time_stamp, |
| 285 uint32_t modifiers, | 275 uint32_t modifiers, |
| 286 PP_InputEvent_MouseButton mouse_button, | 276 PP_InputEvent_MouseButton mouse_button, |
| 287 const PP_Point* mouse_position, | 277 const PP_Point* mouse_position, |
| 288 int32_t click_count, | 278 int32_t click_count, |
| 289 const PP_Point* mouse_movement) { | 279 const PP_Point* mouse_movement) { |
| 290 if (event_type != PP_INPUTEVENT_TYPE_MOUSEDOWN && | 280 if (event_type != PP_INPUTEVENT_TYPE_MOUSEDOWN && |
| 291 event_type != PP_INPUTEVENT_TYPE_MOUSEUP && | 281 event_type != PP_INPUTEVENT_TYPE_MOUSEUP && |
| 292 event_type != PP_INPUTEVENT_TYPE_MOUSEMOVE && | 282 event_type != PP_INPUTEVENT_TYPE_MOUSEMOVE && |
| 293 event_type != PP_INPUTEVENT_TYPE_MOUSEENTER && | 283 event_type != PP_INPUTEVENT_TYPE_MOUSEENTER && |
| 294 event_type != PP_INPUTEVENT_TYPE_MOUSELEAVE) | 284 event_type != PP_INPUTEVENT_TYPE_MOUSELEAVE) |
| 295 return 0; | 285 return 0; |
| 296 | 286 |
| 297 InputEventData data; | 287 InputEventData data; |
| 298 data.event_type = event_type; | 288 data.event_type = event_type; |
| 299 data.event_time_stamp = time_stamp; | 289 data.event_time_stamp = time_stamp; |
| 300 data.event_modifiers = modifiers; | 290 data.event_modifiers = modifiers; |
| 301 data.mouse_button = mouse_button; | 291 data.mouse_button = mouse_button; |
| 302 data.mouse_position = *mouse_position; | 292 data.mouse_position = *mouse_position; |
| 303 data.mouse_click_count = click_count; | 293 data.mouse_click_count = click_count; |
| 304 data.mouse_movement = *mouse_movement; | 294 data.mouse_movement = *mouse_movement; |
| 305 | 295 |
| 306 return (new PPB_InputEvent_Shared(type, instance, data))->GetReference(); | 296 return (new PPB_InputEvent_Shared(type, instance, data))->GetReference(); |
| 307 } | 297 } |
| 308 | 298 |
| 309 //static | 299 // static |
| 310 PP_Resource PPB_InputEvent_Shared::CreateWheelInputEvent( | 300 PP_Resource PPB_InputEvent_Shared::CreateWheelInputEvent( |
| 311 ResourceObjectType type, | 301 ResourceObjectType type, |
| 312 PP_Instance instance, | 302 PP_Instance instance, |
| 313 PP_TimeTicks time_stamp, | 303 PP_TimeTicks time_stamp, |
| 314 uint32_t modifiers, | 304 uint32_t modifiers, |
| 315 const PP_FloatPoint* wheel_delta, | 305 const PP_FloatPoint* wheel_delta, |
| 316 const PP_FloatPoint* wheel_ticks, | 306 const PP_FloatPoint* wheel_ticks, |
| 317 PP_Bool scroll_by_page) { | 307 PP_Bool scroll_by_page) { |
| 318 InputEventData data; | 308 InputEventData data; |
| 319 data.event_type = PP_INPUTEVENT_TYPE_WHEEL; | 309 data.event_type = PP_INPUTEVENT_TYPE_WHEEL; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 340 return 0; | 330 return 0; |
| 341 | 331 |
| 342 InputEventData data; | 332 InputEventData data; |
| 343 data.event_type = event_type; | 333 data.event_type = event_type; |
| 344 data.event_time_stamp = time_stamp; | 334 data.event_time_stamp = time_stamp; |
| 345 data.event_modifiers = modifiers; | 335 data.event_modifiers = modifiers; |
| 346 return (new PPB_InputEvent_Shared(type, instance, data))->GetReference(); | 336 return (new PPB_InputEvent_Shared(type, instance, data))->GetReference(); |
| 347 } | 337 } |
| 348 | 338 |
| 349 } // namespace ppapi | 339 } // namespace ppapi |
| OLD | NEW |