| OLD | NEW |
| 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 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 // If we failed to set the composition text, then we need to let the browser | 1406 // If we failed to set the composition text, then we need to let the browser |
| 1407 // process to cancel the input method's ongoing composition session, to make | 1407 // process to cancel the input method's ongoing composition session, to make |
| 1408 // sure we are in a consistent state. | 1408 // sure we are in a consistent state. |
| 1409 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 1409 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
| 1410 } | 1410 } |
| 1411 UpdateCompositionInfo(false /* not an immediate request */); | 1411 UpdateCompositionInfo(false /* not an immediate request */); |
| 1412 } | 1412 } |
| 1413 | 1413 |
| 1414 void RenderWidget::OnImeConfirmComposition(const base::string16& text, | 1414 void RenderWidget::OnImeConfirmComposition(const base::string16& text, |
| 1415 const gfx::Range& replacement_range, | 1415 const gfx::Range& replacement_range, |
| 1416 bool keep_selection) { | 1416 bool keep_selection, |
| 1417 int relative_cursor_pos) { |
| 1417 #if defined(ENABLE_PLUGINS) | 1418 #if defined(ENABLE_PLUGINS) |
| 1418 if (focused_pepper_plugin_) { | 1419 if (focused_pepper_plugin_) { |
| 1419 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition( | 1420 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition( |
| 1420 text, replacement_range, keep_selection); | 1421 text, replacement_range, keep_selection, relative_cursor_pos); |
| 1421 return; | 1422 return; |
| 1422 } | 1423 } |
| 1423 #endif | 1424 #endif |
| 1424 if (replacement_range.IsValid()) { | 1425 if (replacement_range.IsValid()) { |
| 1425 webwidget_->applyReplacementRange(replacement_range.start(), | 1426 webwidget_->applyReplacementRange(replacement_range.start(), |
| 1426 replacement_range.length()); | 1427 replacement_range.length()); |
| 1427 } | 1428 } |
| 1428 | 1429 |
| 1429 if (!ShouldHandleImeEvent()) | 1430 if (!ShouldHandleImeEvent()) |
| 1430 return; | 1431 return; |
| 1431 ImeEventGuard guard(this); | 1432 ImeEventGuard guard(this); |
| 1432 input_handler_->set_handling_input_event(true); | 1433 input_handler_->set_handling_input_event(true); |
| 1433 if (text.length()) | 1434 if (text.length()) |
| 1434 webwidget_->confirmComposition(text); | 1435 webwidget_->confirmComposition(text, relative_cursor_pos); |
| 1435 else if (keep_selection) | 1436 else if (keep_selection) |
| 1436 webwidget_->confirmComposition(WebWidget::KeepSelection); | 1437 webwidget_->confirmComposition(WebWidget::KeepSelection); |
| 1437 else | 1438 else |
| 1438 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection); | 1439 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection); |
| 1439 input_handler_->set_handling_input_event(false); | 1440 input_handler_->set_handling_input_event(false); |
| 1440 UpdateCompositionInfo(false /* not an immediate request */); | 1441 UpdateCompositionInfo(false /* not an immediate request */); |
| 1441 } | 1442 } |
| 1442 | 1443 |
| 1443 void RenderWidget::OnDeviceScaleFactorChanged() { | 1444 void RenderWidget::OnDeviceScaleFactorChanged() { |
| 1444 if (!compositor_) | 1445 if (!compositor_) |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2100 void RenderWidget::requestPointerUnlock() { | 2101 void RenderWidget::requestPointerUnlock() { |
| 2101 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); | 2102 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); |
| 2102 } | 2103 } |
| 2103 | 2104 |
| 2104 bool RenderWidget::isPointerLocked() { | 2105 bool RenderWidget::isPointerLocked() { |
| 2105 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2106 return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 2106 webwidget_mouse_lock_target_.get()); | 2107 webwidget_mouse_lock_target_.get()); |
| 2107 } | 2108 } |
| 2108 | 2109 |
| 2109 } // namespace content | 2110 } // namespace content |
| OLD | NEW |