diff options
author | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-14 11:50:27 +0000 |
---|---|---|
committer | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-14 11:50:27 +0000 |
commit | f0287d39566b717d4e73b4ae8222d08d96e4a873 (patch) | |
tree | d85aaaefe9406dc829370e09b394a146cee92fcf /ppapi | |
parent | d1c2ab117942b72556e987a209cb0068acc8d907 (diff) | |
download | chromium_src-f0287d39566b717d4e73b4ae8222d08d96e4a873.zip chromium_src-f0287d39566b717d4e73b4ae8222d08d96e4a873.tar.gz chromium_src-f0287d39566b717d4e73b4ae8222d08d96e4a873.tar.bz2 |
The current PPB_KeyboardInputEvent_Dev interface uses the old USB codes which were part of the original proposal.
The current working-draft spec from W3C (http://www.w3.org/TR/uievents/) uses string names rather than Unicode ints. This cl updates the _Dev API to match the current spec.
Note that the new APIs cannot be used until the Blink plumbing for |code| is added in a following CL.
We would like to deprecate the current _Dev interface (GetUsbKeyCode) and move the new interface (GetCode) out of _Dev for M31.
A note on naming: The DOM KeyboardEvent has the following attributes:
* keyIdentifier (deprecated - we'll be removing this)
* keyCode (deprecated, but it'll stick around for a while)
* charCode (deprecated, but it'll stick around for a while)
* key (specified in DOM3, not yet implemented in Chrome)
* code (specified in UIEvents, adding support for this now)
The current PepperAPI already has:
* GetKeyCode (return the keyCode)
So I used GetCode() here and I assume that we'll be adding GetKey() when we support |key|.
Suggestions for better naming conventions are welcome.
BUG=284774
Review URL: https://chromiumcodereview.appspot.com/23526007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223239 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/api/dev/ppb_keyboard_input_event_dev.idl | 16 | ||||
-rw-r--r-- | ppapi/c/dev/ppb_keyboard_input_event_dev.h | 22 | ||||
-rw-r--r-- | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c | 33 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 1 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_input_event_shared.cc | 5 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_input_event_shared.h | 5 | ||||
-rw-r--r-- | ppapi/thunk/interfaces_ppb_public_dev.h | 4 | ||||
-rw-r--r-- | ppapi/thunk/ppb_input_event_api.h | 1 | ||||
-rw-r--r-- | ppapi/thunk/ppb_input_event_thunk.cc | 18 |
9 files changed, 88 insertions, 17 deletions
diff --git a/ppapi/api/dev/ppb_keyboard_input_event_dev.idl b/ppapi/api/dev/ppb_keyboard_input_event_dev.idl index 02f20b3..0612b99 100644 --- a/ppapi/api/dev/ppb_keyboard_input_event_dev.idl +++ b/ppapi/api/dev/ppb_keyboard_input_event_dev.idl @@ -10,14 +10,14 @@ */ label Chrome { - M19 = 0.1 + M31 = 0.2 }; /** * The <code>PPB_KeyboardInputEvent_Dev</code> interface is an extension to the * PPB_KeyboardInputEvent</code> interface that provides */ -[version=0.1, macro="PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE"] +[macro="PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE"] interface PPB_KeyboardInputEvent_Dev { /** * This sets a USB key code in the given <code>PP_Resource</code>. It is @@ -33,7 +33,7 @@ interface PPB_KeyboardInputEvent_Dev { * @return <code>PP_TRUE</code> if the USB key code was set successfully. */ PP_Bool SetUsbKeyCode([in] PP_Resource key_event, - [in] uint32_t usb_key_code); + [in] uint32_t usb_key_code); /** * GetUsbKeyCode() returns the USB key code associated with this keyboard @@ -47,4 +47,14 @@ interface PPB_KeyboardInputEvent_Dev { * a 0 is returned. */ uint32_t GetUsbKeyCode([in] PP_Resource key_event); + + /** + * GetCode() returns the DOM |code| field for this keyboard event, as + * defined by the UI Events spec: http://www.w3.org/TR/uievents/ + * + * @param[in] key_event The key event for which to return the key code. + * + * @return The string that contains the DOM |code| for the keyboard event. + */ + PP_Var GetCode([in] PP_Resource key_event); }; diff --git a/ppapi/c/dev/ppb_keyboard_input_event_dev.h b/ppapi/c/dev/ppb_keyboard_input_event_dev.h index c3c8fe2..a921bd9 100644 --- a/ppapi/c/dev/ppb_keyboard_input_event_dev.h +++ b/ppapi/c/dev/ppb_keyboard_input_event_dev.h @@ -4,7 +4,7 @@ */ /* From dev/ppb_keyboard_input_event_dev.idl, - * modified Tue Feb 21 08:56:59 2012. + * modified Fri Sep 6 10:00:04 2013. */ #ifndef PPAPI_C_DEV_PPB_KEYBOARD_INPUT_EVENT_DEV_H_ @@ -14,11 +14,12 @@ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" +#include "ppapi/c/pp_var.h" -#define PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_1 \ - "PPB_KeyboardInputEvent(Dev);0.1" +#define PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_2 \ + "PPB_KeyboardInputEvent(Dev);0.2" #define PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE \ - PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_1 + PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_2 /** * @file @@ -36,7 +37,7 @@ * The <code>PPB_KeyboardInputEvent_Dev</code> interface is an extension to the * PPB_KeyboardInputEvent</code> interface that provides */ -struct PPB_KeyboardInputEvent_Dev_0_1 { +struct PPB_KeyboardInputEvent_Dev_0_2 { /** * This sets a USB key code in the given <code>PP_Resource</code>. It is * intended that this method be called immediately after any call to @@ -63,9 +64,18 @@ struct PPB_KeyboardInputEvent_Dev_0_1 { * a 0 is returned. */ uint32_t (*GetUsbKeyCode)(PP_Resource key_event); + /** + * GetCode() returns the DOM |code| field for this keyboard event, as + * defined by the UI Events spec: http://www.w3.org/TR/uievents/ + * + * @param[in] key_event The key event for which to return the key code. + * + * @return The string that contains the DOM |code| for the keyboard event. + */ + struct PP_Var (*GetCode)(PP_Resource key_event); }; -typedef struct PPB_KeyboardInputEvent_Dev_0_1 PPB_KeyboardInputEvent_Dev; +typedef struct PPB_KeyboardInputEvent_Dev_0_2 PPB_KeyboardInputEvent_Dev; /** * @} */ diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index 44a86c3..7b20ec9 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -179,6 +179,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileChooser_Dev_0_6; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Font_Dev_0_6; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_2; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_KeyboardInputEvent_Dev_0_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Printing_Dev_0_7; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Testing_Dev_0_9; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Testing_Dev_0_91; @@ -1823,7 +1824,24 @@ static void Pnacl_M21_PPB_IMEInputEvent_Dev_GetSelection(PP_Resource ime_event, /* End wrapper methods for PPB_IMEInputEvent_Dev_0_2 */ -/* Not generating wrapper methods for PPB_KeyboardInputEvent_Dev_0_1 */ +/* Begin wrapper methods for PPB_KeyboardInputEvent_Dev_0_2 */ + +static PP_Bool Pnacl_M31_PPB_KeyboardInputEvent_Dev_SetUsbKeyCode(PP_Resource key_event, uint32_t usb_key_code) { + const struct PPB_KeyboardInputEvent_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_KeyboardInputEvent_Dev_0_2.real_iface; + return iface->SetUsbKeyCode(key_event, usb_key_code); +} + +static uint32_t Pnacl_M31_PPB_KeyboardInputEvent_Dev_GetUsbKeyCode(PP_Resource key_event) { + const struct PPB_KeyboardInputEvent_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_KeyboardInputEvent_Dev_0_2.real_iface; + return iface->GetUsbKeyCode(key_event); +} + +static void Pnacl_M31_PPB_KeyboardInputEvent_Dev_GetCode(struct PP_Var* _struct_result, PP_Resource key_event) { + const struct PPB_KeyboardInputEvent_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_KeyboardInputEvent_Dev_0_2.real_iface; + *_struct_result = iface->GetCode(key_event); +} + +/* End wrapper methods for PPB_KeyboardInputEvent_Dev_0_2 */ /* Not generating wrapper methods for PPB_Memory_Dev_0_1 */ @@ -4473,7 +4491,11 @@ struct PPB_IMEInputEvent_Dev_0_2 Pnacl_Wrappers_PPB_IMEInputEvent_Dev_0_2 = { .GetSelection = (void (*)(PP_Resource ime_event, uint32_t* start, uint32_t* end))&Pnacl_M21_PPB_IMEInputEvent_Dev_GetSelection }; -/* Not generating wrapper interface for PPB_KeyboardInputEvent_Dev_0_1 */ +struct PPB_KeyboardInputEvent_Dev_0_2 Pnacl_Wrappers_PPB_KeyboardInputEvent_Dev_0_2 = { + .SetUsbKeyCode = (PP_Bool (*)(PP_Resource key_event, uint32_t usb_key_code))&Pnacl_M31_PPB_KeyboardInputEvent_Dev_SetUsbKeyCode, + .GetUsbKeyCode = (uint32_t (*)(PP_Resource key_event))&Pnacl_M31_PPB_KeyboardInputEvent_Dev_GetUsbKeyCode, + .GetCode = (struct PP_Var (*)(PP_Resource key_event))&Pnacl_M31_PPB_KeyboardInputEvent_Dev_GetCode +}; /* Not generating wrapper interface for PPB_Memory_Dev_0_1 */ @@ -5341,6 +5363,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_2 = { .real_iface = NULL }; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_KeyboardInputEvent_Dev_0_2 = { + .iface_macro = PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_2, + .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_KeyboardInputEvent_Dev_0_2, + .real_iface = NULL +}; + static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Printing_Dev_0_7 = { .iface_macro = PPB_PRINTING_DEV_INTERFACE_0_7, .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_Printing_Dev_0_7, @@ -5709,6 +5737,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_Font_Dev_0_6, &Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_1, &Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_2, + &Pnacl_WrapperInfo_PPB_KeyboardInputEvent_Dev_0_2, &Pnacl_WrapperInfo_PPB_Printing_Dev_0_7, &Pnacl_WrapperInfo_PPB_Testing_Dev_0_9, &Pnacl_WrapperInfo_PPB_Testing_Dev_0_91, diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index a313db1..b970d36 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -259,6 +259,7 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::InputEventData) IPC_STRUCT_TRAITS_MEMBER(wheel_scroll_by_page) IPC_STRUCT_TRAITS_MEMBER(key_code) IPC_STRUCT_TRAITS_MEMBER(usb_key_code) + IPC_STRUCT_TRAITS_MEMBER(code) IPC_STRUCT_TRAITS_MEMBER(character_text) IPC_STRUCT_TRAITS_MEMBER(composition_segment_offsets) IPC_STRUCT_TRAITS_MEMBER(composition_target_segment) diff --git a/ppapi/shared_impl/ppb_input_event_shared.cc b/ppapi/shared_impl/ppb_input_event_shared.cc index 4cd918d..c837e5a 100644 --- a/ppapi/shared_impl/ppb_input_event_shared.cc +++ b/ppapi/shared_impl/ppb_input_event_shared.cc @@ -24,6 +24,7 @@ InputEventData::InputEventData() wheel_scroll_by_page(false), key_code(0), usb_key_code(0), + code(), character_text(), composition_target_segment(-1), composition_selection_start(0), @@ -108,6 +109,10 @@ uint32_t PPB_InputEvent_Shared::GetUsbKeyCode() { return data_.usb_key_code; } +PP_Var PPB_InputEvent_Shared::GetCode() { + return StringVar::StringToPPVar(data_.code); +} + uint32_t PPB_InputEvent_Shared::GetIMESegmentNumber() { if (data_.composition_segment_offsets.empty()) return 0; diff --git a/ppapi/shared_impl/ppb_input_event_shared.h b/ppapi/shared_impl/ppb_input_event_shared.h index f6bdea6..623d997 100644 --- a/ppapi/shared_impl/ppb_input_event_shared.h +++ b/ppapi/shared_impl/ppb_input_event_shared.h @@ -43,6 +43,10 @@ struct PPAPI_SHARED_EXPORT InputEventData { uint32_t key_code; uint32_t usb_key_code; + // The key event's |code| attribute as defined in: + // http://www.w3.org/TR/uievents/ + std::string code; + std::string character_text; std::vector<uint32_t> composition_segment_offsets; @@ -84,6 +88,7 @@ class PPAPI_SHARED_EXPORT PPB_InputEvent_Shared virtual PP_Var GetCharacterText() OVERRIDE; virtual PP_Bool SetUsbKeyCode(uint32_t usb_key_code) OVERRIDE; virtual uint32_t GetUsbKeyCode() OVERRIDE; + virtual PP_Var GetCode() OVERRIDE; virtual uint32_t GetIMESegmentNumber() OVERRIDE; virtual uint32_t GetIMESegmentOffset(uint32_t index) OVERRIDE; virtual int32_t GetIMETargetSegment() OVERRIDE; diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h index c1bc8c6..1ba0435 100644 --- a/ppapi/thunk/interfaces_ppb_public_dev.h +++ b/ppapi/thunk/interfaces_ppb_public_dev.h @@ -25,8 +25,8 @@ PROXIED_IFACE(NoAPIName, PPB_FILECHOOSER_DEV_INTERFACE_0_6, UNPROXIED_IFACE(PPB_Find, PPB_FIND_DEV_INTERFACE_0_3, PPB_Find_Dev_0_3) PROXIED_IFACE(NoAPIName, PPB_IME_INPUT_EVENT_DEV_INTERFACE_0_2, PPB_IMEInputEvent_Dev_0_2) -PROXIED_IFACE(NoAPIName, PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_1, - PPB_KeyboardInputEvent_Dev_0_1) +PROXIED_IFACE(NoAPIName, PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_2, + PPB_KeyboardInputEvent_Dev_0_2) PROXIED_IFACE(NoAPIName, PPB_MEMORY_DEV_INTERFACE_0_1, PPB_Memory_Dev_0_1) PROXIED_IFACE(NoAPIName, PPB_PRINTING_DEV_INTERFACE_0_7, PPB_Printing_Dev_0_7) diff --git a/ppapi/thunk/ppb_input_event_api.h b/ppapi/thunk/ppb_input_event_api.h index 18bda79..e2eb357 100644 --- a/ppapi/thunk/ppb_input_event_api.h +++ b/ppapi/thunk/ppb_input_event_api.h @@ -38,6 +38,7 @@ class PPAPI_THUNK_EXPORT PPB_InputEvent_API { virtual PP_Var GetCharacterText() = 0; virtual PP_Bool SetUsbKeyCode(uint32_t) = 0; virtual uint32_t GetUsbKeyCode() = 0; + virtual PP_Var GetCode() = 0; virtual uint32_t GetIMESegmentNumber() = 0; virtual uint32_t GetIMESegmentOffset(uint32_t index) = 0; virtual int32_t GetIMETargetSegment() = 0; diff --git a/ppapi/thunk/ppb_input_event_thunk.cc b/ppapi/thunk/ppb_input_event_thunk.cc index f54eefa..5a0927d 100644 --- a/ppapi/thunk/ppb_input_event_thunk.cc +++ b/ppapi/thunk/ppb_input_event_thunk.cc @@ -311,9 +311,19 @@ uint32_t GetUsbKeyCode(PP_Resource key_event) { return enter.object()->GetUsbKeyCode(); } -const PPB_KeyboardInputEvent_Dev g_ppb_keyboard_input_event_dev_thunk = { +PP_Var GetCode(PP_Resource key_event) { + VLOG(4) << "PPB_KeyboardInputEvent_Dev::GetCode()"; + EnterInputEvent enter(key_event, true); + if (enter.failed()) + return PP_MakeUndefined(); + return enter.object()->GetCode(); +} + +const PPB_KeyboardInputEvent_Dev_0_2 + g_ppb_keyboard_input_event_dev_0_2_thunk = { &SetUsbKeyCode, &GetUsbKeyCode, + &GetCode, }; // Composition ----------------------------------------------------------------- @@ -511,9 +521,9 @@ const PPB_KeyboardInputEvent_1_0* GetPPB_KeyboardInputEvent_1_0_Thunk() { return &g_ppb_keyboard_input_event_thunk; } -const PPB_KeyboardInputEvent_Dev_0_1* - GetPPB_KeyboardInputEvent_Dev_0_1_Thunk() { - return &g_ppb_keyboard_input_event_dev_thunk; +const PPB_KeyboardInputEvent_Dev_0_2* + GetPPB_KeyboardInputEvent_Dev_0_2_Thunk() { + return &g_ppb_keyboard_input_event_dev_0_2_thunk; } const PPB_WheelInputEvent_1_0* GetPPB_WheelInputEvent_1_0_Thunk() { |