Chromium Code Reviews| Index: ppapi/cpp/text_input_controller.cc |
| diff --git a/ppapi/cpp/text_input_controller.cc b/ppapi/cpp/text_input_controller.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0041f3a6e63fafc351b0d3c0990203d7cf1897ce |
| --- /dev/null |
| +++ b/ppapi/cpp/text_input_controller.cc |
| @@ -0,0 +1,63 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ppapi/cpp/text_input_controller.h" |
| + |
| +#include "ppapi/c/ppb_text_input_controller.h" |
|
yzshen1
2013/07/23 16:48:20
it is not needed because the .h file has included
Seigo Nonaka
2013/07/24 09:05:37
Done.
|
| +#include "ppapi/cpp/instance.h" |
|
yzshen1
2013/07/23 16:48:20
It isn't needed once we change the constructor to
Seigo Nonaka
2013/07/24 09:05:37
Done.
|
| +#include "ppapi/cpp/instance_handle.h" |
|
yzshen1
2013/07/23 16:48:20
ditto.
Seigo Nonaka
2013/07/24 09:05:37
Done.
|
| +#include "ppapi/cpp/module_impl.h" |
| +#include "ppapi/cpp/rect.h" |
| + |
| +namespace pp { |
| + |
| +namespace { |
| + |
| +template <> const char* interface_name<PPB_TextInputController_1_0>() { |
| + return PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0; |
| +} |
| + |
| +} // namespace |
| + |
| + |
| +TextInputController::TextInputController(Instance* instance) |
| + : instance_(instance) { |
| +} |
| + |
| +TextInputController::~TextInputController() { |
| +} |
| + |
| +void TextInputController::SetTextInputType(PP_TextInput_Type type) { |
| + if (has_interface<PPB_TextInputController_1_0>()) { |
| + get_interface<PPB_TextInputController_1_0>()->SetTextInputType( |
| + instance_.pp_instance(), type); |
| + } |
| +} |
| + |
| +void TextInputController::UpdateCaretPosition(const Rect& caret, |
| + const Rect& bounding_box) { |
|
yzshen1
2013/07/23 16:48:20
wrong indent.
Seigo Nonaka
2013/07/24 09:05:37
Done.
|
| + if (has_interface<PPB_TextInputController_1_0>()) { |
| + get_interface<PPB_TextInputController_1_0>()->UpdateCaretPosition( |
| + instance_.pp_instance(), &caret.pp_rect(), &bounding_box.pp_rect()); |
| + } |
| +} |
| + |
| +void TextInputController::CancelCompositionText() { |
| + if (has_interface<PPB_TextInputController_1_0>()) { |
| + get_interface<PPB_TextInputController_1_0>()->CancelCompositionText( |
| + instance_.pp_instance()); |
| + } |
| +} |
| + |
| +void TextInputController::UpdateSurroundingText(const std::string& text, |
| + uint32_t caret, |
|
yzshen1
2013/07/23 16:48:20
wrong indent.
Seigo Nonaka
2013/07/24 09:05:37
Done.
|
| + uint32_t anchor) { |
| + if (has_interface<PPB_TextInputController_1_0>()) { |
| + get_interface<PPB_TextInputController_1_0>()->UpdateSurroundingText( |
| + instance_.pp_instance(), text.c_str(), caret, anchor); |
| + } |
| +} |
| + |
| + |
| +} // namespace pp |