1 // Copyright 2013 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. 4 5 #include "ppapi/cpp/text_input_controller.h" 6 7 #include "ppapi/cpp/module_impl.h" 8 #include "ppapi/cpp/rect.h" 9 #include "ppapi/cpp/var.h" 10 11 namespace pp { 12 13 namespace { 14 interface_name()15template <> const char* interface_name<PPB_TextInputController_1_0>() { 16 return PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0; 17 } 18 19 } // namespace 20 21 TextInputController(const InstanceHandle & instance)22TextInputController::TextInputController(const InstanceHandle& instance) 23 : instance_(instance) { 24 } 25 ~TextInputController()26TextInputController::~TextInputController() { 27 } 28 SetTextInputType(PP_TextInput_Type type)29void TextInputController::SetTextInputType(PP_TextInput_Type type) { 30 if (has_interface<PPB_TextInputController_1_0>()) { 31 get_interface<PPB_TextInputController_1_0>()->SetTextInputType( 32 instance_.pp_instance(), type); 33 } 34 } 35 UpdateCaretPosition(const Rect & caret)36void TextInputController::UpdateCaretPosition(const Rect& caret) { 37 if (has_interface<PPB_TextInputController_1_0>()) { 38 get_interface<PPB_TextInputController_1_0>()->UpdateCaretPosition( 39 instance_.pp_instance(), &caret.pp_rect()); 40 } 41 } 42 CancelCompositionText()43void TextInputController::CancelCompositionText() { 44 if (has_interface<PPB_TextInputController_1_0>()) { 45 get_interface<PPB_TextInputController_1_0>()->CancelCompositionText( 46 instance_.pp_instance()); 47 } 48 } 49 UpdateSurroundingText(const Var & text,uint32_t caret,uint32_t anchor)50void TextInputController::UpdateSurroundingText(const Var& text, 51 uint32_t caret, 52 uint32_t anchor) { 53 if (has_interface<PPB_TextInputController_1_0>()) { 54 get_interface<PPB_TextInputController_1_0>()->UpdateSurroundingText( 55 instance_.pp_instance(), 56 text.pp_var(), 57 caret, 58 anchor); 59 } 60 } 61 62 63 } // namespace pp 64