Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: ppapi/thunk/ppb_text_input_thunk.cc

Issue 18671004: PPAPI: Move IMEInputEvent and TextInput to stable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing comments Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
7 #include "ppapi/shared_impl/var.h"
5 #include "ppapi/thunk/enter.h" 8 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/ppb_instance_api.h"
6 #include "ppapi/thunk/thunk.h" 10 #include "ppapi/thunk/thunk.h"
7 #include "ppapi/thunk/ppb_instance_api.h"
8 11
9 namespace ppapi { 12 namespace ppapi {
10 namespace thunk { 13 namespace thunk {
11 14
12 namespace { 15 namespace {
13 16
14 void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) { 17 void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) {
15 EnterInstance enter(instance); 18 EnterInstance enter(instance);
16 if (enter.succeeded()) 19 if (enter.succeeded())
17 enter.functions()->SetTextInputType(instance, type); 20 enter.functions()->SetTextInputType(instance, type);
18 } 21 }
19 22
20 void UpdateCaretPosition(PP_Instance instance, 23 void UpdateCaretPosition_0_2(PP_Instance instance,
21 const PP_Rect* caret, 24 const PP_Rect* caret,
22 const PP_Rect* bounding_box) { 25 const PP_Rect* bounding_box) {
23 EnterInstance enter(instance); 26 EnterInstance enter(instance);
24 if (enter.succeeded() && caret && bounding_box) 27 if (enter.succeeded() && caret && bounding_box)
25 enter.functions()->UpdateCaretPosition(instance, *caret, *bounding_box); 28 enter.functions()->UpdateCaretPosition(instance, *caret, *bounding_box);
26 } 29 }
27 30
31 void UpdateCaretPosition(PP_Instance instance,
32 const PP_Rect* caret) {
33 EnterInstance enter(instance);
34 if (enter.succeeded() && caret)
35 enter.functions()->UpdateCaretPosition(instance, *caret, PP_Rect());
36 }
37
28 void CancelCompositionText(PP_Instance instance) { 38 void CancelCompositionText(PP_Instance instance) {
29 EnterInstance enter(instance); 39 EnterInstance enter(instance);
30 if (enter.succeeded()) 40 if (enter.succeeded())
31 enter.functions()->CancelCompositionText(instance); 41 enter.functions()->CancelCompositionText(instance);
32 } 42 }
33 43
34 void UpdateSurroundingText(PP_Instance instance, const char* text, 44 void UpdateSurroundingText_0_2(PP_Instance instance, const char* text,
35 uint32_t caret, uint32_t anchor) { 45 uint32_t caret, uint32_t anchor) {
36 EnterInstance enter(instance); 46 EnterInstance enter(instance);
37 if (enter.succeeded()) 47 if (enter.succeeded())
38 enter.functions()->UpdateSurroundingText(instance, text, caret, anchor); 48 enter.functions()->UpdateSurroundingText(instance, text, caret, anchor);
39 } 49 }
40 50
51 void UpdateSurroundingText(PP_Instance instance, PP_Var text,
dmichael (off chromium) 2013/07/26 17:59:37 nit: I think it would be clearest to go ahead and
Seigo Nonaka 2013/07/31 18:05:32 Done.
52 uint32_t caret, uint32_t anchor) {
53 EnterInstance enter(instance);
54 StringVar* var = StringVar::FromPPVar(text);
55 if (enter.succeeded() && var)
56 enter.functions()->UpdateSurroundingText(instance,
57 var->value().c_str(),
58 caret,
59 anchor);
60 }
61
41 void SelectionChanged(PP_Instance instance) { 62 void SelectionChanged(PP_Instance instance) {
42 EnterInstance enter(instance); 63 EnterInstance enter(instance);
43 if (enter.succeeded()) 64 if (enter.succeeded())
44 enter.functions()->SelectionChanged(instance); 65 enter.functions()->SelectionChanged(instance);
45 } 66 }
46 67
47 const PPB_TextInput_Dev_0_1 g_ppb_textinput_0_1_thunk = { 68 const PPB_TextInput_Dev_0_1 g_ppb_textinput_0_1_thunk = {
48 &SetTextInputType, 69 &SetTextInputType,
49 &UpdateCaretPosition, 70 &UpdateCaretPosition_0_2,
50 &CancelCompositionText, 71 &CancelCompositionText,
51 }; 72 };
52 73
53 const PPB_TextInput_Dev g_ppb_textinput_0_2_thunk = { 74 const PPB_TextInput_Dev_0_2 g_ppb_textinput_0_2_thunk = {
75 &SetTextInputType,
76 &UpdateCaretPosition_0_2,
77 &CancelCompositionText,
78 &UpdateSurroundingText_0_2,
79 &SelectionChanged,
80 };
81
82 const PPB_TextInputController_1_0 g_ppb_textinputcontroller_1_0_thunk = {
54 &SetTextInputType, 83 &SetTextInputType,
55 &UpdateCaretPosition, 84 &UpdateCaretPosition,
56 &CancelCompositionText, 85 &CancelCompositionText,
57 &UpdateSurroundingText, 86 &UpdateSurroundingText,
58 &SelectionChanged,
59 }; 87 };
60 88
61 } // namespace 89 } // namespace
62 90
63 const PPB_TextInput_Dev_0_1* GetPPB_TextInput_Dev_0_1_Thunk() { 91 const PPB_TextInput_Dev_0_1* GetPPB_TextInput_Dev_0_1_Thunk() {
64 return &g_ppb_textinput_0_1_thunk; 92 return &g_ppb_textinput_0_1_thunk;
65 } 93 }
66 94
67 const PPB_TextInput_Dev_0_2* GetPPB_TextInput_Dev_0_2_Thunk() { 95 const PPB_TextInput_Dev_0_2* GetPPB_TextInput_Dev_0_2_Thunk() {
68 return &g_ppb_textinput_0_2_thunk; 96 return &g_ppb_textinput_0_2_thunk;
69 } 97 }
70 98
99 const PPB_TextInputController_1_0* GetPPB_TextInputController_1_0_Thunk() {
100 return &g_ppb_textinputcontroller_1_0_thunk;
101 }
102
71 } // namespace thunk 103 } // namespace thunk
72 } // namespace ppapi 104 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698