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

Unified Diff: content/renderer/render_widget.cc

Issue 7824037: Get surrounding text from webkit. This CL is for sharing code only. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 4 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 | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 761a993bc4877eb4cf93ee44aaa248649d6f8829..071c65c359cf13bed0cb8f0b6c4659fb92dcff90 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -83,6 +83,9 @@ RenderWidget::RenderWidget(RenderThreadBase* render_thread,
is_swapped_out_(false),
input_method_is_active_(false),
text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
+ surrounding_(),
+ cursor_(0),
+ anchor_(0),
can_compose_inline_(true),
popup_type_(popup_type),
pending_window_rect_count_(0),
@@ -1290,23 +1293,48 @@ void RenderWidget::set_next_paint_is_repaint_ack() {
void RenderWidget::UpdateInputMethod() {
if (!input_method_is_active_)
return;
+
+ ViewHostMsg_ImeUpdateTextInputState_Params params;
- ui::TextInputType new_type = GetTextInputType();
- bool new_can_compose_inline = CanComposeInline();
- WebRect new_caret_bounds;
+ params.text_input_type = GetTextInputType();
+ params.can_compose_inline = CanComposeInline();
if (webwidget_)
- new_caret_bounds = webwidget_->caretOrSelectionBounds();
+ params.caret_bounds = webwidget_->caretOrSelectionBounds();
+
+ params.cursor = 0;
+ params.anchor = 0;
+
+
+ // Do not get the surrounding, if the text input type is None or Password.
+ if (webwidget_ &&
+ params.text_input_type != ui::TEXT_INPUT_TYPE_NONE &&
+ params.text_input_type != ui::TEXT_INPUT_TYPE_PASSWORD) {
+ WebKit::WebString text;
+ webwidget_->surroundingTextWithSelection(
+ text, params.cursor, params.anchor);
+ params.surrounding = text;
+ LOG(ERROR) << "\n"
+ << "\tsurrounding = " << params.surrounding
+ << "\tcursor =" << params.cursor
+ << "\tanchor =" << params.anchor;
+ }
// Only sends text input type and caret bounds to the browser process if they
// are changed.
- if (text_input_type_ != new_type || caret_bounds_ != new_caret_bounds ||
- can_compose_inline_ != new_can_compose_inline) {
- text_input_type_ = new_type;
- can_compose_inline_ = new_can_compose_inline;
- caret_bounds_ = new_caret_bounds;
+ if (text_input_type_ != params.text_input_type ||
+ caret_bounds_ != params.caret_bounds ||
+ surrounding_ != params.surrounding ||
+ cursor_ != params.cursor || anchor_ != params.anchor ||
+ can_compose_inline_ != params.can_compose_inline) {
+ text_input_type_ = params.text_input_type;
+ surrounding_ = params.surrounding;
+ cursor_ = params.cursor;
+ anchor_ = params.anchor;
+ can_compose_inline_ = params.can_compose_inline;
+ caret_bounds_ = params.caret_bounds;
Send(new ViewHostMsg_ImeUpdateTextInputState(
- routing_id(), new_type, new_can_compose_inline, new_caret_bounds));
+ routing_id(), params));
}
}
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698