| 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/ppb_text_input_controller.h" |
| 6 |
| 5 #include "ppapi/thunk/enter.h" | 7 #include "ppapi/thunk/enter.h" |
| 6 #include "ppapi/thunk/thunk.h" | 8 #include "ppapi/thunk/thunk.h" |
| 7 #include "ppapi/thunk/ppb_instance_api.h" | 9 #include "ppapi/thunk/ppb_instance_api.h" |
| 8 | 10 |
| 9 namespace ppapi { | 11 namespace ppapi { |
| 10 namespace thunk { | 12 namespace thunk { |
| 11 | 13 |
| 12 namespace { | 14 namespace { |
| 13 | 15 |
| 14 void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) { | 16 void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) { |
| 15 EnterInstance enter(instance); | 17 EnterInstance enter(instance); |
| 16 if (enter.succeeded()) | 18 if (enter.succeeded()) |
| 17 enter.functions()->SetTextInputType(instance, type); | 19 enter.functions()->SetTextInputType(instance, type); |
| 18 } | 20 } |
| 19 | 21 |
| 20 void UpdateCaretPosition(PP_Instance instance, | 22 void UpdateCaretPosition_0_2(PP_Instance instance, |
| 21 const PP_Rect* caret, | 23 const PP_Rect* caret, |
| 22 const PP_Rect* bounding_box) { | 24 const PP_Rect* bounding_box) { |
| 23 EnterInstance enter(instance); | 25 EnterInstance enter(instance); |
| 24 if (enter.succeeded() && caret && bounding_box) | 26 if (enter.succeeded() && caret && bounding_box) |
| 25 enter.functions()->UpdateCaretPosition(instance, *caret, *bounding_box); | 27 enter.functions()->UpdateCaretPosition(instance, *caret, *bounding_box); |
| 26 } | 28 } |
| 27 | 29 |
| 30 void UpdateCaretPosition(PP_Instance instance, |
| 31 const PP_Rect* caret) { |
| 32 EnterInstance enter(instance); |
| 33 if (enter.succeeded() && caret) |
| 34 enter.functions()->UpdateCaretPosition(instance, *caret, PP_Rect()); |
| 35 } |
| 36 |
| 28 void CancelCompositionText(PP_Instance instance) { | 37 void CancelCompositionText(PP_Instance instance) { |
| 29 EnterInstance enter(instance); | 38 EnterInstance enter(instance); |
| 30 if (enter.succeeded()) | 39 if (enter.succeeded()) |
| 31 enter.functions()->CancelCompositionText(instance); | 40 enter.functions()->CancelCompositionText(instance); |
| 32 } | 41 } |
| 33 | 42 |
| 34 void UpdateSurroundingText(PP_Instance instance, const char* text, | 43 void UpdateSurroundingText(PP_Instance instance, const char* text, |
| 35 uint32_t caret, uint32_t anchor) { | 44 uint32_t caret, uint32_t anchor) { |
| 36 EnterInstance enter(instance); | 45 EnterInstance enter(instance); |
| 37 if (enter.succeeded()) | 46 if (enter.succeeded()) |
| 38 enter.functions()->UpdateSurroundingText(instance, text, caret, anchor); | 47 enter.functions()->UpdateSurroundingText(instance, text, caret, anchor); |
| 39 } | 48 } |
| 40 | 49 |
| 41 void SelectionChanged(PP_Instance instance) { | 50 void SelectionChanged(PP_Instance instance) { |
| 42 EnterInstance enter(instance); | 51 EnterInstance enter(instance); |
| 43 if (enter.succeeded()) | 52 if (enter.succeeded()) |
| 44 enter.functions()->SelectionChanged(instance); | 53 enter.functions()->SelectionChanged(instance); |
| 45 } | 54 } |
| 46 | 55 |
| 47 const PPB_TextInput_Dev_0_1 g_ppb_textinput_0_1_thunk = { | 56 const PPB_TextInput_Dev_0_1 g_ppb_textinput_0_1_thunk = { |
| 48 &SetTextInputType, | 57 &SetTextInputType, |
| 49 &UpdateCaretPosition, | 58 &UpdateCaretPosition_0_2, |
| 50 &CancelCompositionText, | 59 &CancelCompositionText, |
| 51 }; | 60 }; |
| 52 | 61 |
| 53 const PPB_TextInput_Dev g_ppb_textinput_0_2_thunk = { | 62 const PPB_TextInput_Dev_0_2 g_ppb_textinput_0_2_thunk = { |
| 54 &SetTextInputType, | 63 &SetTextInputType, |
| 55 &UpdateCaretPosition, | 64 &UpdateCaretPosition_0_2, |
| 56 &CancelCompositionText, | 65 &CancelCompositionText, |
| 57 &UpdateSurroundingText, | 66 &UpdateSurroundingText, |
| 58 &SelectionChanged, | 67 &SelectionChanged, |
| 59 }; | 68 }; |
| 60 | 69 |
| 70 const PPB_TextInputController_1_0 g_ppb_textinputcontroller_1_0_thunk = { |
| 71 &SetTextInputType, |
| 72 &UpdateCaretPosition, |
| 73 &CancelCompositionText, |
| 74 &UpdateSurroundingText, |
| 75 }; |
| 76 |
| 61 } // namespace | 77 } // namespace |
| 62 | 78 |
| 63 const PPB_TextInput_Dev_0_1* GetPPB_TextInput_Dev_0_1_Thunk() { | 79 const PPB_TextInput_Dev_0_1* GetPPB_TextInput_Dev_0_1_Thunk() { |
| 64 return &g_ppb_textinput_0_1_thunk; | 80 return &g_ppb_textinput_0_1_thunk; |
| 65 } | 81 } |
| 66 | 82 |
| 67 const PPB_TextInput_Dev_0_2* GetPPB_TextInput_Dev_0_2_Thunk() { | 83 const PPB_TextInput_Dev_0_2* GetPPB_TextInput_Dev_0_2_Thunk() { |
| 68 return &g_ppb_textinput_0_2_thunk; | 84 return &g_ppb_textinput_0_2_thunk; |
| 69 } | 85 } |
| 70 | 86 |
| 87 const PPB_TextInputController_1_0* GetPPB_TextInputController_1_0_Thunk() { |
| 88 return &g_ppb_textinputcontroller_1_0_thunk; |
| 89 } |
| 90 |
| 71 } // namespace thunk | 91 } // namespace thunk |
| 72 } // namespace ppapi | 92 } // namespace ppapi |
| OLD | NEW |