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/c/pp_errors.h" | 5 #include "ppapi/c/pp_errors.h" |
6 #include "ppapi/thunk/enter.h" | 6 #include "ppapi/thunk/enter.h" |
7 #include "ppapi/thunk/ppb_input_event_api.h" | 7 #include "ppapi/thunk/ppb_input_event_api.h" |
8 #include "ppapi/thunk/ppb_instance_api.h" | 8 #include "ppapi/thunk/ppb_instance_api.h" |
9 #include "ppapi/thunk/resource_creation_api.h" | 9 #include "ppapi/thunk/resource_creation_api.h" |
10 #include "ppapi/thunk/thunk.h" | 10 #include "ppapi/thunk/thunk.h" |
11 | 11 |
12 // This struct is for ABI compatibility for PPAPI Flash and PDF plugin. | |
13 // TODO(nona): Remove once Flash and PDF support IMEInputEvent1.0. | |
14 struct PPB_IMEInputEvent_Dev_0_2 { | |
dmichael (off chromium)
2013/07/18 03:50:20
I'd really prefer if we just kept the old IDL arou
Seigo Nonaka
2013/07/23 11:49:54
Sure, I revert dev IDLs.
On 2013/07/18 03:50:20,
| |
15 PP_Resource (*Create)(PP_Instance instance, | |
16 PP_InputEvent_Type type, | |
17 PP_TimeTicks time_stamp, | |
18 struct PP_Var text, | |
19 uint32_t segment_number, | |
20 const uint32_t segment_offsets[], | |
21 int32_t target_segment, | |
22 uint32_t selection_start, | |
23 uint32_t selection_end); | |
24 PP_Bool (*IsIMEInputEvent)(PP_Resource resource); | |
25 struct PP_Var (*GetText)(PP_Resource ime_event); | |
26 uint32_t (*GetSegmentCount)(PP_Resource ime_event); | |
27 uint32_t (*GetSegmentOffset)(PP_Resource ime_event, uint32_t index); | |
28 int32_t (*GetTargetSegment)(PP_Resource ime_event); | |
29 void (*GetSelection)(PP_Resource ime_event, uint32_t* start, uint32_t* end); | |
30 }; | |
31 | |
12 namespace ppapi { | 32 namespace ppapi { |
13 namespace thunk { | 33 namespace thunk { |
14 | 34 |
15 namespace { | 35 namespace { |
16 | 36 |
17 typedef EnterResource<PPB_InputEvent_API> EnterInputEvent; | 37 typedef EnterResource<PPB_InputEvent_API> EnterInputEvent; |
18 | 38 |
19 // InputEvent ------------------------------------------------------------------ | 39 // InputEvent ------------------------------------------------------------------ |
20 | 40 |
21 int32_t RequestInputEvents(PP_Instance instance, uint32_t event_classes) { | 41 int32_t RequestInputEvents(PP_Instance instance, uint32_t event_classes) { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 | 340 |
321 PP_Resource CreateIMEInputEvent(PP_Instance instance, | 341 PP_Resource CreateIMEInputEvent(PP_Instance instance, |
322 PP_InputEvent_Type type, | 342 PP_InputEvent_Type type, |
323 PP_TimeTicks time_stamp, | 343 PP_TimeTicks time_stamp, |
324 PP_Var text, | 344 PP_Var text, |
325 uint32_t segment_number, | 345 uint32_t segment_number, |
326 const uint32_t segment_offsets[], | 346 const uint32_t segment_offsets[], |
327 int32_t target_segment, | 347 int32_t target_segment, |
328 uint32_t selection_start, | 348 uint32_t selection_start, |
329 uint32_t selection_end) { | 349 uint32_t selection_end) { |
330 VLOG(4) << "PPB_IMEInputEvent_Dev::Create()"; | 350 VLOG(4) << "PPB_IMEInputEvent::Create()"; |
331 EnterResourceCreation enter(instance); | 351 EnterResourceCreation enter(instance); |
332 if (enter.failed()) | 352 if (enter.failed()) |
333 return 0; | 353 return 0; |
334 return enter.functions()->CreateIMEInputEvent(instance, type, time_stamp, | 354 return enter.functions()->CreateIMEInputEvent(instance, type, time_stamp, |
335 text, segment_number, | 355 text, segment_number, |
336 segment_offsets, | 356 segment_offsets, |
337 target_segment, | 357 target_segment, |
338 selection_start, | 358 selection_start, |
339 selection_end); | 359 selection_end); |
340 } | 360 } |
341 | 361 |
342 PP_Bool IsIMEInputEvent(PP_Resource resource) { | 362 PP_Bool IsIMEInputEvent(PP_Resource resource) { |
343 VLOG(4) << "PPB_IMEInputEvent_Dev::IsIMEInputEvent()"; | 363 VLOG(4) << "PPB_IMEInputEvent::IsIMEInputEvent()"; |
344 if (!IsInputEvent(resource)) | 364 if (!IsInputEvent(resource)) |
345 return PP_FALSE; // Prevent warning log in GetType. | 365 return PP_FALSE; // Prevent warning log in GetType. |
346 PP_InputEvent_Type type = GetType(resource); | 366 PP_InputEvent_Type type = GetType(resource); |
347 return PP_FromBool(type == PP_INPUTEVENT_TYPE_IME_COMPOSITION_START || | 367 return PP_FromBool(type == PP_INPUTEVENT_TYPE_IME_COMPOSITION_START || |
348 type == PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE || | 368 type == PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE || |
349 type == PP_INPUTEVENT_TYPE_IME_COMPOSITION_END || | 369 type == PP_INPUTEVENT_TYPE_IME_COMPOSITION_END || |
350 type == PP_INPUTEVENT_TYPE_IME_TEXT); | 370 type == PP_INPUTEVENT_TYPE_IME_TEXT); |
351 } | 371 } |
352 | 372 |
353 PP_Var GetIMEText(PP_Resource ime_event) { | 373 PP_Var GetIMEText(PP_Resource ime_event) { |
354 VLOG(4) << "PPB_IMEInputEvent_Dev::GetText()"; | 374 VLOG(4) << "PPB_IMEInputEvent::GetText()"; |
355 return GetCharacterText(ime_event); | 375 return GetCharacterText(ime_event); |
356 } | 376 } |
357 | 377 |
358 uint32_t GetIMESegmentNumber(PP_Resource ime_event) { | 378 uint32_t GetIMESegmentNumber(PP_Resource ime_event) { |
359 VLOG(4) << "PPB_IMEInputEvent_Dev::GetSegmentNumber()"; | 379 VLOG(4) << "PPB_IMEInputEvent::GetSegmentCount()"; |
360 EnterInputEvent enter(ime_event, true); | 380 EnterInputEvent enter(ime_event, true); |
361 if (enter.failed()) | 381 if (enter.failed()) |
362 return 0; | 382 return 0; |
363 return enter.object()->GetIMESegmentNumber(); | 383 return enter.object()->GetIMESegmentNumber(); |
364 } | 384 } |
365 | 385 |
366 uint32_t GetIMESegmentOffset(PP_Resource ime_event, uint32_t index) { | 386 uint32_t GetIMESegmentOffset(PP_Resource ime_event, uint32_t index) { |
367 VLOG(4) << "PPB_IMEInputEvent_Dev::GetSegmentOffset()"; | 387 VLOG(4) << "PPB_IMEInputEvent::GetSegmentOffset()"; |
368 EnterInputEvent enter(ime_event, true); | 388 EnterInputEvent enter(ime_event, true); |
369 if (enter.failed()) | 389 if (enter.failed()) |
370 return 0; | 390 return 0; |
371 return enter.object()->GetIMESegmentOffset(index); | 391 return enter.object()->GetIMESegmentOffset(index); |
372 } | 392 } |
373 | 393 |
374 int32_t GetIMETargetSegment(PP_Resource ime_event) { | 394 int32_t GetIMETargetSegment(PP_Resource ime_event) { |
375 VLOG(4) << "PPB_IMEInputEvent_Dev::GetTargetSegment()"; | 395 VLOG(4) << "PPB_IMEInputEvent::GetTargetSegment()"; |
376 EnterInputEvent enter(ime_event, true); | 396 EnterInputEvent enter(ime_event, true); |
377 if (enter.failed()) | 397 if (enter.failed()) |
378 return -1; | 398 return -1; |
379 return enter.object()->GetIMETargetSegment(); | 399 return enter.object()->GetIMETargetSegment(); |
380 } | 400 } |
381 | 401 |
382 void GetIMESelection(PP_Resource ime_event, uint32_t* start, uint32_t* end) { | 402 void GetIMESelection(PP_Resource ime_event, uint32_t* start, uint32_t* end) { |
383 VLOG(4) << "PPB_IMEInputEvent_Dev::GetSelection()"; | 403 VLOG(4) << "PPB_IMEInputEvent::GetSelection()"; |
384 EnterInputEvent enter(ime_event, true); | 404 EnterInputEvent enter(ime_event, true); |
385 if (enter.failed()) { | 405 if (enter.failed()) { |
386 if (start) | 406 if (start) |
387 *start = 0; | 407 *start = 0; |
388 if (end) | 408 if (end) |
389 *end = 0; | 409 *end = 0; |
390 return; | 410 return; |
391 } | 411 } |
392 enter.object()->GetIMESelection(start, end); | 412 enter.object()->GetIMESelection(start, end); |
393 } | 413 } |
394 | 414 |
395 const PPB_IMEInputEvent_Dev_0_1 g_ppb_ime_input_event_0_1_thunk = { | 415 const PPB_IMEInputEvent_1_0 g_ppb_ime_input_event_1_0_thunk = { |
416 &CreateIMEInputEvent, | |
396 &IsIMEInputEvent, | 417 &IsIMEInputEvent, |
397 &GetIMEText, | 418 &GetIMEText, |
398 &GetIMESegmentNumber, | 419 &GetIMESegmentNumber, |
399 &GetIMESegmentOffset, | 420 &GetIMESegmentOffset, |
400 &GetIMETargetSegment, | 421 &GetIMETargetSegment, |
401 &GetIMESelection | 422 &GetIMESelection |
402 }; | 423 }; |
403 | 424 |
404 const PPB_IMEInputEvent_Dev_0_2 g_ppb_ime_input_event_0_2_thunk = { | 425 // TODO(nona): Remove once Flash and PDF plugin support IMEInputEvent1.0. |
426 const PPB_IMEInputEvent_Dev_0_2 g_ppb_ime_input_event_dev_0_2_thunk = { | |
405 &CreateIMEInputEvent, | 427 &CreateIMEInputEvent, |
406 &IsIMEInputEvent, | 428 &IsIMEInputEvent, |
407 &GetIMEText, | 429 &GetIMEText, |
408 &GetIMESegmentNumber, | 430 &GetIMESegmentNumber, |
409 &GetIMESegmentOffset, | 431 &GetIMESegmentOffset, |
410 &GetIMETargetSegment, | 432 &GetIMETargetSegment, |
411 &GetIMESelection | 433 &GetIMESelection |
412 }; | 434 }; |
413 | 435 |
414 // Touch ----------------------------------------------------------------------- | 436 // Touch ----------------------------------------------------------------------- |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
503 | 525 |
504 const PPB_KeyboardInputEvent_Dev_0_1* | 526 const PPB_KeyboardInputEvent_Dev_0_1* |
505 GetPPB_KeyboardInputEvent_Dev_0_1_Thunk() { | 527 GetPPB_KeyboardInputEvent_Dev_0_1_Thunk() { |
506 return &g_ppb_keyboard_input_event_dev_thunk; | 528 return &g_ppb_keyboard_input_event_dev_thunk; |
507 } | 529 } |
508 | 530 |
509 const PPB_WheelInputEvent_1_0* GetPPB_WheelInputEvent_1_0_Thunk() { | 531 const PPB_WheelInputEvent_1_0* GetPPB_WheelInputEvent_1_0_Thunk() { |
510 return &g_ppb_wheel_input_event_thunk; | 532 return &g_ppb_wheel_input_event_thunk; |
511 } | 533 } |
512 | 534 |
513 const PPB_IMEInputEvent_Dev_0_1* GetPPB_IMEInputEvent_Dev_0_1_Thunk() { | 535 const PPB_IMEInputEvent_1_0* GetPPB_IMEInputEvent_1_0_Thunk() { |
514 return &g_ppb_ime_input_event_0_1_thunk; | 536 return &g_ppb_ime_input_event_1_0_thunk; |
515 } | 537 } |
516 | 538 |
539 // TODO(nona): Remove once Flash and PDF plugin support IMEInputEvent1.0. | |
517 const PPB_IMEInputEvent_Dev_0_2* GetPPB_IMEInputEvent_Dev_0_2_Thunk() { | 540 const PPB_IMEInputEvent_Dev_0_2* GetPPB_IMEInputEvent_Dev_0_2_Thunk() { |
518 return &g_ppb_ime_input_event_0_2_thunk; | 541 return &g_ppb_ime_input_event_dev_0_2_thunk; |
519 } | 542 } |
520 | 543 |
521 const PPB_TouchInputEvent_1_0* GetPPB_TouchInputEvent_1_0_Thunk() { | 544 const PPB_TouchInputEvent_1_0* GetPPB_TouchInputEvent_1_0_Thunk() { |
522 return &g_ppb_touch_input_event_thunk; | 545 return &g_ppb_touch_input_event_thunk; |
523 } | 546 } |
524 | 547 |
525 } // namespace thunk | 548 } // namespace thunk |
526 } // namespace ppapi | 549 } // namespace ppapi |
OLD | NEW |