summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp/text_input_controller.cc
blob: 59850d31be0d25f7ae7bc1ebe8b839982ba603e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2013 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/cpp/module_impl.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/var.h"

namespace pp {

namespace {

template <> const char* interface_name<PPB_TextInputController_1_0>() {
  return PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0;
}

}  // namespace


TextInputController::TextInputController(const InstanceHandle& 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) {
  if (has_interface<PPB_TextInputController_1_0>()) {
    get_interface<PPB_TextInputController_1_0>()->UpdateCaretPosition(
        instance_.pp_instance(), &caret.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 Var& text,
                                                uint32_t caret,
                                                uint32_t anchor) {
  if (has_interface<PPB_TextInputController_1_0>()) {
    get_interface<PPB_TextInputController_1_0>()->UpdateSurroundingText(
        instance_.pp_instance(),
        text.pp_var(),
        caret,
        anchor);
  }
}


}  // namespace pp