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

Side by Side 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, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 num_swapbuffers_complete_pending_(0), 76 num_swapbuffers_complete_pending_(0),
77 did_show_(false), 77 did_show_(false),
78 is_hidden_(false), 78 is_hidden_(false),
79 needs_repainting_on_restore_(false), 79 needs_repainting_on_restore_(false),
80 has_focus_(false), 80 has_focus_(false),
81 handling_input_event_(false), 81 handling_input_event_(false),
82 closing_(false), 82 closing_(false),
83 is_swapped_out_(false), 83 is_swapped_out_(false),
84 input_method_is_active_(false), 84 input_method_is_active_(false),
85 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 85 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
86 surrounding_(),
87 cursor_(0),
88 anchor_(0),
86 can_compose_inline_(true), 89 can_compose_inline_(true),
87 popup_type_(popup_type), 90 popup_type_(popup_type),
88 pending_window_rect_count_(0), 91 pending_window_rect_count_(0),
89 suppress_next_char_events_(false), 92 suppress_next_char_events_(false),
90 is_accelerated_compositing_active_(false), 93 is_accelerated_compositing_active_(false),
91 animation_update_pending_(false), 94 animation_update_pending_(false),
92 animation_task_posted_(false), 95 animation_task_posted_(false),
93 invalidation_task_posted_(false) { 96 invalidation_task_posted_(false) {
94 RenderProcess::current()->AddRefProcess(); 97 RenderProcess::current()->AddRefProcess();
95 DCHECK(render_thread_); 98 DCHECK(render_thread_);
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESTORE_ACK; 1286 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESTORE_ACK;
1284 } 1287 }
1285 1288
1286 void RenderWidget::set_next_paint_is_repaint_ack() { 1289 void RenderWidget::set_next_paint_is_repaint_ack() {
1287 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; 1290 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK;
1288 } 1291 }
1289 1292
1290 void RenderWidget::UpdateInputMethod() { 1293 void RenderWidget::UpdateInputMethod() {
1291 if (!input_method_is_active_) 1294 if (!input_method_is_active_)
1292 return; 1295 return;
1296
1297 ViewHostMsg_ImeUpdateTextInputState_Params params;
1293 1298
1294 ui::TextInputType new_type = GetTextInputType(); 1299 params.text_input_type = GetTextInputType();
1295 bool new_can_compose_inline = CanComposeInline(); 1300 params.can_compose_inline = CanComposeInline();
1296 WebRect new_caret_bounds;
1297 1301
1298 if (webwidget_) 1302 if (webwidget_)
1299 new_caret_bounds = webwidget_->caretOrSelectionBounds(); 1303 params.caret_bounds = webwidget_->caretOrSelectionBounds();
1304
1305 params.cursor = 0;
1306 params.anchor = 0;
1307
1308
1309 // Do not get the surrounding, if the text input type is None or Password.
1310 if (webwidget_ &&
1311 params.text_input_type != ui::TEXT_INPUT_TYPE_NONE &&
1312 params.text_input_type != ui::TEXT_INPUT_TYPE_PASSWORD) {
1313 WebKit::WebString text;
1314 webwidget_->surroundingTextWithSelection(
1315 text, params.cursor, params.anchor);
1316 params.surrounding = text;
1317 LOG(ERROR) << "\n"
1318 << "\tsurrounding = " << params.surrounding
1319 << "\tcursor =" << params.cursor
1320 << "\tanchor =" << params.anchor;
1321 }
1300 1322
1301 // Only sends text input type and caret bounds to the browser process if they 1323 // Only sends text input type and caret bounds to the browser process if they
1302 // are changed. 1324 // are changed.
1303 if (text_input_type_ != new_type || caret_bounds_ != new_caret_bounds || 1325 if (text_input_type_ != params.text_input_type ||
1304 can_compose_inline_ != new_can_compose_inline) { 1326 caret_bounds_ != params.caret_bounds ||
1305 text_input_type_ = new_type; 1327 surrounding_ != params.surrounding ||
1306 can_compose_inline_ = new_can_compose_inline; 1328 cursor_ != params.cursor || anchor_ != params.anchor ||
1307 caret_bounds_ = new_caret_bounds; 1329 can_compose_inline_ != params.can_compose_inline) {
1330 text_input_type_ = params.text_input_type;
1331 surrounding_ = params.surrounding;
1332 cursor_ = params.cursor;
1333 anchor_ = params.anchor;
1334 can_compose_inline_ = params.can_compose_inline;
1335 caret_bounds_ = params.caret_bounds;
1308 Send(new ViewHostMsg_ImeUpdateTextInputState( 1336 Send(new ViewHostMsg_ImeUpdateTextInputState(
1309 routing_id(), new_type, new_can_compose_inline, new_caret_bounds)); 1337 routing_id(), params));
1310 } 1338 }
1311 } 1339 }
1312 1340
1313 COMPILE_ASSERT(int(WebKit::WebTextInputTypeNone) == \ 1341 COMPILE_ASSERT(int(WebKit::WebTextInputTypeNone) == \
1314 int(ui::TEXT_INPUT_TYPE_NONE), mismatching_enums); 1342 int(ui::TEXT_INPUT_TYPE_NONE), mismatching_enums);
1315 COMPILE_ASSERT(int(WebKit::WebTextInputTypeText) == \ 1343 COMPILE_ASSERT(int(WebKit::WebTextInputTypeText) == \
1316 int(ui::TEXT_INPUT_TYPE_TEXT), mismatching_enums); 1344 int(ui::TEXT_INPUT_TYPE_TEXT), mismatching_enums);
1317 COMPILE_ASSERT(int(WebKit::WebTextInputTypePassword) == \ 1345 COMPILE_ASSERT(int(WebKit::WebTextInputTypePassword) == \
1318 int(ui::TEXT_INPUT_TYPE_PASSWORD), mismatching_enums); 1346 int(ui::TEXT_INPUT_TYPE_PASSWORD), mismatching_enums);
1319 COMPILE_ASSERT(int(WebKit::WebTextInputTypeSearch) == \ 1347 COMPILE_ASSERT(int(WebKit::WebTextInputTypeSearch) == \
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 1419
1392 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { 1420 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) {
1393 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); 1421 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin();
1394 i != plugin_window_moves_.end(); ++i) { 1422 i != plugin_window_moves_.end(); ++i) {
1395 if (i->window == window) { 1423 if (i->window == window) {
1396 plugin_window_moves_.erase(i); 1424 plugin_window_moves_.erase(i);
1397 break; 1425 break;
1398 } 1426 }
1399 } 1427 }
1400 } 1428 }
OLDNEW
« 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