diff options
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/ppapi_proxy.gypi | 2 | ||||
-rw-r--r-- | ppapi/proxy/interface_list.cc | 1 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 10 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.cc | 145 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.h | 21 | ||||
-rw-r--r-- | ppapi/proxy/ppb_text_input_proxy.cc | 141 | ||||
-rw-r--r-- | ppapi/proxy/ppb_text_input_proxy.h | 65 | ||||
-rw-r--r-- | ppapi/shared_impl/function_group_base.h | 5 | ||||
-rw-r--r-- | ppapi/thunk/interfaces_ppb_public_dev.h | 5 | ||||
-rw-r--r-- | ppapi/thunk/ppb_instance_api.h | 14 | ||||
-rw-r--r-- | ppapi/thunk/ppb_text_input_api.h | 36 | ||||
-rw-r--r-- | ppapi/thunk/ppb_text_input_thunk.cc | 12 |
12 files changed, 168 insertions, 289 deletions
diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index 63132d0..d8d5728 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -120,8 +120,6 @@ 'proxy/ppb_tcp_socket_private_proxy.h', 'proxy/ppb_testing_proxy.cc', 'proxy/ppb_testing_proxy.h', - 'proxy/ppb_text_input_proxy.cc', - 'proxy/ppb_text_input_proxy.h', 'proxy/ppb_udp_socket_private_proxy.cc', 'proxy/ppb_udp_socket_private_proxy.h', 'proxy/ppb_url_loader_proxy.cc', diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index 4a92812..530ff26 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -95,7 +95,6 @@ #include "ppapi/proxy/ppb_tcp_server_socket_private_proxy.h" #include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" #include "ppapi/proxy/ppb_testing_proxy.h" -#include "ppapi/proxy/ppb_text_input_proxy.h" #include "ppapi/proxy/ppb_udp_socket_private_proxy.h" #include "ppapi/proxy/ppb_url_loader_proxy.h" #include "ppapi/proxy/ppb_url_response_info_proxy.h" diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 307574a..412aec0 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -899,18 +899,16 @@ IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_SetCursor, int32_t /* type */, ppapi::HostResource /* custom_image */, PP_Point /* hot_spot */) - -// PPB_TextInput. -IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBTextInput_SetTextInputType, +IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBInstance_SetTextInputType, PP_Instance /* instance */, PP_TextInput_Type /* type */) -IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBTextInput_UpdateCaretPosition, +IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_UpdateCaretPosition, PP_Instance /* instance */, PP_Rect /* caret */, PP_Rect /* bounding_box */) -IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBTextInput_CancelCompositionText, +IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBInstance_CancelCompositionText, PP_Instance /* instance */) -IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBTextInput_UpdateSurroundingText, +IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_UpdateSurroundingText, PP_Instance /* instance */, std::string /* text */, uint32_t /* caret */, diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index 9873321..293ebf0 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -30,7 +30,7 @@ #undef PostMessage #endif -using ppapi::thunk::EnterFunctionNoLock; +using ppapi::thunk::EnterInstanceNoLock; using ppapi::thunk::EnterResourceNoLock; using ppapi::thunk::PPB_Instance_FunctionAPI; @@ -39,12 +39,25 @@ namespace proxy { namespace { -typedef EnterFunctionNoLock<PPB_Instance_FunctionAPI> EnterInstanceNoLock; - InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) { return new PPB_Instance_Proxy(dispatcher); } +void RequestSurroundingText(PP_Instance instance) { + PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); + if (!dispatcher) + return; // Instance has gone away while message was pending. + + // Just fake out a RequestSurroundingText message to the proxy for the PPP + // interface. + InterfaceProxy* proxy = dispatcher->GetInterfaceProxy(API_ID_PPB_TEXT_INPUT); + if (!proxy) + return; + proxy->OnMessageReceived(PpapiMsg_PPPTextInput_RequestSurroundingText( + API_ID_PPP_TEXT_INPUT, instance, + PPB_Instance_Shared::kExtraCharsForTextInput)); +} + } // namespace PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher) @@ -113,6 +126,14 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { OnHostMsgUnlockMouse) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor, OnHostMsgSetCursor) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType, + OnHostMsgSetTextInputType) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateCaretPosition, + OnHostMsgUpdateCaretPosition) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_CancelCompositionText, + OnHostMsgCancelCompositionText) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateSurroundingText, + OnHostMsgUpdateSurroundingText) #if !defined(OS_NACL) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument, OnHostMsgResolveRelativeToDocument) @@ -441,10 +462,52 @@ void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) { API_ID_PPB_INSTANCE, instance)); } +void PPB_Instance_Proxy::SetTextInputType(PP_Instance instance, + PP_TextInput_Type type) { + dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetTextInputType( + API_ID_PPB_INSTANCE, instance, type)); +} + +void PPB_Instance_Proxy::UpdateCaretPosition(PP_Instance instance, + const PP_Rect& caret, + const PP_Rect& bounding_box) { + dispatcher()->Send(new PpapiHostMsg_PPBInstance_UpdateCaretPosition( + API_ID_PPB_INSTANCE, instance, caret, bounding_box)); +} + +void PPB_Instance_Proxy::CancelCompositionText(PP_Instance instance) { + dispatcher()->Send(new PpapiHostMsg_PPBInstance_CancelCompositionText( + API_ID_PPB_INSTANCE, instance)); +} + +void PPB_Instance_Proxy::SelectionChanged(PP_Instance instance) { + // The "right" way to do this is to send the message to the host. However, + // all it will do it call RequestSurroundingText with a hardcoded number of + // characters in response, which is an entire IPC round-trip. + // + // We can avoid this round-trip by just implementing the + // RequestSurroundingText logic in the plugin process. If the logic in the + // host becomes more complex (like a more adaptive number of characters), + // we'll need to reevanuate whether we want to do the round trip instead. + // + // Be careful to post a task to avoid reentering the plugin. + MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&RequestSurroundingText, instance)); +} + +void PPB_Instance_Proxy::UpdateSurroundingText(PP_Instance instance, + const char* text, + uint32_t caret, + uint32_t anchor) { + dispatcher()->Send(new PpapiHostMsg_PPBInstance_UpdateSurroundingText( + API_ID_PPB_INSTANCE, instance, text, caret, anchor)); +} + void PPB_Instance_Proxy::OnHostMsgGetWindowObject( PP_Instance instance, SerializedVarReturnValue result) { - EnterInstanceNoLock enter(instance, false); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) result.Return(dispatcher(), enter.functions()->GetWindowObject(instance)); } @@ -452,7 +515,7 @@ void PPB_Instance_Proxy::OnHostMsgGetWindowObject( void PPB_Instance_Proxy::OnHostMsgGetOwnerElementObject( PP_Instance instance, SerializedVarReturnValue result) { - EnterInstanceNoLock enter(instance, false); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) { result.Return(dispatcher(), enter.functions()->GetOwnerElementObject(instance)); @@ -462,7 +525,7 @@ void PPB_Instance_Proxy::OnHostMsgGetOwnerElementObject( void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance, const HostResource& device, PP_Bool* result) { - EnterInstanceNoLock enter(instance, false); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) { *result = enter.functions()->BindGraphics(instance, device.host_resource()); @@ -471,21 +534,21 @@ void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance, void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputSampleRate( PP_Instance instance, uint32_t* result) { - EnterInstanceNoLock enter(instance, false); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) *result = enter.functions()->GetAudioHardwareOutputSampleRate(instance); } void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputBufferSize( PP_Instance instance, uint32_t* result) { - EnterInstanceNoLock enter(instance, false); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) *result = enter.functions()->GetAudioHardwareOutputBufferSize(instance); } void PPB_Instance_Proxy::OnHostMsgIsFullFrame(PP_Instance instance, PP_Bool* result) { - EnterInstanceNoLock enter(instance, false); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) *result = enter.functions()->IsFullFrame(instance); } @@ -495,7 +558,7 @@ void PPB_Instance_Proxy::OnHostMsgExecuteScript( SerializedVarReceiveInput script, SerializedVarOutParam out_exception, SerializedVarReturnValue result) { - EnterInstanceNoLock enter(instance, false); + EnterInstanceNoLock enter(instance); if (enter.failed()) return; @@ -513,7 +576,7 @@ void PPB_Instance_Proxy::OnHostMsgExecuteScript( void PPB_Instance_Proxy::OnHostMsgGetDefaultCharSet( PP_Instance instance, SerializedVarReturnValue result) { - EnterInstanceNoLock enter(instance, false); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) result.Return(dispatcher(), enter.functions()->GetDefaultCharSet(instance)); } @@ -521,7 +584,7 @@ void PPB_Instance_Proxy::OnHostMsgGetDefaultCharSet( void PPB_Instance_Proxy::OnHostMsgSetFullscreen(PP_Instance instance, PP_Bool fullscreen, PP_Bool* result) { - EnterInstanceNoLock enter(instance, false); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) *result = enter.functions()->SetFullscreen(instance, fullscreen); } @@ -530,7 +593,7 @@ void PPB_Instance_Proxy::OnHostMsgSetFullscreen(PP_Instance instance, void PPB_Instance_Proxy::OnHostMsgGetScreenSize(PP_Instance instance, PP_Bool* result, PP_Size* size) { - EnterInstanceNoLock enter(instance, false); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) *result = enter.functions()->GetScreenSize(instance, size); } @@ -538,7 +601,7 @@ void PPB_Instance_Proxy::OnHostMsgGetScreenSize(PP_Instance instance, void PPB_Instance_Proxy::OnHostMsgRequestInputEvents(PP_Instance instance, bool is_filtering, uint32_t event_classes) { - EnterInstanceNoLock enter(instance, false); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) { if (is_filtering) enter.functions()->RequestFilteringInputEvents(instance, event_classes); @@ -549,14 +612,14 @@ void PPB_Instance_Proxy::OnHostMsgRequestInputEvents(PP_Instance instance, void PPB_Instance_Proxy::OnHostMsgClearInputEvents(PP_Instance instance, uint32_t event_classes) { - EnterInstanceNoLock enter(instance, false); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) enter.functions()->ClearInputEventRequest(instance, event_classes); } void PPB_Instance_Proxy::OnMsgHandleInputEventAck(PP_Instance instance, PP_TimeTicks timestamp) { - EnterInstanceNoLock enter(instance, false); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) enter.functions()->ClosePendingUserGesture(instance, timestamp); } @@ -564,7 +627,7 @@ void PPB_Instance_Proxy::OnMsgHandleInputEventAck(PP_Instance instance, void PPB_Instance_Proxy::OnHostMsgPostMessage( PP_Instance instance, SerializedVarReceiveInput message) { - EnterInstanceNoLock enter(instance, false); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) enter.functions()->PostMessage(instance, message.Get(dispatcher())); } @@ -580,7 +643,7 @@ void PPB_Instance_Proxy::OnHostMsgLockMouse(PP_Instance instance) { } void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) enter.functions()->UnlockMouse(instance); } @@ -590,7 +653,7 @@ void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument( PP_Instance instance, SerializedVarReceiveInput relative, SerializedVarReturnValue result) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) { result.Return(dispatcher(), enter.functions()->ResolveRelativeToDocument( @@ -602,7 +665,7 @@ void PPB_Instance_Proxy::OnHostMsgDocumentCanRequest( PP_Instance instance, SerializedVarReceiveInput url, PP_Bool* result) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) { *result = enter.functions()->DocumentCanRequest(instance, url.Get(dispatcher())); @@ -612,14 +675,14 @@ void PPB_Instance_Proxy::OnHostMsgDocumentCanRequest( void PPB_Instance_Proxy::OnHostMsgDocumentCanAccessDocument(PP_Instance active, PP_Instance target, PP_Bool* result) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(active, true); + EnterInstanceNoLock enter(active); if (enter.succeeded()) *result = enter.functions()->DocumentCanAccessDocument(active, target); } void PPB_Instance_Proxy::OnHostMsgGetDocumentURL(PP_Instance instance, SerializedVarReturnValue result) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) { result.Return(dispatcher(), enter.functions()->GetDocumentURL(instance, NULL)); @@ -629,7 +692,7 @@ void PPB_Instance_Proxy::OnHostMsgGetDocumentURL(PP_Instance instance, void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL( PP_Instance instance, SerializedVarReturnValue result) { - EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) { result.Return(dispatcher(), enter.functions()->GetPluginInstanceURL(instance, NULL)); @@ -642,7 +705,7 @@ void PPB_Instance_Proxy::OnHostMsgSetCursor( int32_t type, const ppapi::HostResource& custom_image, const PP_Point& hot_spot) { - EnterInstanceNoLock enter(instance, true); + EnterInstanceNoLock enter(instance); if (enter.succeeded()) { enter.functions()->SetCursor( instance, static_cast<PP_MouseCursor_Type>(type), @@ -650,6 +713,40 @@ void PPB_Instance_Proxy::OnHostMsgSetCursor( } } +void PPB_Instance_Proxy::OnHostMsgSetTextInputType(PP_Instance instance, + PP_TextInput_Type type) { + EnterInstanceNoLock enter(instance); + if (enter.succeeded()) + enter.functions()->SetTextInputType(instance, type); +} + +void PPB_Instance_Proxy::OnHostMsgUpdateCaretPosition( + PP_Instance instance, + const PP_Rect& caret, + const PP_Rect& bounding_box) { + EnterInstanceNoLock enter(instance); + if (enter.succeeded()) + enter.functions()->UpdateCaretPosition(instance, caret, bounding_box); +} + +void PPB_Instance_Proxy::OnHostMsgCancelCompositionText(PP_Instance instance) { + EnterInstanceNoLock enter(instance); + if (enter.succeeded()) + enter.functions()->CancelCompositionText(instance); +} + +void PPB_Instance_Proxy::OnHostMsgUpdateSurroundingText( + PP_Instance instance, + const std::string& text, + uint32_t caret, + uint32_t anchor) { + EnterInstanceNoLock enter(instance); + if (enter.succeeded()) { + enter.functions()->UpdateSurroundingText(instance, text.c_str(), caret, + anchor); + } +} + void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, int32_t result) { // Save the mouse callback on the instance data. diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h index d408af7..3c8ae49 100644 --- a/ppapi/proxy/ppb_instance_proxy.h +++ b/ppapi/proxy/ppb_instance_proxy.h @@ -91,6 +91,17 @@ class PPB_Instance_Proxy : public InterfaceProxy, virtual int32_t LockMouse(PP_Instance instance, PP_CompletionCallback callback) OVERRIDE; virtual void UnlockMouse(PP_Instance instance) OVERRIDE; + 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; + virtual void SelectionChanged(PP_Instance instance) OVERRIDE; + virtual void UpdateSurroundingText(PP_Instance instance, + const char* text, + uint32_t caret, + uint32_t anchor) OVERRIDE; #if !defined(OS_NACL) virtual PP_Var ResolveRelativeToDocument( @@ -150,6 +161,16 @@ class PPB_Instance_Proxy : public InterfaceProxy, int32_t type, const ppapi::HostResource& custom_image, const PP_Point& hot_spot); + void OnHostMsgSetTextInputType(PP_Instance instance, PP_TextInput_Type type); + void OnHostMsgUpdateCaretPosition(PP_Instance instance, + const PP_Rect& caret, + const PP_Rect& bounding_box); + void OnHostMsgCancelCompositionText(PP_Instance instance); + void OnHostMsgUpdateSurroundingText( + PP_Instance instance, + const std::string& text, + uint32_t caret, + uint32_t anchor); #if !defined(OS_NACL) void OnHostMsgResolveRelativeToDocument(PP_Instance instance, SerializedVarReceiveInput relative, diff --git a/ppapi/proxy/ppb_text_input_proxy.cc b/ppapi/proxy/ppb_text_input_proxy.cc deleted file mode 100644 index 3d2f873..0000000 --- a/ppapi/proxy/ppb_text_input_proxy.cc +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) 2012 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/shared_impl/ppb_instance_shared.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/thunk.h" - -namespace ppapi { -namespace proxy { - -namespace { - -void RequestSurroundingText(PP_Instance instance) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return; // Instance has gone away while message was pending. - - // Just fake out a RequestSurroundingText message to the proxy for the PPP - // interface. - InterfaceProxy* proxy = dispatcher->GetInterfaceProxy(API_ID_PPB_TEXT_INPUT); - if (!proxy) - return; - proxy->OnMessageReceived(PpapiMsg_PPPTextInput_RequestSurroundingText( - API_ID_PPP_TEXT_INPUT, instance, - PPB_Instance_Shared::kExtraCharsForTextInput)); -} - -} // namespace - -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( - API_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( - API_ID_PPB_TEXT_INPUT, instance, caret, bounding_box)); -} - -void PPB_TextInput_Proxy::CancelCompositionText(PP_Instance instance) { - dispatcher()->Send(new PpapiHostMsg_PPBTextInput_CancelCompositionText( - API_ID_PPB_TEXT_INPUT, instance)); -} - -void PPB_TextInput_Proxy::SelectionChanged(PP_Instance instance) { - // The "right" way to do this is to send the message to the host. However, - // all it will do it call RequestSurroundingText with a hardcoded number of - // characters in response, which is an entire IPC round-trip. - // - // We can avoid this round-trip by just implementing the - // RequestSurroundingText logic in the plugin process. If the logic in the - // host becomes more complex (like a more adaptive number of characters), - // we'll need to reevanuate whether we want to do the round trip instead. - // - // Be careful to post a task to avoid reentering the plugin. - MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&RequestSurroundingText, instance)); -} - -void PPB_TextInput_Proxy::UpdateSurroundingText(PP_Instance instance, - const char* text, - uint32_t caret, - uint32_t anchor) { - dispatcher()->Send(new PpapiHostMsg_PPBTextInput_UpdateSurroundingText( - API_ID_PPB_TEXT_INPUT, instance, text, caret, anchor)); -} - -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_HANDLER(PpapiHostMsg_PPBTextInput_UpdateSurroundingText, - OnMsgUpdateSurroundingText) - 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); -} - -void PPB_TextInput_Proxy::OnMsgUpdateSurroundingText(PP_Instance instance, - const std::string& text, - uint32_t caret, - uint32_t anchor) { - ppapi::thunk::EnterFunctionNoLock<PPB_TextInput_FunctionAPI> enter(instance, - true); - if (enter.succeeded()) - enter.functions()->UpdateSurroundingText(instance, - text.c_str(), caret, anchor); -} - -} // namespace proxy -} // namespace ppapi diff --git a/ppapi/proxy/ppb_text_input_proxy.h b/ppapi/proxy/ppb_text_input_proxy.h deleted file mode 100644 index 066ac5b..0000000 --- a/ppapi/proxy/ppb_text_input_proxy.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2012 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_PROXY_PPB_TEXT_INPUT_PROXY_H_ -#define PPAPI_PROXY_PPB_TEXT_INPUT_PROXY_H_ - -#include <string> - -#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" - -namespace ppapi { -namespace proxy { - -class PPB_TextInput_Proxy - : public InterfaceProxy, - public ppapi::thunk::PPB_TextInput_FunctionAPI { - public: - explicit 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; - virtual void SelectionChanged(PP_Instance instance) OVERRIDE; - virtual void UpdateSurroundingText(PP_Instance instance, - const char* text, - uint32_t caret, - uint32_t anchor) OVERRIDE; - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; - - static const ApiID kApiID = API_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); - void OnMsgUpdateSurroundingText(PP_Instance instance, - const std::string& text, - uint32_t caret, - uint32_t anchor); - - DISALLOW_COPY_AND_ASSIGN(PPB_TextInput_Proxy); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_PPB_TEXT_INPUT_PROXY_H_ diff --git a/ppapi/shared_impl/function_group_base.h b/ppapi/shared_impl/function_group_base.h index e09b893..ce42a38 100644 --- a/ppapi/shared_impl/function_group_base.h +++ b/ppapi/shared_impl/function_group_base.h @@ -10,12 +10,7 @@ #include "ppapi/shared_impl/ppapi_shared_export.h" #define FOR_ALL_PPAPI_FUNCTION_APIS(F) \ - F(PPB_CharSet_FunctionAPI) \ - F(PPB_CursorControl_FunctionAPI) \ - F(PPB_Font_FunctionAPI) \ - F(PPB_Fullscreen_FunctionAPI) \ F(PPB_Instance_FunctionAPI) \ - F(PPB_TextInput_FunctionAPI) \ F(ResourceCreationAPI) namespace ppapi { diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h index 73006ce..3b79fe4 100644 --- a/ppapi/thunk/interfaces_ppb_public_dev.h +++ b/ppapi/thunk/interfaces_ppb_public_dev.h @@ -14,7 +14,6 @@ PROXIED_API(PPB_FileChooser) PROXIED_API(PPB_Graphics3D) UNPROXIED_API(PPB_LayerCompositor) UNPROXIED_API(PPB_Scrollbar) -PROXIED_API(PPB_TextInput) UNPROXIED_API(PPB_Transport) PROXIED_API(PPB_VideoCapture) PROXIED_API(PPB_VideoDecoder) @@ -55,9 +54,9 @@ PROXIED_IFACE(NoAPIName, PPB_RESOURCEARRAY_DEV_INTERFACE_0_1, PPB_ResourceArray_Dev_0_1) UNPROXIED_IFACE(PPB_Scrollbar, PPB_SCROLLBAR_DEV_INTERFACE_0_5, PPB_Scrollbar_Dev_0_5) -PROXIED_IFACE(PPB_TextInput, PPB_TEXTINPUT_DEV_INTERFACE_0_1, +PROXIED_IFACE(PPB_Instance, PPB_TEXTINPUT_DEV_INTERFACE_0_1, PPB_TextInput_Dev_0_1) -PROXIED_IFACE(PPB_TextInput, PPB_TEXTINPUT_DEV_INTERFACE_0_2, +PROXIED_IFACE(PPB_Instance, PPB_TEXTINPUT_DEV_INTERFACE_0_2, PPB_TextInput_Dev_0_2) UNPROXIED_IFACE(PPB_Transport, PPB_TRANSPORT_DEV_INTERFACE_0_7, PPB_Transport_Dev_0_7) diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h index 05ebe8b..6a51648 100644 --- a/ppapi/thunk/ppb_instance_api.h +++ b/ppapi/thunk/ppb_instance_api.h @@ -6,6 +6,7 @@ #define PPAPI_THUNK_INSTANCE_API_H_ #include "ppapi/c/dev/ppb_console_dev.h" +#include "ppapi/c/dev/ppb_text_input_dev.h" #include "ppapi/c/dev/ppb_url_util_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" @@ -110,6 +111,19 @@ class PPB_Instance_FunctionAPI { PP_CompletionCallback callback) = 0; virtual void UnlockMouse(PP_Instance instance) = 0; + // TextInput. + virtual void SetTextInputType(PP_Instance instance, + PP_TextInput_Type type) = 0; + virtual void UpdateCaretPosition(PP_Instance instance, + const PP_Rect& caret, + const PP_Rect& bounding_box) = 0; + virtual void CancelCompositionText(PP_Instance instance) = 0; + virtual void SelectionChanged(PP_Instance instance) = 0; + virtual void UpdateSurroundingText(PP_Instance instance, + const char* text, + uint32_t caret, + uint32_t anchor) = 0; + // Zoom. virtual void ZoomChanged(PP_Instance instance, double factor) = 0; virtual void ZoomLimitsChanged(PP_Instance instance, diff --git a/ppapi/thunk/ppb_text_input_api.h b/ppapi/thunk/ppb_text_input_api.h deleted file mode 100644 index 65589a0..0000000 --- a/ppapi/thunk/ppb_text_input_api.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2012 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_THUNK_PPB_TEXT_INPUT_API_H_ -#define PPAPI_THUNK_PPB_TEXT_INPUT_API_H_ - -#include "ppapi/c/dev/ppb_text_input_dev.h" -#include "ppapi/shared_impl/api_id.h" - -namespace ppapi { -namespace thunk { - -class PPB_TextInput_FunctionAPI { - public: - virtual ~PPB_TextInput_FunctionAPI() {} - - virtual void SetTextInputType(PP_Instance instance, - PP_TextInput_Type type) = 0; - virtual void UpdateCaretPosition(PP_Instance instance, - const PP_Rect& caret, - const PP_Rect& bounding_box) = 0; - virtual void CancelCompositionText(PP_Instance instance) = 0; - virtual void SelectionChanged(PP_Instance instance) = 0; - virtual void UpdateSurroundingText(PP_Instance instance, - const char* text, - uint32_t caret, - uint32_t anchor) = 0; - - static const ApiID kApiID = API_ID_PPB_TEXT_INPUT; -}; - -} // namespace thunk -} // namespace ppapi - -#endif // PPAPI_THUNK_PPB_TEXT_INPUT_API_H_ diff --git a/ppapi/thunk/ppb_text_input_thunk.cc b/ppapi/thunk/ppb_text_input_thunk.cc index b5b1753..7d35e2a 100644 --- a/ppapi/thunk/ppb_text_input_thunk.cc +++ b/ppapi/thunk/ppb_text_input_thunk.cc @@ -4,7 +4,7 @@ #include "ppapi/thunk/enter.h" #include "ppapi/thunk/thunk.h" -#include "ppapi/thunk/ppb_text_input_api.h" +#include "ppapi/thunk/ppb_instance_api.h" namespace ppapi { namespace thunk { @@ -12,7 +12,7 @@ namespace thunk { namespace { void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) { - EnterFunction<PPB_TextInput_FunctionAPI> enter(instance, true); + EnterInstance enter(instance); if (enter.succeeded()) enter.functions()->SetTextInputType(instance, type); } @@ -20,26 +20,26 @@ void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) { void UpdateCaretPosition(PP_Instance instance, const PP_Rect* caret, const PP_Rect* bounding_box) { - EnterFunction<PPB_TextInput_FunctionAPI> enter(instance, true); + EnterInstance enter(instance); if (enter.succeeded() && caret && bounding_box) enter.functions()->UpdateCaretPosition(instance, *caret, *bounding_box); } void CancelCompositionText(PP_Instance instance) { - EnterFunction<PPB_TextInput_FunctionAPI> enter(instance, true); + EnterInstance enter(instance); if (enter.succeeded()) enter.functions()->CancelCompositionText(instance); } void UpdateSurroundingText(PP_Instance instance, const char* text, uint32_t caret, uint32_t anchor) { - EnterFunction<PPB_TextInput_FunctionAPI> enter(instance, true); + EnterInstance enter(instance); if (enter.succeeded()) enter.functions()->UpdateSurroundingText(instance, text, caret, anchor); } void SelectionChanged(PP_Instance instance) { - EnterFunction<PPB_TextInput_FunctionAPI> enter(instance, true); + EnterInstance enter(instance); if (enter.succeeded()) enter.functions()->SelectionChanged(instance); } |