Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(608)

Side by Side Diff: ppapi/cpp/dev/ime_input_event_dev.cc

Issue 7882004: Declarations for Pepper IME API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clarified the specification of GetSegmentAt(). Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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/dev/ime_input_event_dev.h"
6
7 #include "ppapi/cpp/instance.h"
8 #include "ppapi/cpp/module.h"
9 #include "ppapi/cpp/module_impl.h"
10 #include "ppapi/cpp/var.h"
11
12 namespace pp {
13
14 namespace {
15
16 template <> const char* interface_name<PPB_IMEInputEvent_Dev>() {
17 return PPB_IME_INPUT_EVENT_DEV_INTERFACE;
18 }
19
20 } // namespace
21
22 // IMEInputEvent_Dev -------------------------------------------------------
23
24 IMEInputEvent_Dev::IMEInputEvent_Dev() : InputEvent() {
25 }
26
27 IMEInputEvent_Dev::IMEInputEvent_Dev(const InputEvent& event) : InputEvent() {
28 // Type check the input event before setting it.
29 if (!has_interface<PPB_IMEInputEvent_Dev>())
30 return;
31 if (get_interface<PPB_IMEInputEvent_Dev>()->IsIMEInputEvent(
32 event.pp_resource())) {
33 Module::Get()->core()->AddRefResource(event.pp_resource());
34 PassRefFromConstructor(event.pp_resource());
35 }
36 }
37
38 Var IMEInputEvent_Dev::GetText() const {
39 if (!has_interface<PPB_IMEInputEvent_Dev>())
40 return Var();
41 return Var(Var::PassRef(),
42 get_interface<PPB_IMEInputEvent_Dev>()->GetText(pp_resource()));
43 }
44
45 uint32_t IMEInputEvent_Dev::GetSegmentNumber() const {
46 if (!has_interface<PPB_IMEInputEvent_Dev>())
47 return 0;
48 return get_interface<PPB_IMEInputEvent_Dev>()->GetSegmentNumber(
49 pp_resource());
50 }
51
52 std::pair<uint32_t, uint32_t>
53 IMEInputEvent_Dev::GetSegmentAt(uint32_t index) const {
54 std::pair<uint32_t, uint32_t> range(0, 0);
55 if (!has_interface<PPB_IMEInputEvent_Dev>())
56 return range;
57 get_interface<PPB_IMEInputEvent_Dev>()->GetSegmentAt(pp_resource(),
58 index,
59 &range.first,
60 &range.second);
61 return range;
62 }
63
64 int32_t IMEInputEvent_Dev::GetTargetSegment() const {
65 if (!has_interface<PPB_IMEInputEvent_Dev>())
66 return 0;
67 return get_interface<PPB_IMEInputEvent_Dev>()->GetTargetSegment(
68 pp_resource());
69 }
70
71 std::pair<uint32_t, uint32_t> IMEInputEvent_Dev::GetSelection() const {
72 std::pair<uint32_t, uint32_t> range(0, 0);
73 if (!has_interface<PPB_IMEInputEvent_Dev>())
74 return range;
75 get_interface<PPB_IMEInputEvent_Dev>()->GetSelection(pp_resource(),
76 &range.first,
77 &range.second);
78 return range;
79 }
80
81
82 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698