| 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 uint32_t GetCompositionTargetSegment(PP_Resource composition_event) { |
| 291 EnterInputEvent enter(composition_event, true); |
| 292 if (enter.failed()) |
| 293 return 0; |
| 294 return enter.object()->GetCompositionTargetSegment(); |
| 295 } |
| 296 |
| 297 void GetCompositionSegments(PP_Resource composition_event, |
| 298 uint32_t** segments, |
| 299 uint32_t* size) { |
| 300 EnterInputEvent enter(composition_event, true); |
| 301 if (enter.failed()) |
| 302 return; |
| 303 enter.object()->GetCompositionSegments(segments, size); |
| 304 } |
| 305 |
| 306 const PPB_CompositionInputEvent g_ppb_composition_input_event_thunk = { |
| 307 &IsCompositionInputEvent, |
| 308 &GetCompositionText, |
| 309 &GetCompositionTargetSegment, |
| 310 &GetCompositionSegments, |
| 311 }; |
| 312 |
| 274 } // namespace | 313 } // namespace |
| 275 | 314 |
| 276 const PPB_InputEvent* GetPPB_InputEvent_Thunk() { | 315 const PPB_InputEvent* GetPPB_InputEvent_Thunk() { |
| 277 return &g_ppb_input_event_thunk; | 316 return &g_ppb_input_event_thunk; |
| 278 } | 317 } |
| 279 | 318 |
| 280 const PPB_MouseInputEvent_1_0* GetPPB_MouseInputEvent_1_0_Thunk() { | 319 const PPB_MouseInputEvent_1_0* GetPPB_MouseInputEvent_1_0_Thunk() { |
| 281 return &g_ppb_mouse_input_event_1_0_thunk; | 320 return &g_ppb_mouse_input_event_1_0_thunk; |
| 282 } | 321 } |
| 283 | 322 |
| 284 const PPB_MouseInputEvent* GetPPB_MouseInputEvent_1_1_Thunk() { | 323 const PPB_MouseInputEvent* GetPPB_MouseInputEvent_1_1_Thunk() { |
| 285 return &g_ppb_mouse_input_event_1_1_thunk; | 324 return &g_ppb_mouse_input_event_1_1_thunk; |
| 286 } | 325 } |
| 287 | 326 |
| 288 const PPB_KeyboardInputEvent* GetPPB_KeyboardInputEvent_Thunk() { | 327 const PPB_KeyboardInputEvent* GetPPB_KeyboardInputEvent_Thunk() { |
| 289 return &g_ppb_keyboard_input_event_thunk; | 328 return &g_ppb_keyboard_input_event_thunk; |
| 290 } | 329 } |
| 291 | 330 |
| 292 const PPB_WheelInputEvent* GetPPB_WheelInputEvent_Thunk() { | 331 const PPB_WheelInputEvent* GetPPB_WheelInputEvent_Thunk() { |
| 293 return &g_ppb_wheel_input_event_thunk; | 332 return &g_ppb_wheel_input_event_thunk; |
| 294 } | 333 } |
| 295 | 334 |
| 335 const PPB_CompositionInputEvent* GetPPB_CompositionInputEvent_Thunk() { |
| 336 return &g_ppb_composition_input_event_thunk; |
| 337 } |
| 338 |
| 296 } // namespace thunk | 339 } // namespace thunk |
| 297 } // namespace ppapi | 340 } // namespace ppapi |
| OLD | NEW |