summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp/dev/text_input_dev.cc
blob: 638883636b3503b24afdd2503afdfe6467b29676 (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
// Copyright (c) 2011 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/dev/text_input_dev.h"

#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module_impl.h"
#include "ppapi/cpp/rect.h"

namespace pp {

namespace {

template <> const char* interface_name<PPB_TextInput_Dev>() {
  return PPB_TEXTINPUT_DEV_INTERFACE;
}

}  // namespace


TextInput_Dev::TextInput_Dev(Instance* instance) : instance_(instance) {
}

TextInput_Dev::~TextInput_Dev() {
}

void TextInput_Dev::SetTextInputType(PP_TextInput_Type type) {
  if (!has_interface<PPB_TextInput_Dev>())
    return;
  get_interface<PPB_TextInput_Dev>()->SetTextInputType(
      instance_->pp_instance(), type);
}

void TextInput_Dev::UpdateCaretPosition(const Rect& caret,
                                        const Rect& bounding_box) {
  if (!has_interface<PPB_TextInput_Dev>())
    return;
  get_interface<PPB_TextInput_Dev>()->UpdateCaretPosition(
      instance_->pp_instance(), &caret.pp_rect(), &bounding_box.pp_rect());
}

void TextInput_Dev::CancelCompositionText() {
  if (!has_interface<PPB_TextInput_Dev>())
    return;
  get_interface<PPB_TextInput_Dev>()->CancelCompositionText(
      instance_->pp_instance());
}

}  // namespace pp