Make castv2 performance test work.
[chromium-blink-merge.git] / ppapi / shared_impl / ppb_input_event_shared.h
blobbd0d175595111571cd5a6eed0bc0abab57ee971f
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"
16 #include "ui/events/latency_info.h"
18 namespace ppapi {
20 // IF YOU ADD STUFF TO THIS CLASS
21 // ==============================
22 // Be sure to add it to the STRUCT_TRAITS at the top of ppapi_messages.h
23 struct PPAPI_SHARED_EXPORT InputEventData {
24 InputEventData();
25 ~InputEventData();
27 // Internal-only value. Set to true when this input event is filtered, that
28 // is, should be delivered synchronously. This is used by the proxy.
29 bool is_filtered;
31 PP_InputEvent_Type event_type;
32 PP_TimeTicks event_time_stamp;
33 uint32_t event_modifiers;
35 PP_InputEvent_MouseButton mouse_button;
36 PP_Point mouse_position;
37 int32_t mouse_click_count;
38 PP_Point mouse_movement;
40 PP_FloatPoint wheel_delta;
41 PP_FloatPoint wheel_ticks;
42 bool wheel_scroll_by_page;
44 uint32_t key_code;
46 // The key event's |code| attribute as defined in:
47 // http://www.w3.org/TR/uievents/
48 std::string code;
50 std::string character_text;
52 std::vector<uint32_t> composition_segment_offsets;
53 int32_t composition_target_segment;
54 uint32_t composition_selection_start;
55 uint32_t composition_selection_end;
57 std::vector<PP_TouchPoint> touches;
58 std::vector<PP_TouchPoint> changed_touches;
59 std::vector<PP_TouchPoint> target_touches;
61 ui::LatencyInfo latency_info;
64 // This simple class implements the PPB_InputEvent_API in terms of the
65 // shared InputEventData structure
66 class PPAPI_SHARED_EXPORT PPB_InputEvent_Shared
67 : public Resource,
68 public thunk::PPB_InputEvent_API {
69 public:
70 PPB_InputEvent_Shared(ResourceObjectType type,
71 PP_Instance instance,
72 const InputEventData& data);
74 // Resource overrides.
75 virtual PPB_InputEvent_API* AsPPB_InputEvent_API() override;
77 // PPB_InputEvent_API implementation.
78 virtual const InputEventData& GetInputEventData() const override;
79 virtual PP_InputEvent_Type GetType() override;
80 virtual PP_TimeTicks GetTimeStamp() override;
81 virtual uint32_t GetModifiers() override;
82 virtual PP_InputEvent_MouseButton GetMouseButton() override;
83 virtual PP_Point GetMousePosition() override;
84 virtual int32_t GetMouseClickCount() override;
85 virtual PP_Point GetMouseMovement() override;
86 virtual PP_FloatPoint GetWheelDelta() override;
87 virtual PP_FloatPoint GetWheelTicks() override;
88 virtual PP_Bool GetWheelScrollByPage() override;
89 virtual uint32_t GetKeyCode() override;
90 virtual PP_Var GetCharacterText() override;
91 virtual PP_Var GetCode() override;
92 virtual uint32_t GetIMESegmentNumber() override;
93 virtual uint32_t GetIMESegmentOffset(uint32_t index) override;
94 virtual int32_t GetIMETargetSegment() override;
95 virtual void GetIMESelection(uint32_t* start, uint32_t* end) override;
96 virtual void AddTouchPoint(PP_TouchListType list,
97 const PP_TouchPoint& point) override;
98 virtual uint32_t GetTouchCount(PP_TouchListType list) override;
99 virtual PP_TouchPoint GetTouchByIndex(PP_TouchListType list,
100 uint32_t index) override;
101 virtual PP_TouchPoint GetTouchById(PP_TouchListType list,
102 uint32_t id) override;
103 virtual PP_Bool TraceInputLatency(PP_Bool has_damage) override;
105 // Implementations for event creation.
106 static PP_Resource CreateIMEInputEvent(ResourceObjectType type,
107 PP_Instance instance,
108 PP_InputEvent_Type event_type,
109 PP_TimeTicks time_stamp,
110 struct PP_Var text,
111 uint32_t segment_number,
112 const uint32_t* segment_offsets,
113 int32_t target_segment,
114 uint32_t selection_start,
115 uint32_t selection_end);
116 static PP_Resource CreateKeyboardInputEvent(ResourceObjectType type,
117 PP_Instance instance,
118 PP_InputEvent_Type event_type,
119 PP_TimeTicks time_stamp,
120 uint32_t modifiers,
121 uint32_t key_code,
122 struct PP_Var character_text,
123 struct PP_Var code);
124 static PP_Resource CreateMouseInputEvent(
125 ResourceObjectType type,
126 PP_Instance instance,
127 PP_InputEvent_Type event_type,
128 PP_TimeTicks time_stamp,
129 uint32_t modifiers,
130 PP_InputEvent_MouseButton mouse_button,
131 const PP_Point* mouse_position,
132 int32_t click_count,
133 const PP_Point* mouse_movement);
134 static PP_Resource CreateWheelInputEvent(ResourceObjectType type,
135 PP_Instance instance,
136 PP_TimeTicks time_stamp,
137 uint32_t modifiers,
138 const PP_FloatPoint* wheel_delta,
139 const PP_FloatPoint* wheel_ticks,
140 PP_Bool scroll_by_page);
141 static PP_Resource CreateTouchInputEvent(ResourceObjectType type,
142 PP_Instance instance,
143 PP_InputEvent_Type event_type,
144 PP_TimeTicks time_stamp,
145 uint32_t modifiers);
147 private:
148 InputEventData data_;
150 DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_InputEvent_Shared);
153 } // namespace ppapi
155 #endif // PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_