| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/c/pp_errors.h" | 5 #include "ppapi/c/pp_errors.h" |
| 6 #include "ppapi/thunk/thunk.h" | 6 #include "ppapi/thunk/thunk.h" |
| 7 #include "ppapi/thunk/enter.h" | 7 #include "ppapi/thunk/enter.h" |
| 8 #include "ppapi/thunk/ppb_input_event_api.h" | 8 #include "ppapi/thunk/ppb_input_event_api.h" |
| 9 #include "ppapi/thunk/ppb_instance_api.h" | 9 #include "ppapi/thunk/ppb_instance_api.h" |
| 10 #include "ppapi/thunk/resource_creation_api.h" | 10 #include "ppapi/thunk/resource_creation_api.h" |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 return enter.object()->GetCharacterText(); | 264 return enter.object()->GetCharacterText(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 const PPB_KeyboardInputEvent g_ppb_keyboard_input_event_thunk = { | 267 const PPB_KeyboardInputEvent g_ppb_keyboard_input_event_thunk = { |
| 268 &CreateKeyboardInputEvent, | 268 &CreateKeyboardInputEvent, |
| 269 &IsKeyboardInputEvent, | 269 &IsKeyboardInputEvent, |
| 270 &GetKeyCode, | 270 &GetKeyCode, |
| 271 &GetCharacterText | 271 &GetCharacterText |
| 272 }; | 272 }; |
| 273 | 273 |
| 274 // Keyboard -------------------------------------------------------------------- |
| 275 |
| 276 PP_Bool IsCompositionInputEvent(PP_Resource resource) { |
| 277 if (!IsInputEvent(resource)) |
| 278 return PP_FALSE; // Prevent warning log in GetType. |
| 279 PP_InputEvent_Type type = GetType(resource); |
| 280 return PP_FromBool(type == PP_INPUTEVENT_TYPE_COMPOSITION_START || |
| 281 type == PP_INPUTEVENT_TYPE_COMPOSITION_UPDATE || |
| 282 type == PP_INPUTEVENT_TYPE_COMPOSITION_END || |
| 283 type == PP_INPUTEVENT_TYPE_IME_TEXT); |
| 284 } |
| 285 |
| 286 PP_Var GetCompositionText(PP_Resource composition_event) { |
| 287 return GetCharacterText(composition_event); |
| 288 } |
| 289 |
| 290 void GetCompositionSegments(PP_Resource composition_event, |
| 291 void* segments, |
| 292 uint32_t* size) { |
| 293 EnterInputEvent enter(composition_event, true); |
| 294 if (enter.failed()) { |
| 295 if (size) |
| 296 *size = 0; |
| 297 return; |
| 298 } |
| 299 enter.object()->GetCompositionSegments(static_cast<uint32_t**>(segments), |
| 300 size); |
| 301 } |
| 302 |
| 303 int32_t GetCompositionTargetSegment(PP_Resource composition_event) { |
| 304 EnterInputEvent enter(composition_event, true); |
| 305 if (enter.failed()) |
| 306 return -1; |
| 307 return enter.object()->GetCompositionTargetSegment(); |
| 308 } |
| 309 |
| 310 void GetCompositionSelection(PP_Resource composition_event, |
| 311 uint32_t* start, |
| 312 uint32_t* end) { |
| 313 EnterInputEvent enter(composition_event, true); |
| 314 if (enter.failed()) { |
| 315 if (start) |
| 316 *start = 0; |
| 317 if (end) |
| 318 *end = 0; |
| 319 return; |
| 320 } |
| 321 enter.object()->GetCompositionSelection(start, end); |
| 322 } |
| 323 |
| 324 const PPB_CompositionInputEvent g_ppb_composition_input_event_thunk = { |
| 325 &IsCompositionInputEvent, |
| 326 &GetCompositionText, |
| 327 &GetCompositionSegments, |
| 328 &GetCompositionTargetSegment, |
| 329 &GetCompositionSelection |
| 330 }; |
| 331 |
| 274 } // namespace | 332 } // namespace |
| 275 | 333 |
| 276 const PPB_InputEvent* GetPPB_InputEvent_Thunk() { | 334 const PPB_InputEvent* GetPPB_InputEvent_Thunk() { |
| 277 return &g_ppb_input_event_thunk; | 335 return &g_ppb_input_event_thunk; |
| 278 } | 336 } |
| 279 | 337 |
| 280 const PPB_MouseInputEvent_1_0* GetPPB_MouseInputEvent_1_0_Thunk() { | 338 const PPB_MouseInputEvent_1_0* GetPPB_MouseInputEvent_1_0_Thunk() { |
| 281 return &g_ppb_mouse_input_event_1_0_thunk; | 339 return &g_ppb_mouse_input_event_1_0_thunk; |
| 282 } | 340 } |
| 283 | 341 |
| 284 const PPB_MouseInputEvent* GetPPB_MouseInputEvent_1_1_Thunk() { | 342 const PPB_MouseInputEvent* GetPPB_MouseInputEvent_1_1_Thunk() { |
| 285 return &g_ppb_mouse_input_event_1_1_thunk; | 343 return &g_ppb_mouse_input_event_1_1_thunk; |
| 286 } | 344 } |
| 287 | 345 |
| 288 const PPB_KeyboardInputEvent* GetPPB_KeyboardInputEvent_Thunk() { | 346 const PPB_KeyboardInputEvent* GetPPB_KeyboardInputEvent_Thunk() { |
| 289 return &g_ppb_keyboard_input_event_thunk; | 347 return &g_ppb_keyboard_input_event_thunk; |
| 290 } | 348 } |
| 291 | 349 |
| 292 const PPB_WheelInputEvent* GetPPB_WheelInputEvent_Thunk() { | 350 const PPB_WheelInputEvent* GetPPB_WheelInputEvent_Thunk() { |
| 293 return &g_ppb_wheel_input_event_thunk; | 351 return &g_ppb_wheel_input_event_thunk; |
| 294 } | 352 } |
| 295 | 353 |
| 354 const PPB_CompositionInputEvent* GetPPB_CompositionInputEvent_Thunk() { |
| 355 return &g_ppb_composition_input_event_thunk; |
| 356 } |
| 357 |
| 296 } // namespace thunk | 358 } // namespace thunk |
| 297 } // namespace ppapi | 359 } // namespace ppapi |
| OLD | NEW |