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

Side by Side Diff: ppapi/thunk/ppb_input_event_thunk.cc

Issue 8059006: Additional update on Pepper IME API and boilerplate thunk/proxy implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make win_shared happy. Created 9 years, 2 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
« no previous file with comments | « ppapi/thunk/ppb_input_event_api.h ('k') | ppapi/thunk/ppb_text_input_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 return enter.object()->GetCharacterText(); 264 return enter.object()->GetCharacterText();
265 } 265 }
266 266
267 const PPB_KeyboardInputEvent g_ppb_keyboard_input_event_thunk = { 267 const PPB_KeyboardInputEvent g_ppb_keyboard_input_event_thunk = {
268 &CreateKeyboardInputEvent, 268 &CreateKeyboardInputEvent,
269 &IsKeyboardInputEvent, 269 &IsKeyboardInputEvent,
270 &GetKeyCode, 270 &GetKeyCode,
271 &GetCharacterText 271 &GetCharacterText
272 }; 272 };
273 273
274 // Composition -----------------------------------------------------------------
275
276 PP_Bool IsIMEInputEvent(PP_Resource resource) {
277 if (!IsInputEvent(resource))
278 return PP_FALSE; // Prevent warning log in GetType.
279 PP_InputEvent_Type type = GetType(resource);
280 return PP_FromBool(type == PP_INPUTEVENT_TYPE_IME_COMPOSITION_START ||
281 type == PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE ||
282 type == PP_INPUTEVENT_TYPE_IME_COMPOSITION_END ||
283 type == PP_INPUTEVENT_TYPE_IME_TEXT);
284 }
285
286 PP_Var GetIMEText(PP_Resource ime_event) {
287 return GetCharacterText(ime_event);
288 }
289
290 uint32_t GetIMESegmentNumber(PP_Resource ime_event) {
291 EnterInputEvent enter(ime_event, true);
292 if (enter.failed())
293 return 0;
294 return enter.object()->GetIMESegmentNumber();
295 }
296
297 uint32_t GetIMESegmentOffset(PP_Resource ime_event, uint32_t index) {
298 EnterInputEvent enter(ime_event, true);
299 if (enter.failed())
300 return 0;
301 return enter.object()->GetIMESegmentOffset(index);
302 }
303
304 int32_t GetIMETargetSegment(PP_Resource ime_event) {
305 EnterInputEvent enter(ime_event, true);
306 if (enter.failed())
307 return -1;
308 return enter.object()->GetIMETargetSegment();
309 }
310
311 void GetIMESelection(PP_Resource ime_event, uint32_t* start, uint32_t* end) {
312 EnterInputEvent enter(ime_event, true);
313 if (enter.failed()) {
314 if (start)
315 *start = 0;
316 if (end)
317 *end = 0;
318 return;
319 }
320 enter.object()->GetIMESelection(start, end);
321 }
322
323 const PPB_IMEInputEvent_Dev g_ppb_ime_input_event_thunk = {
324 &IsIMEInputEvent,
325 &GetIMEText,
326 &GetIMESegmentNumber,
327 &GetIMESegmentOffset,
328 &GetIMETargetSegment,
329 &GetIMESelection
330 };
331
274 } // namespace 332 } // namespace
275 333
276 const PPB_InputEvent* GetPPB_InputEvent_Thunk() { 334 const PPB_InputEvent* GetPPB_InputEvent_Thunk() {
277 return &g_ppb_input_event_thunk; 335 return &g_ppb_input_event_thunk;
278 } 336 }
279 337
280 const PPB_MouseInputEvent_1_0* GetPPB_MouseInputEvent_1_0_Thunk() { 338 const PPB_MouseInputEvent_1_0* GetPPB_MouseInputEvent_1_0_Thunk() {
281 return &g_ppb_mouse_input_event_1_0_thunk; 339 return &g_ppb_mouse_input_event_1_0_thunk;
282 } 340 }
283 341
284 const PPB_MouseInputEvent* GetPPB_MouseInputEvent_Thunk() { 342 const PPB_MouseInputEvent* GetPPB_MouseInputEvent_Thunk() {
285 return &g_ppb_mouse_input_event_1_1_thunk; 343 return &g_ppb_mouse_input_event_1_1_thunk;
286 } 344 }
287 345
288 const PPB_KeyboardInputEvent* GetPPB_KeyboardInputEvent_Thunk() { 346 const PPB_KeyboardInputEvent* GetPPB_KeyboardInputEvent_Thunk() {
289 return &g_ppb_keyboard_input_event_thunk; 347 return &g_ppb_keyboard_input_event_thunk;
290 } 348 }
291 349
292 const PPB_WheelInputEvent* GetPPB_WheelInputEvent_Thunk() { 350 const PPB_WheelInputEvent* GetPPB_WheelInputEvent_Thunk() {
293 return &g_ppb_wheel_input_event_thunk; 351 return &g_ppb_wheel_input_event_thunk;
294 } 352 }
295 353
354 const PPB_IMEInputEvent_Dev* GetPPB_IMEInputEvent_Dev_Thunk() {
355 return &g_ppb_ime_input_event_thunk;
356 }
357
296 } // namespace thunk 358 } // namespace thunk
297 } // namespace ppapi 359 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_input_event_api.h ('k') | ppapi/thunk/ppb_text_input_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698