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

Side by Side Diff: content/renderer/render_widget.cc

Issue 2303613003: WebRange-ify WebWidget::applyReplacementRange. (Closed)
Patch Set: Updated comments. Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 const gfx::Range& replacement_range, 1374 const gfx::Range& replacement_range,
1375 int selection_start, int selection_end) { 1375 int selection_start, int selection_end) {
1376 #if defined(ENABLE_PLUGINS) 1376 #if defined(ENABLE_PLUGINS)
1377 if (focused_pepper_plugin_) { 1377 if (focused_pepper_plugin_) {
1378 focused_pepper_plugin_->render_frame()->OnImeSetComposition( 1378 focused_pepper_plugin_->render_frame()->OnImeSetComposition(
1379 text, underlines, selection_start, selection_end); 1379 text, underlines, selection_start, selection_end);
1380 return; 1380 return;
1381 } 1381 }
1382 #endif 1382 #endif
1383 if (replacement_range.IsValid()) { 1383 if (replacement_range.IsValid()) {
1384 webwidget_->applyReplacementRange(replacement_range.start(), 1384 webwidget_->applyReplacementRange(
1385 replacement_range.length()); 1385 WebRange(replacement_range.start(), replacement_range.length()));
1386 } 1386 }
1387 1387
1388 if (!ShouldHandleImeEvent()) 1388 if (!ShouldHandleImeEvent())
1389 return; 1389 return;
1390 ImeEventGuard guard(this); 1390 ImeEventGuard guard(this);
1391 if (!webwidget_->setComposition( 1391 if (!webwidget_->setComposition(
1392 text, WebVector<WebCompositionUnderline>(underlines), 1392 text, WebVector<WebCompositionUnderline>(underlines),
1393 selection_start, selection_end)) { 1393 selection_start, selection_end)) {
1394 // If we failed to set the composition text, then we need to let the browser 1394 // If we failed to set the composition text, then we need to let the browser
1395 // process to cancel the input method's ongoing composition session, to make 1395 // process to cancel the input method's ongoing composition session, to make
1396 // sure we are in a consistent state. 1396 // sure we are in a consistent state.
1397 Send(new InputHostMsg_ImeCancelComposition(routing_id())); 1397 Send(new InputHostMsg_ImeCancelComposition(routing_id()));
1398 } 1398 }
1399 UpdateCompositionInfo(false /* not an immediate request */); 1399 UpdateCompositionInfo(false /* not an immediate request */);
1400 } 1400 }
1401 1401
1402 void RenderWidget::OnImeConfirmComposition(const base::string16& text, 1402 void RenderWidget::OnImeConfirmComposition(const base::string16& text,
1403 const gfx::Range& replacement_range, 1403 const gfx::Range& replacement_range,
1404 bool keep_selection) { 1404 bool keep_selection) {
1405 #if defined(ENABLE_PLUGINS) 1405 #if defined(ENABLE_PLUGINS)
1406 if (focused_pepper_plugin_) { 1406 if (focused_pepper_plugin_) {
1407 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition( 1407 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition(
1408 text, replacement_range, keep_selection); 1408 text, replacement_range, keep_selection);
1409 return; 1409 return;
1410 } 1410 }
1411 #endif 1411 #endif
1412 if (replacement_range.IsValid()) { 1412 if (replacement_range.IsValid()) {
1413 webwidget_->applyReplacementRange(replacement_range.start(), 1413 webwidget_->applyReplacementRange(
1414 replacement_range.length()); 1414 WebRange(replacement_range.start(), replacement_range.length()));
1415 } 1415 }
1416 1416
1417 if (!ShouldHandleImeEvent()) 1417 if (!ShouldHandleImeEvent())
1418 return; 1418 return;
1419 ImeEventGuard guard(this); 1419 ImeEventGuard guard(this);
1420 input_handler_->set_handling_input_event(true); 1420 input_handler_->set_handling_input_event(true);
1421 if (text.length()) 1421 if (text.length())
1422 webwidget_->confirmComposition(text); 1422 webwidget_->confirmComposition(text);
1423 else if (keep_selection) 1423 else if (keep_selection)
1424 webwidget_->confirmComposition(WebWidget::KeepSelection); 1424 webwidget_->confirmComposition(WebWidget::KeepSelection);
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 void RenderWidget::requestPointerUnlock() { 2087 void RenderWidget::requestPointerUnlock() {
2088 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); 2088 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get());
2089 } 2089 }
2090 2090
2091 bool RenderWidget::isPointerLocked() { 2091 bool RenderWidget::isPointerLocked() {
2092 return mouse_lock_dispatcher_->IsMouseLockedTo( 2092 return mouse_lock_dispatcher_->IsMouseLockedTo(
2093 webwidget_mouse_lock_target_.get()); 2093 webwidget_mouse_lock_target_.get());
2094 } 2094 }
2095 2095
2096 } // namespace content 2096 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698