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

Side by Side Diff: ppapi/cpp/input_event.cc

Issue 7285010: Implement an input event resource. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
Property Changes:
Added: svn:eol-style
+ LF
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/input_event.h"
6
7 #include "ppapi/cpp/common.h"
8 #include "ppapi/cpp/instance.h"
9 #include "ppapi/cpp/module.h"
10 #include "ppapi/cpp/module_impl.h"
11 #include "ppapi/cpp/point.h"
12 #include "ppapi/cpp/var.h"
13
14 namespace pp {
15
16 namespace {
17
18 template <> const char* interface_name<PPB_InputEvent>() {
19 return PPB_INPUT_EVENT_INTERFACE;
20 }
21
22 } // namespace
23
24 InputEvent::InputEvent() : Resource() {
25 }
26
27 InputEvent::InputEvent(PP_Resource input_event_resource)
28 : Resource(input_event_resource) {
29 }
30
31 InputEvent::~InputEvent() {
32 }
33
34 PP_InputEvent_Type InputEvent::GetEventType() const {
35 if (!has_interface<PPB_InputEvent>())
36 return PP_INPUTEVENT_TYPE_UNDEFINED;
37 return get_interface<PPB_InputEvent>()->GetEventType(pp_resource());
38 }
39
40 PP_TimeTicks InputEvent::GetEventTimeStamp() const {
41 if (!has_interface<PPB_InputEvent>())
42 return 0.0f;
43 return get_interface<PPB_InputEvent>()->GetEventTimeStamp(pp_resource());
44 }
45
46 uint32_t InputEvent::GetEventModifiers() const {
47 if (!has_interface<PPB_InputEvent>())
48 return 0;
49 return get_interface<PPB_InputEvent>()->GetEventModifiers(pp_resource());
50 }
51
52 PP_InputEvent_MouseButton InputEvent::GetMouseButton() const {
53 if (!has_interface<PPB_InputEvent>())
54 return PP_INPUTEVENT_MOUSEBUTTON_NONE;
55 return get_interface<PPB_InputEvent>()->GetMouseButton(pp_resource());
56 }
57
58 Point InputEvent::GetMousePosition() const {
59 if (!has_interface<PPB_InputEvent>())
60 return Point();
61 return get_interface<PPB_InputEvent>()->GetMousePosition(pp_resource());
62 }
63
64 int32_t InputEvent::GetMouseClickCount() const {
65 if (!has_interface<PPB_InputEvent>())
66 return 0;
67 return get_interface<PPB_InputEvent>()->GetMouseClickCount(pp_resource());
68 }
69
70 FloatPoint InputEvent::GetWheelDelta() const {
71 if (!has_interface<PPB_InputEvent>())
72 return FloatPoint();
73 return get_interface<PPB_InputEvent>()->GetWheelDelta(pp_resource());
74 }
75
76 FloatPoint InputEvent::GetWheelTicks() const {
77 if (!has_interface<PPB_InputEvent>())
78 return FloatPoint();
79 return get_interface<PPB_InputEvent>()->GetWheelTicks(pp_resource());
80 }
81
82 uint32_t InputEvent::GetKeyCode() const {
83 if (!has_interface<PPB_InputEvent>())
84 return 0;
85 return get_interface<PPB_InputEvent>()->GetKeyCode(pp_resource());
86 }
87
88 Var InputEvent::GetCharacterText() const {
89 if (!has_interface<PPB_InputEvent>())
90 return PP_INPUTEVENT_TYPE_UNDEFINED;
91 return Var(Var::PassRef(),
92 get_interface<PPB_InputEvent>()->GetCharacterText(pp_resource()));
93 }
94
95 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698