diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-12 18:59:15 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-12 18:59:15 +0000 |
commit | 877c69eca972ab2c9ce2022e9987c9e7956a5c94 (patch) | |
tree | c01054374195aecfde5f06f7fa747845e64bcc09 /webkit | |
parent | e24b60976bba788e40c3227efb25f08b5ad7ead3 (diff) | |
download | chromium_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 'webkit')
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 20 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.h | 4 |
2 files changed, 14 insertions, 10 deletions
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 037e1a9..ffb0c17 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -158,11 +158,6 @@ namespace { // that they don't accept texts. const ui::TextInputType kPluginDefaultTextInputType = ui::TEXT_INPUT_TYPE_TEXT; -// 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 size_t kExtraCharsBeforeAndAfterSelection = 100; - #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \ COMPILE_ASSERT(static_cast<int>(WebCursorInfo::webkit_name) \ == static_cast<int>(np_name), \ @@ -611,7 +606,15 @@ void PluginInstance::SelectionChanged() { // TODO(kinaba): currently the browser always calls RequestSurroundingText. // It can be optimized so that it won't call it back until the information // is really needed. - RequestSurroundingText(kExtraCharsBeforeAndAfterSelection); + + // Avoid calling in nested context or else this will reenter the plugin. This + // uses a weak pointer rather than exploiting the fact that this class is + // refcounted because we don't actually want this operation to affect the + // lifetime of the instance. + MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(&PluginInstance::RequestSurroundingText, + AsWeakPtr(), + static_cast<size_t>(kExtraCharsForTextInput))); } void PluginInstance::UpdateSurroundingText(const std::string& text, @@ -900,15 +903,14 @@ string16 PluginInstance::GetLinkAtPosition(const gfx::Point& point) { return link; } -bool PluginInstance::RequestSurroundingText( +void PluginInstance::RequestSurroundingText( size_t desired_number_of_characters) { // Keep a reference on the stack. See NOTE above. scoped_refptr<PluginInstance> ref(this); if (!LoadTextInputInterface()) - return false; + return; plugin_textinput_interface_->RequestSurroundingText( pp_instance(), desired_number_of_characters); - return true; } void PluginInstance::Zoom(double factor, bool text_only) { diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h index 7c8e0de..dc430e71 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.h +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h @@ -13,6 +13,7 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" #include "base/string16.h" #include "googleurl/src/gurl.h" #include "ppapi/c/dev/pp_cursor_type_dev.h" @@ -90,6 +91,7 @@ class PPB_URLRequestInfo_Impl; // ResourceTracker. class WEBKIT_PLUGINS_EXPORT PluginInstance : public base::RefCounted<PluginInstance>, + public base::SupportsWeakPtr<PluginInstance>, public ::ppapi::FunctionGroupBase, public ::ppapi::PPB_Instance_Shared { public: @@ -221,7 +223,7 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance : string16 GetSelectedText(bool html); string16 GetLinkAtPosition(const gfx::Point& point); - bool RequestSurroundingText(size_t desired_number_of_characters); + void RequestSurroundingText(size_t desired_number_of_characters); void Zoom(double factor, bool text_only); bool StartFind(const string16& search_text, bool case_sensitive, |