Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / ppapi / shared_impl / ppb_input_event_shared.h
blobad467b4551c6f8c032573ff0421175b409f92fa7
1 // Copyright (c) 2012 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.
5 #ifndef PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_
6 #define PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "ppapi/c/ppb_input_event.h"
14 #include "ppapi/shared_impl/resource.h"
15 #include "ppapi/thunk/ppb_input_event_api.h"
17 namespace ppapi {
19 // IF YOU ADD STUFF TO THIS CLASS
20 // ==============================
21 // Be sure to add it to the STRUCT_TRAITS at the top of ppapi_messages.h
22 struct PPAPI_SHARED_EXPORT InputEventData {
23 InputEventData();
24 ~InputEventData();
26 // Internal-only value. Set to true when this input event is filtered, that
27 // is, should be delivered synchronously. This is used by the proxy.
28 bool is_filtered;
30 PP_InputEvent_Type event_type;
31 PP_TimeTicks event_time_stamp;
32 uint32_t event_modifiers;
34 PP_InputEvent_MouseButton mouse_button;
35 PP_Point mouse_position;
36 int32_t mouse_click_count;
37 PP_Point mouse_movement;
39 PP_FloatPoint wheel_delta;
40 PP_FloatPoint wheel_ticks;
41 bool wheel_scroll_by_page;
43 uint32_t key_code;
45 // The key event's |code| attribute as defined in:
46 // http://www.w3.org/TR/uievents/
47 std::string code;
49 std::string character_text;
51 std::vector<uint32_t> composition_segment_offsets;
52 int32_t composition_target_segment;
53 uint32_t composition_selection_start;
54 uint32_t composition_selection_end;
56 std::vector<PP_TouchPoint> touches;
57 std::vector<PP_TouchPoint> changed_touches;
58 std::vector<PP_TouchPoint> target_touches;
61 // This simple class implements the PPB_InputEvent_API in terms of the
62 // shared InputEventData structure
63 class PPAPI_SHARED_EXPORT PPB_InputEvent_Shared
64 : public Resource,
65 public thunk::PPB_InputEvent_API {
66 public:
67 PPB_InputEvent_Shared(ResourceObjectType type,
68 PP_Instance instance,
69 const InputEventData& data);
71 // Resource overrides.
72 virtual PPB_InputEvent_API* AsPPB_InputEvent_API() OVERRIDE;
74 // PPB_InputEvent_API implementation.
75 virtual const InputEventData& GetInputEventData() const OVERRIDE;
76 virtual PP_InputEvent_Type GetType() OVERRIDE;
77 virtual PP_TimeTicks GetTimeStamp() OVERRIDE;
78 virtual uint32_t GetModifiers() OVERRIDE;
79 virtual PP_InputEvent_MouseButton GetMouseButton() OVERRIDE;
80 virtual PP_Point GetMousePosition() OVERRIDE;
81 virtual int32_t GetMouseClickCount() OVERRIDE;
82 virtual PP_Point GetMouseMovement() OVERRIDE;
83 virtual PP_FloatPoint GetWheelDelta() OVERRIDE;
84 virtual PP_FloatPoint GetWheelTicks() OVERRIDE;
85 virtual PP_Bool GetWheelScrollByPage() OVERRIDE;
86 virtual uint32_t GetKeyCode() OVERRIDE;
87 virtual PP_Var GetCharacterText() OVERRIDE;
88 virtual PP_Var GetCode() OVERRIDE;
89 virtual uint32_t GetIMESegmentNumber() OVERRIDE;
90 virtual uint32_t GetIMESegmentOffset(uint32_t index) OVERRIDE;
91 virtual int32_t GetIMETargetSegment() OVERRIDE;
92 virtual void GetIMESelection(uint32_t* start, uint32_t* end) OVERRIDE;
93 virtual void AddTouchPoint(PP_TouchListType list,
94 const PP_TouchPoint& point) OVERRIDE;
95 virtual uint32_t GetTouchCount(PP_TouchListType list) OVERRIDE;
96 virtual PP_TouchPoint GetTouchByIndex(PP_TouchListType list,
97 uint32_t index) OVERRIDE;
98 virtual PP_TouchPoint GetTouchById(PP_TouchListType list,
99 uint32_t id) OVERRIDE;
101 // Implementations for event creation.
102 static PP_Resource CreateIMEInputEvent(ResourceObjectType type,
103 PP_Instance instance,
104 PP_InputEvent_Type event_type,
105 PP_TimeTicks time_stamp,
106 struct PP_Var text,
107 uint32_t segment_number,
108 const uint32_t* segment_offsets,
109 int32_t target_segment,
110 uint32_t selection_start,
111 uint32_t selection_end);
112 static PP_Resource CreateKeyboardInputEvent(ResourceObjectType type,
113 PP_Instance instance,
114 PP_InputEvent_Type event_type,
115 PP_TimeTicks time_stamp,
116 uint32_t modifiers,
117 uint32_t key_code,
118 struct PP_Var character_text,
119 struct PP_Var code);
120 static PP_Resource CreateMouseInputEvent(
121 ResourceObjectType type,
122 PP_Instance instance,
123 PP_InputEvent_Type event_type,
124 PP_TimeTicks time_stamp,
125 uint32_t modifiers,
126 PP_InputEvent_MouseButton mouse_button,
127 const PP_Point* mouse_position,
128 int32_t click_count,
129 const PP_Point* mouse_movement);
130 static PP_Resource CreateWheelInputEvent(ResourceObjectType type,
131 PP_Instance instance,
132 PP_TimeTicks time_stamp,
133 uint32_t modifiers,
134 const PP_FloatPoint* wheel_delta,
135 const PP_FloatPoint* wheel_ticks,
136 PP_Bool scroll_by_page);
137 static PP_Resource CreateTouchInputEvent(ResourceObjectType type,
138 PP_Instance instance,
139 PP_InputEvent_Type event_type,
140 PP_TimeTicks time_stamp,
141 uint32_t modifiers);
143 private:
144 InputEventData data_;
146 DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_InputEvent_Shared);
149 } // namespace ppapi
151 #endif // PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_