| 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 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 text, WebVector<WebCompositionUnderline>(underlines), selection_start, | 1524 text, WebVector<WebCompositionUnderline>(underlines), selection_start, |
| 1525 selection_end)) { | 1525 selection_end)) { |
| 1526 // If we failed to set the composition text, then we need to let the browser | 1526 // If we failed to set the composition text, then we need to let the browser |
| 1527 // process to cancel the input method's ongoing composition session, to make | 1527 // process to cancel the input method's ongoing composition session, to make |
| 1528 // sure we are in a consistent state. | 1528 // sure we are in a consistent state. |
| 1529 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 1529 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
| 1530 } | 1530 } |
| 1531 UpdateCompositionInfo(false /* not an immediate request */); | 1531 UpdateCompositionInfo(false /* not an immediate request */); |
| 1532 } | 1532 } |
| 1533 | 1533 |
| 1534 void RenderWidget::OnImeCommitText(const base::string16& text, | 1534 void RenderWidget::OnImeCommitText( |
| 1535 const gfx::Range& replacement_range, | 1535 const base::string16& text, |
| 1536 int relative_cursor_pos) { | 1536 const std::vector<WebCompositionUnderline>& underlines, |
| 1537 const gfx::Range& replacement_range, |
| 1538 int relative_cursor_pos) { |
| 1537 #if BUILDFLAG(ENABLE_PLUGINS) | 1539 #if BUILDFLAG(ENABLE_PLUGINS) |
| 1538 if (focused_pepper_plugin_) { | 1540 if (focused_pepper_plugin_) { |
| 1539 focused_pepper_plugin_->render_frame()->OnImeCommitText( | 1541 focused_pepper_plugin_->render_frame()->OnImeCommitText( |
| 1540 text, replacement_range, relative_cursor_pos); | 1542 text, replacement_range, relative_cursor_pos); |
| 1541 return; | 1543 return; |
| 1542 } | 1544 } |
| 1543 #endif | 1545 #endif |
| 1544 if (replacement_range.IsValid()) { | 1546 if (replacement_range.IsValid()) { |
| 1545 GetWebWidget()->applyReplacementRange( | 1547 GetWebWidget()->applyReplacementRange( |
| 1546 WebRange(replacement_range.start(), replacement_range.length())); | 1548 WebRange(replacement_range.start(), replacement_range.length())); |
| 1547 } | 1549 } |
| 1548 | 1550 |
| 1549 if (!GetWebWidget()) | 1551 if (!GetWebWidget()) |
| 1550 return; | 1552 return; |
| 1551 ImeEventGuard guard(this); | 1553 ImeEventGuard guard(this); |
| 1552 input_handler_->set_handling_input_event(true); | 1554 input_handler_->set_handling_input_event(true); |
| 1553 if (auto* controller = GetInputMethodController()) | 1555 if (auto* controller = GetInputMethodController()) |
| 1554 controller->commitText(text, relative_cursor_pos); | 1556 controller->commitText(text, WebVector<WebCompositionUnderline>(underlines), |
| 1557 relative_cursor_pos); |
| 1555 input_handler_->set_handling_input_event(false); | 1558 input_handler_->set_handling_input_event(false); |
| 1556 UpdateCompositionInfo(false /* not an immediate request */); | 1559 UpdateCompositionInfo(false /* not an immediate request */); |
| 1557 } | 1560 } |
| 1558 | 1561 |
| 1559 void RenderWidget::OnImeFinishComposingText(bool keep_selection) { | 1562 void RenderWidget::OnImeFinishComposingText(bool keep_selection) { |
| 1560 #if BUILDFLAG(ENABLE_PLUGINS) | 1563 #if BUILDFLAG(ENABLE_PLUGINS) |
| 1561 if (focused_pepper_plugin_) { | 1564 if (focused_pepper_plugin_) { |
| 1562 focused_pepper_plugin_->render_frame()->OnImeFinishComposingText( | 1565 focused_pepper_plugin_->render_frame()->OnImeFinishComposingText( |
| 1563 keep_selection); | 1566 keep_selection); |
| 1564 return; | 1567 return; |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2241 // browser side (https://crbug.com/669219). | 2244 // browser side (https://crbug.com/669219). |
| 2242 // If there is no WebFrameWidget, then there will be no | 2245 // If there is no WebFrameWidget, then there will be no |
| 2243 // InputMethodControllers for a WebLocalFrame. | 2246 // InputMethodControllers for a WebLocalFrame. |
| 2244 return nullptr; | 2247 return nullptr; |
| 2245 } | 2248 } |
| 2246 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) | 2249 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) |
| 2247 ->getActiveWebInputMethodController(); | 2250 ->getActiveWebInputMethodController(); |
| 2248 } | 2251 } |
| 2249 | 2252 |
| 2250 } // namespace content | 2253 } // namespace content |
| OLD | NEW |