OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/c/pp_errors.h" | 5 #include "ppapi/c/pp_errors.h" |
6 #include "ppapi/thunk/thunk.h" | 6 #include "ppapi/thunk/thunk.h" |
7 #include "ppapi/thunk/enter.h" | 7 #include "ppapi/thunk/enter.h" |
8 #include "ppapi/thunk/ppb_input_event_api.h" | 8 #include "ppapi/thunk/ppb_input_event_api.h" |
9 #include "ppapi/thunk/ppb_instance_api.h" | 9 #include "ppapi/thunk/ppb_instance_api.h" |
10 #include "ppapi/thunk/resource_creation_api.h" | 10 #include "ppapi/thunk/resource_creation_api.h" |
11 | 11 |
12 namespace ppapi { | 12 namespace ppapi { |
13 namespace thunk { | 13 namespace thunk { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 typedef EnterFunction<PPB_Instance_FunctionAPI> EnterInstance; | |
18 typedef EnterResource<PPB_InputEvent_API> EnterInputEvent; | 17 typedef EnterResource<PPB_InputEvent_API> EnterInputEvent; |
19 | 18 |
20 // InputEvent ------------------------------------------------------------------ | 19 // InputEvent ------------------------------------------------------------------ |
21 | 20 |
22 int32_t RequestInputEvents(PP_Instance instance, uint32_t event_classes) { | 21 int32_t RequestInputEvents(PP_Instance instance, uint32_t event_classes) { |
23 EnterInstance enter(instance, true); | 22 EnterInstance enter(instance); |
24 if (enter.failed()) | 23 if (enter.failed()) |
25 return enter.retval(); | 24 return enter.retval(); |
26 return enter.functions()->RequestInputEvents(instance, event_classes); | 25 return enter.functions()->RequestInputEvents(instance, event_classes); |
27 } | 26 } |
28 | 27 |
29 int32_t RequestFilteringInputEvents(PP_Instance instance, | 28 int32_t RequestFilteringInputEvents(PP_Instance instance, |
30 uint32_t event_classes) { | 29 uint32_t event_classes) { |
31 EnterInstance enter(instance, true); | 30 EnterInstance enter(instance); |
32 if (enter.failed()) | 31 if (enter.failed()) |
33 return enter.retval(); | 32 return enter.retval(); |
34 return enter.functions()->RequestFilteringInputEvents(instance, | 33 return enter.functions()->RequestFilteringInputEvents(instance, |
35 event_classes); | 34 event_classes); |
36 } | 35 } |
37 | 36 |
38 void ClearInputEventRequest(PP_Instance instance, | 37 void ClearInputEventRequest(PP_Instance instance, |
39 uint32_t event_classes) { | 38 uint32_t event_classes) { |
40 EnterInstance enter(instance, true); | 39 EnterInstance enter(instance); |
41 if (enter.succeeded()) | 40 if (enter.succeeded()) |
42 enter.functions()->ClearInputEventRequest(instance, event_classes); | 41 enter.functions()->ClearInputEventRequest(instance, event_classes); |
43 } | 42 } |
44 | 43 |
45 PP_Bool IsInputEvent(PP_Resource resource) { | 44 PP_Bool IsInputEvent(PP_Resource resource) { |
46 EnterInputEvent enter(resource, false); | 45 EnterInputEvent enter(resource, false); |
47 return enter.succeeded() ? PP_TRUE : PP_FALSE; | 46 return enter.succeeded() ? PP_TRUE : PP_FALSE; |
48 } | 47 } |
49 | 48 |
50 PP_InputEvent_Type GetType(PP_Resource event) { | 49 PP_InputEvent_Type GetType(PP_Resource event) { |
(...skipping 29 matching lines...) Expand all Loading... |
80 | 79 |
81 // Mouse ----------------------------------------------------------------------- | 80 // Mouse ----------------------------------------------------------------------- |
82 | 81 |
83 PP_Resource CreateMouseInputEvent1_0(PP_Instance instance, | 82 PP_Resource CreateMouseInputEvent1_0(PP_Instance instance, |
84 PP_InputEvent_Type type, | 83 PP_InputEvent_Type type, |
85 PP_TimeTicks time_stamp, | 84 PP_TimeTicks time_stamp, |
86 uint32_t modifiers, | 85 uint32_t modifiers, |
87 PP_InputEvent_MouseButton mouse_button, | 86 PP_InputEvent_MouseButton mouse_button, |
88 const PP_Point* mouse_position, | 87 const PP_Point* mouse_position, |
89 int32_t click_count) { | 88 int32_t click_count) { |
90 EnterFunction<ResourceCreationAPI> enter(instance, true); | 89 EnterResourceCreation enter(instance); |
91 if (enter.failed()) | 90 if (enter.failed()) |
92 return 0; | 91 return 0; |
93 | 92 |
94 PP_Point mouse_movement = PP_MakePoint(0, 0); | 93 PP_Point mouse_movement = PP_MakePoint(0, 0); |
95 return enter.functions()->CreateMouseInputEvent(instance, type, time_stamp, | 94 return enter.functions()->CreateMouseInputEvent(instance, type, time_stamp, |
96 modifiers, mouse_button, | 95 modifiers, mouse_button, |
97 mouse_position, click_count, | 96 mouse_position, click_count, |
98 &mouse_movement); | 97 &mouse_movement); |
99 } | 98 } |
100 | 99 |
101 PP_Resource CreateMouseInputEvent1_1(PP_Instance instance, | 100 PP_Resource CreateMouseInputEvent1_1(PP_Instance instance, |
102 PP_InputEvent_Type type, | 101 PP_InputEvent_Type type, |
103 PP_TimeTicks time_stamp, | 102 PP_TimeTicks time_stamp, |
104 uint32_t modifiers, | 103 uint32_t modifiers, |
105 PP_InputEvent_MouseButton mouse_button, | 104 PP_InputEvent_MouseButton mouse_button, |
106 const PP_Point* mouse_position, | 105 const PP_Point* mouse_position, |
107 int32_t click_count, | 106 int32_t click_count, |
108 const PP_Point* mouse_movement) { | 107 const PP_Point* mouse_movement) { |
109 EnterFunction<ResourceCreationAPI> enter(instance, true); | 108 EnterResourceCreation enter(instance); |
110 if (enter.failed()) | 109 if (enter.failed()) |
111 return 0; | 110 return 0; |
112 return enter.functions()->CreateMouseInputEvent(instance, type, time_stamp, | 111 return enter.functions()->CreateMouseInputEvent(instance, type, time_stamp, |
113 modifiers, mouse_button, | 112 modifiers, mouse_button, |
114 mouse_position, click_count, | 113 mouse_position, click_count, |
115 mouse_movement); | 114 mouse_movement); |
116 } | 115 } |
117 | 116 |
118 PP_Bool IsMouseInputEvent(PP_Resource resource) { | 117 PP_Bool IsMouseInputEvent(PP_Resource resource) { |
119 if (!IsInputEvent(resource)) | 118 if (!IsInputEvent(resource)) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 }; | 172 }; |
174 | 173 |
175 // Wheel ----------------------------------------------------------------------- | 174 // Wheel ----------------------------------------------------------------------- |
176 | 175 |
177 PP_Resource CreateWheelInputEvent(PP_Instance instance, | 176 PP_Resource CreateWheelInputEvent(PP_Instance instance, |
178 PP_TimeTicks time_stamp, | 177 PP_TimeTicks time_stamp, |
179 uint32_t modifiers, | 178 uint32_t modifiers, |
180 const PP_FloatPoint* wheel_delta, | 179 const PP_FloatPoint* wheel_delta, |
181 const PP_FloatPoint* wheel_ticks, | 180 const PP_FloatPoint* wheel_ticks, |
182 PP_Bool scroll_by_page) { | 181 PP_Bool scroll_by_page) { |
183 EnterFunction<ResourceCreationAPI> enter(instance, true); | 182 EnterResourceCreation enter(instance); |
184 if (enter.failed()) | 183 if (enter.failed()) |
185 return 0; | 184 return 0; |
186 return enter.functions()->CreateWheelInputEvent(instance, time_stamp, | 185 return enter.functions()->CreateWheelInputEvent(instance, time_stamp, |
187 modifiers, wheel_delta, | 186 modifiers, wheel_delta, |
188 wheel_ticks, scroll_by_page); | 187 wheel_ticks, scroll_by_page); |
189 } | 188 } |
190 | 189 |
191 PP_Bool IsWheelInputEvent(PP_Resource resource) { | 190 PP_Bool IsWheelInputEvent(PP_Resource resource) { |
192 if (!IsInputEvent(resource)) | 191 if (!IsInputEvent(resource)) |
193 return PP_FALSE; // Prevent warning log in GetType. | 192 return PP_FALSE; // Prevent warning log in GetType. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 }; | 224 }; |
226 | 225 |
227 // Keyboard -------------------------------------------------------------------- | 226 // Keyboard -------------------------------------------------------------------- |
228 | 227 |
229 PP_Resource CreateKeyboardInputEvent(PP_Instance instance, | 228 PP_Resource CreateKeyboardInputEvent(PP_Instance instance, |
230 PP_InputEvent_Type type, | 229 PP_InputEvent_Type type, |
231 PP_TimeTicks time_stamp, | 230 PP_TimeTicks time_stamp, |
232 uint32_t modifiers, | 231 uint32_t modifiers, |
233 uint32_t key_code, | 232 uint32_t key_code, |
234 struct PP_Var character_text) { | 233 struct PP_Var character_text) { |
235 EnterFunction<ResourceCreationAPI> enter(instance, true); | 234 EnterResourceCreation enter(instance); |
236 if (enter.failed()) | 235 if (enter.failed()) |
237 return 0; | 236 return 0; |
238 return enter.functions()->CreateKeyboardInputEvent(instance, type, time_stamp, | 237 return enter.functions()->CreateKeyboardInputEvent(instance, type, time_stamp, |
239 modifiers, key_code, | 238 modifiers, key_code, |
240 character_text); | 239 character_text); |
241 } | 240 } |
242 | 241 |
243 PP_Bool IsKeyboardInputEvent(PP_Resource resource) { | 242 PP_Bool IsKeyboardInputEvent(PP_Resource resource) { |
244 if (!IsInputEvent(resource)) | 243 if (!IsInputEvent(resource)) |
245 return PP_FALSE; // Prevent warning log in GetType. | 244 return PP_FALSE; // Prevent warning log in GetType. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 const PPB_WheelInputEvent_1_0* GetPPB_WheelInputEvent_1_0_Thunk() { | 375 const PPB_WheelInputEvent_1_0* GetPPB_WheelInputEvent_1_0_Thunk() { |
377 return &g_ppb_wheel_input_event_thunk; | 376 return &g_ppb_wheel_input_event_thunk; |
378 } | 377 } |
379 | 378 |
380 const PPB_IMEInputEvent_Dev_0_1* GetPPB_IMEInputEvent_Dev_0_1_Thunk() { | 379 const PPB_IMEInputEvent_Dev_0_1* GetPPB_IMEInputEvent_Dev_0_1_Thunk() { |
381 return &g_ppb_ime_input_event_thunk; | 380 return &g_ppb_ime_input_event_thunk; |
382 } | 381 } |
383 | 382 |
384 } // namespace thunk | 383 } // namespace thunk |
385 } // namespace ppapi | 384 } // namespace ppapi |
OLD | NEW |