cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / ppapi / thunk / ppb_text_input_thunk.cc
bloba59146bd1f7b98ed18896231d7697af696087b06
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
3 // found in the LICENSE file.
5 #include "base/basictypes.h"
6 #include "ppapi/c/dev/ppb_text_input_dev.h"
7 #include "ppapi/c/ppb_text_input_controller.h"
8 #include "ppapi/shared_impl/var.h"
9 #include "ppapi/thunk/enter.h"
10 #include "ppapi/thunk/ppb_instance_api.h"
11 #include "ppapi/thunk/thunk.h"
13 namespace ppapi {
14 namespace thunk {
16 namespace {
18 COMPILE_ASSERT(int(PP_TEXTINPUT_TYPE_DEV_NONE) == int(PP_TEXTINPUT_TYPE_NONE),
19 mismatching_enums);
20 COMPILE_ASSERT(int(PP_TEXTINPUT_TYPE_DEV_TEXT) == int(PP_TEXTINPUT_TYPE_TEXT),
21 mismatching_enums);
22 COMPILE_ASSERT(
23 int(PP_TEXTINPUT_TYPE_DEV_PASSWORD) == int(PP_TEXTINPUT_TYPE_PASSWORD),
24 mismatching_enums);
25 COMPILE_ASSERT(
26 int(PP_TEXTINPUT_TYPE_DEV_SEARCH) == int(PP_TEXTINPUT_TYPE_SEARCH),
27 mismatching_enums);
28 COMPILE_ASSERT(int(PP_TEXTINPUT_TYPE_DEV_EMAIL) == int(PP_TEXTINPUT_TYPE_EMAIL),
29 mismatching_enums);
30 COMPILE_ASSERT(
31 int(PP_TEXTINPUT_TYPE_DEV_NUMBER) == int(PP_TEXTINPUT_TYPE_NUMBER),
32 mismatching_enums);
33 COMPILE_ASSERT(
34 int(PP_TEXTINPUT_TYPE_DEV_TELEPHONE) == int(PP_TEXTINPUT_TYPE_TELEPHONE),
35 mismatching_enums);
36 COMPILE_ASSERT(int(PP_TEXTINPUT_TYPE_DEV_URL) == int(PP_TEXTINPUT_TYPE_URL),
37 mismatching_enums);
39 void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) {
40 EnterInstance enter(instance);
41 if (enter.succeeded())
42 enter.functions()->SetTextInputType(instance, type);
45 void SetTextInputType_0_2(PP_Instance instance, PP_TextInput_Type_Dev type) {
46 EnterInstance enter(instance);
47 if (enter.succeeded())
48 enter.functions()->SetTextInputType(instance,
49 static_cast<PP_TextInput_Type>(type));
52 void UpdateCaretPosition_0_2(PP_Instance instance,
53 const PP_Rect* caret,
54 const PP_Rect* bounding_box) {
55 EnterInstance enter(instance);
56 if (enter.succeeded() && caret && bounding_box)
57 enter.functions()->UpdateCaretPosition(instance, *caret, *bounding_box);
60 void UpdateCaretPosition(PP_Instance instance,
61 const PP_Rect* caret) {
62 EnterInstance enter(instance);
63 if (enter.succeeded() && caret)
64 enter.functions()->UpdateCaretPosition(instance, *caret, PP_Rect());
67 void CancelCompositionText(PP_Instance instance) {
68 EnterInstance enter(instance);
69 if (enter.succeeded())
70 enter.functions()->CancelCompositionText(instance);
73 void UpdateSurroundingText_0_2(PP_Instance instance, const char* text,
74 uint32_t caret, uint32_t anchor) {
75 EnterInstance enter(instance);
76 if (enter.succeeded())
77 enter.functions()->UpdateSurroundingText(instance, text, caret, anchor);
80 void UpdateSurroundingText_1_0(PP_Instance instance, PP_Var text,
81 uint32_t caret, uint32_t anchor) {
82 EnterInstance enter(instance);
83 StringVar* var = StringVar::FromPPVar(text);
84 if (enter.succeeded() && var)
85 enter.functions()->UpdateSurroundingText(instance,
86 var->value().c_str(),
87 caret,
88 anchor);
91 void SelectionChanged(PP_Instance instance) {
92 EnterInstance enter(instance);
93 if (enter.succeeded())
94 enter.functions()->SelectionChanged(instance);
97 const PPB_TextInput_Dev_0_1 g_ppb_textinput_0_1_thunk = {
98 &SetTextInputType_0_2,
99 &UpdateCaretPosition_0_2,
100 &CancelCompositionText,
103 const PPB_TextInput_Dev_0_2 g_ppb_textinput_0_2_thunk = {
104 &SetTextInputType_0_2,
105 &UpdateCaretPosition_0_2,
106 &CancelCompositionText,
107 &UpdateSurroundingText_0_2,
108 &SelectionChanged,
111 const PPB_TextInputController_1_0 g_ppb_textinputcontroller_1_0_thunk = {
112 &SetTextInputType,
113 &UpdateCaretPosition,
114 &CancelCompositionText,
115 &UpdateSurroundingText_1_0,
118 } // namespace
120 const PPB_TextInput_Dev_0_1* GetPPB_TextInput_Dev_0_1_Thunk() {
121 return &g_ppb_textinput_0_1_thunk;
124 const PPB_TextInput_Dev_0_2* GetPPB_TextInput_Dev_0_2_Thunk() {
125 return &g_ppb_textinput_0_2_thunk;
128 const PPB_TextInputController_1_0* GetPPB_TextInputController_1_0_Thunk() {
129 return &g_ppb_textinputcontroller_1_0_thunk;
132 } // namespace thunk
133 } // namespace ppapi