diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-27 08:22:03 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-27 08:22:03 +0000 |
commit | a5bd413ae6ca86fce6922fcd19c111eaeb7232f4 (patch) | |
tree | 53e953e110155169b190daff3ca8721661ae9516 /ppapi/proxy | |
parent | bec2695b1a4faad59f6c71d777032af5f04042bc (diff) | |
download | chromium_src-a5bd413ae6ca86fce6922fcd19c111eaeb7232f4.zip chromium_src-a5bd413ae6ca86fce6922fcd19c111eaeb7232f4.tar.gz chromium_src-a5bd413ae6ca86fce6922fcd19c111eaeb7232f4.tar.bz2 |
Additional update on Pepper IME API and boilerplate thunk/proxy implementation.
BUG=59425
TEST=Check that ppapi_tests compile.
This CL is the second (out of three) part for adding IME support for PPAPI.
It reflects comments from James Su to the previous CL:
http://codereview.chromium.org/7882004.
- Renamed ..._COMPOSTION_START to _IME_COMPOSITON_START.
- Changed to assure GetSegment to return a strictly increasing sequence of
segmentation points from 0 to the length.
and,
- Added the mostly boilerplate code for interfacing with
in-process & out-of-process plugins.
The actual implementation of the IME support will come as
the next and the last part of this series of patches.
Review URL: http://codereview.chromium.org/7978019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102897 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r-- | ppapi/proxy/interface_id.h | 1 | ||||
-rw-r--r-- | ppapi/proxy/interface_list.cc | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 17 | ||||
-rw-r--r-- | ppapi/proxy/ppb_text_input_proxy.cc | 84 | ||||
-rw-r--r-- | ppapi/proxy/ppb_text_input_proxy.h | 56 |
5 files changed, 161 insertions, 0 deletions
diff --git a/ppapi/proxy/interface_id.h b/ppapi/proxy/interface_id.h index c18a02e..7f45bfa 100644 --- a/ppapi/proxy/interface_id.h +++ b/ppapi/proxy/interface_id.h @@ -42,6 +42,7 @@ enum InterfaceID { INTERFACE_ID_PPB_PDF, INTERFACE_ID_PPB_SURFACE_3D, INTERFACE_ID_PPB_TESTING, + INTERFACE_ID_PPB_TEXT_INPUT, INTERFACE_ID_PPB_URL_LOADER, INTERFACE_ID_PPB_URL_RESPONSE_INFO, INTERFACE_ID_PPB_URL_UTIL, diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index 3ae9529..2511f3b 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -14,10 +14,12 @@ #include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" #include "ppapi/c/dev/ppb_font_dev.h" #include "ppapi/c/dev/ppb_fullscreen_dev.h" +#include "ppapi/c/dev/ppb_ime_input_event_dev.h" #include "ppapi/c/dev/ppb_memory_dev.h" #include "ppapi/c/dev/ppb_mouse_lock_dev.h" #include "ppapi/c/dev/ppb_surface_3d_dev.h" #include "ppapi/c/dev/ppb_testing_dev.h" +#include "ppapi/c/dev/ppb_text_input_dev.h" #include "ppapi/c/dev/ppb_url_util_dev.h" #include "ppapi/c/dev/ppb_var_deprecated.h" #include "ppapi/c/dev/ppb_video_capture_dev.h" @@ -78,6 +80,7 @@ #include "ppapi/proxy/ppb_pdf_proxy.h" #include "ppapi/proxy/ppb_surface_3d_proxy.h" #include "ppapi/proxy/ppb_testing_proxy.h" +#include "ppapi/proxy/ppb_text_input_proxy.h" #include "ppapi/proxy/ppb_url_loader_proxy.h" #include "ppapi/proxy/ppb_url_response_info_proxy.h" #include "ppapi/proxy/ppb_url_util_proxy.h" diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index bbdb34e..96280c4 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -19,6 +19,7 @@ #include "ipc/ipc_message_utils.h" #include "ipc/ipc_platform_file.h" #include "ppapi/c/dev/pp_video_capture_dev.h" +#include "ppapi/c/dev/ppb_text_input_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_file_info.h" #include "ppapi/c/pp_instance.h" @@ -44,6 +45,7 @@ IPC_ENUM_TRAITS(PP_InputEvent_Type) IPC_ENUM_TRAITS(PP_InputEvent_MouseButton) +IPC_ENUM_TRAITS(PP_TextInput_Type) IPC_ENUM_TRAITS(PP_VideoDecoder_Profile) IPC_ENUM_TRAITS(PP_VideoDecodeError_Dev) @@ -113,6 +115,10 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::InputEventData) IPC_STRUCT_TRAITS_MEMBER(wheel_scroll_by_page) IPC_STRUCT_TRAITS_MEMBER(key_code) IPC_STRUCT_TRAITS_MEMBER(character_text) + IPC_STRUCT_TRAITS_MEMBER(composition_segment_offsets) + IPC_STRUCT_TRAITS_MEMBER(composition_target_segment) + IPC_STRUCT_TRAITS_MEMBER(composition_selection_start) + IPC_STRUCT_TRAITS_MEMBER(composition_selection_end) IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(ppapi::PPB_URLRequestInfo_Data) @@ -922,6 +928,17 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance, PP_Instance /* instance */, uint32 /* result */) +// PPB_TextInput. +IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBTextInput_SetTextInputType, + PP_Instance /* instance */, + PP_TextInput_Type /* type */) +IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBTextInput_UpdateCaretPosition, + PP_Instance /* instance */, + PP_Rect /* caret */, + PP_Rect /* bounding_box */) +IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBTextInput_CancelCompositionText, + PP_Instance /* instance */) + // PPB_URLLoader. IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBURLLoader_Create, PP_Instance /* instance */, diff --git a/ppapi/proxy/ppb_text_input_proxy.cc b/ppapi/proxy/ppb_text_input_proxy.cc new file mode 100644 index 0000000..e4ada9b --- /dev/null +++ b/ppapi/proxy/ppb_text_input_proxy.cc @@ -0,0 +1,84 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/proxy/ppb_text_input_proxy.h" + +#include "ppapi/proxy/plugin_dispatcher.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/thunk.h" + +namespace ppapi { +namespace proxy { + +PPB_TextInput_Proxy::PPB_TextInput_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { +} + +PPB_TextInput_Proxy::~PPB_TextInput_Proxy() { +} + +ppapi::thunk::PPB_TextInput_FunctionAPI* +PPB_TextInput_Proxy::AsPPB_TextInput_FunctionAPI() { + return this; +} + +void PPB_TextInput_Proxy::SetTextInputType(PP_Instance instance, + PP_TextInput_Type type) { + dispatcher()->Send(new PpapiHostMsg_PPBTextInput_SetTextInputType( + INTERFACE_ID_PPB_TEXT_INPUT, instance, type)); +} + +void PPB_TextInput_Proxy::UpdateCaretPosition(PP_Instance instance, + const PP_Rect& caret, + const PP_Rect& bounding_box) { + dispatcher()->Send(new PpapiHostMsg_PPBTextInput_UpdateCaretPosition( + INTERFACE_ID_PPB_TEXT_INPUT, instance, caret, bounding_box)); +} + +void PPB_TextInput_Proxy::CancelCompositionText(PP_Instance instance) { + dispatcher()->Send(new PpapiHostMsg_PPBTextInput_CancelCompositionText( + INTERFACE_ID_PPB_TEXT_INPUT, instance)); +} + +bool PPB_TextInput_Proxy::OnMessageReceived(const IPC::Message& msg) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(PPB_TextInput_Proxy, msg) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTextInput_SetTextInputType, + OnMsgSetTextInputType) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTextInput_UpdateCaretPosition, + OnMsgUpdateCaretPosition) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTextInput_CancelCompositionText, + OnMsgCancelCompositionText) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void PPB_TextInput_Proxy::OnMsgSetTextInputType(PP_Instance instance, + PP_TextInput_Type type) { + ppapi::thunk::EnterFunctionNoLock<PPB_TextInput_FunctionAPI> enter(instance, + true); + if (enter.succeeded()) + enter.functions()->SetTextInputType(instance, type); +} + +void PPB_TextInput_Proxy::OnMsgUpdateCaretPosition(PP_Instance instance, + PP_Rect caret, + PP_Rect bounding_box) { + ppapi::thunk::EnterFunctionNoLock<PPB_TextInput_FunctionAPI> enter(instance, + true); + if (enter.succeeded()) + enter.functions()->UpdateCaretPosition(instance, caret, bounding_box); +} + +void PPB_TextInput_Proxy::OnMsgCancelCompositionText(PP_Instance instance) { + ppapi::thunk::EnterFunctionNoLock<PPB_TextInput_FunctionAPI> enter(instance, + true); + if (enter.succeeded()) + enter.functions()->CancelCompositionText(instance); +} + +} // namespace proxy +} // namespace ppapi diff --git a/ppapi/proxy/ppb_text_input_proxy.h b/ppapi/proxy/ppb_text_input_proxy.h new file mode 100644 index 0000000..e234f33 --- /dev/null +++ b/ppapi/proxy/ppb_text_input_proxy.h @@ -0,0 +1,56 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_PPB_TEXT_INPUT_PROXY_H_ +#define PPAPI_PPB_TEXT_INPUT_PROXY_H_ + +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_rect.h" +#include "ppapi/proxy/interface_proxy.h" +#include "ppapi/thunk/ppb_text_input_api.h" + +struct PPB_TextInput_Dev; + +namespace ppapi { +namespace proxy { + +class PPB_TextInput_Proxy + : public InterfaceProxy, + public ppapi::thunk::PPB_TextInput_FunctionAPI { + public: + PPB_TextInput_Proxy(Dispatcher* dispatcher); + virtual ~PPB_TextInput_Proxy(); + + // FunctionGroupBase overrides. + ppapi::thunk::PPB_TextInput_FunctionAPI* AsPPB_TextInput_FunctionAPI() + OVERRIDE; + + // PPB_TextInput_FunctionAPI implementation. + virtual void SetTextInputType(PP_Instance instance, + PP_TextInput_Type type) OVERRIDE; + virtual void UpdateCaretPosition(PP_Instance instance, + const PP_Rect& caret, + const PP_Rect& bounding_box) OVERRIDE; + virtual void CancelCompositionText(PP_Instance instance) OVERRIDE; + + // InterfaceProxy implementation. + virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; + + static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_TEXT_INPUT; + + private: + // Message handlers. + void OnMsgSetTextInputType(PP_Instance instance, PP_TextInput_Type type); + void OnMsgUpdateCaretPosition(PP_Instance instance, + PP_Rect caret, + PP_Rect bounding_box); + void OnMsgCancelCompositionText(PP_Instance instance); + + DISALLOW_COPY_AND_ASSIGN(PPB_TextInput_Proxy); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PPB_TEXT_INPUT_PROXY_H_ |