Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Unified Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 10083013: Merge 132027 - Make the text input not require round-trips when the text is updated. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1084/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc
===================================================================
--- webkit/plugins/ppapi/ppapi_plugin_instance.cc (revision 132273)
+++ webkit/plugins/ppapi/ppapi_plugin_instance.cc (working copy)
@@ -157,11 +157,6 @@
// 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), \
@@ -655,7 +650,15 @@
// 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,
@@ -944,15 +947,14 @@
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) {
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698