summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 18:59:15 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 18:59:15 +0000
commit877c69eca972ab2c9ce2022e9987c9e7956a5c94 (patch)
treec01054374195aecfde5f06f7fa747845e64bcc09 /ppapi
parente24b60976bba788e40c3227efb25f08b5ad7ead3 (diff)
downloadchromium_src-877c69eca972ab2c9ce2022e9987c9e7956a5c94.zip
chromium_src-877c69eca972ab2c9ce2022e9987c9e7956a5c94.tar.gz
chromium_src-877c69eca972ab2c9ce2022e9987c9e7956a5c94.tar.bz2
Make the text input not require round-trips when the text is updated.
In the proxied version, this requests the text in-process avoiding the round trip. This also makes the requesting not reenter the plugin for in-process plugins. TEST= BUG=123020 Review URL: https://chromiumcodereview.appspot.com/10053017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132027 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/proxy/ppapi_messages.h2
-rw-r--r--ppapi/proxy/ppb_text_input_proxy.cc44
-rw-r--r--ppapi/proxy/ppb_text_input_proxy.h1
-rw-r--r--ppapi/shared_impl/ppb_instance_shared.cc3
-rw-r--r--ppapi/shared_impl/ppb_instance_shared.h5
5 files changed, 41 insertions, 14 deletions
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 8d7d0fc..a6390f4 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -973,8 +973,6 @@ IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBTextInput_UpdateCaretPosition,
PP_Rect /* bounding_box */)
IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBTextInput_CancelCompositionText,
PP_Instance /* instance */)
-IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBTextInput_SelectionChanged,
- PP_Instance /* instance */)
IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBTextInput_UpdateSurroundingText,
PP_Instance /* instance */,
std::string /* text */,
diff --git a/ppapi/proxy/ppb_text_input_proxy.cc b/ppapi/proxy/ppb_text_input_proxy.cc
index e7434e0..3d2f873 100644
--- a/ppapi/proxy/ppb_text_input_proxy.cc
+++ b/ppapi/proxy/ppb_text_input_proxy.cc
@@ -6,12 +6,32 @@
#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) {
}
@@ -43,8 +63,19 @@ void PPB_TextInput_Proxy::CancelCompositionText(PP_Instance instance) {
}
void PPB_TextInput_Proxy::SelectionChanged(PP_Instance instance) {
- dispatcher()->Send(new PpapiHostMsg_PPBTextInput_SelectionChanged(
- API_ID_PPB_TEXT_INPUT, 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,
@@ -64,8 +95,6 @@ bool PPB_TextInput_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnMsgUpdateCaretPosition)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTextInput_CancelCompositionText,
OnMsgCancelCompositionText)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTextInput_SelectionChanged,
- OnMsgSelectionChanged)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTextInput_UpdateSurroundingText,
OnMsgUpdateSurroundingText)
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -97,13 +126,6 @@ void PPB_TextInput_Proxy::OnMsgCancelCompositionText(PP_Instance instance) {
enter.functions()->CancelCompositionText(instance);
}
-void PPB_TextInput_Proxy::OnMsgSelectionChanged(PP_Instance instance) {
- ppapi::thunk::EnterFunctionNoLock<PPB_TextInput_FunctionAPI> enter(instance,
- true);
- if (enter.succeeded())
- enter.functions()->SelectionChanged(instance);
-}
-
void PPB_TextInput_Proxy::OnMsgUpdateSurroundingText(PP_Instance instance,
const std::string& text,
uint32_t caret,
diff --git a/ppapi/proxy/ppb_text_input_proxy.h b/ppapi/proxy/ppb_text_input_proxy.h
index e5226a4..066ac5b 100644
--- a/ppapi/proxy/ppb_text_input_proxy.h
+++ b/ppapi/proxy/ppb_text_input_proxy.h
@@ -51,7 +51,6 @@ class PPB_TextInput_Proxy
PP_Rect caret,
PP_Rect bounding_box);
void OnMsgCancelCompositionText(PP_Instance instance);
- void OnMsgSelectionChanged(PP_Instance instance);
void OnMsgUpdateSurroundingText(PP_Instance instance,
const std::string& text,
uint32_t caret,
diff --git a/ppapi/shared_impl/ppb_instance_shared.cc b/ppapi/shared_impl/ppb_instance_shared.cc
index 22e263a..5a29a99 100644
--- a/ppapi/shared_impl/ppb_instance_shared.cc
+++ b/ppapi/shared_impl/ppb_instance_shared.cc
@@ -16,6 +16,9 @@
namespace ppapi {
+// static
+const int PPB_Instance_Shared::kExtraCharsForTextInput = 100;
+
PPB_Instance_Shared::~PPB_Instance_Shared() {
}
diff --git a/ppapi/shared_impl/ppb_instance_shared.h b/ppapi/shared_impl/ppb_instance_shared.h
index 385d805..eed82e1 100644
--- a/ppapi/shared_impl/ppb_instance_shared.h
+++ b/ppapi/shared_impl/ppb_instance_shared.h
@@ -33,6 +33,11 @@ class PPAPI_SHARED_EXPORT PPB_Instance_Shared
bool ValidateSetCursorParams(PP_MouseCursor_Type type,
PP_Resource image,
const PP_Point* hot_spot);
+
+ // The length of text to request as a surrounding context of selection.
+ // For now, the value is copied from the one with render_view_impl.cc.
+ // TODO(kinaba) implement a way to dynamically sync the requirement.
+ static const int kExtraCharsForTextInput;
};
} // namespace ppapi