| 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 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1534 text, WebVector<WebCompositionUnderline>(underlines), selection_start, | 1534 text, WebVector<WebCompositionUnderline>(underlines), selection_start, |
| 1535 selection_end)) { | 1535 selection_end)) { |
| 1536 // If we failed to set the composition text, then we need to let the browser | 1536 // If we failed to set the composition text, then we need to let the browser |
| 1537 // process to cancel the input method's ongoing composition session, to make | 1537 // process to cancel the input method's ongoing composition session, to make |
| 1538 // sure we are in a consistent state. | 1538 // sure we are in a consistent state. |
| 1539 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 1539 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
| 1540 } | 1540 } |
| 1541 UpdateCompositionInfo(false /* not an immediate request */); | 1541 UpdateCompositionInfo(false /* not an immediate request */); |
| 1542 } | 1542 } |
| 1543 | 1543 |
| 1544 void RenderWidget::OnImeCommitText(const base::string16& text, | 1544 void RenderWidget::OnImeCommitText( |
| 1545 const gfx::Range& replacement_range, | 1545 const base::string16& text, |
| 1546 int relative_cursor_pos) { | 1546 const std::vector<WebCompositionUnderline>& underlines, |
| 1547 const gfx::Range& replacement_range, |
| 1548 int relative_cursor_pos) { |
| 1547 if (!ShouldHandleImeEvents()) | 1549 if (!ShouldHandleImeEvents()) |
| 1548 return; | 1550 return; |
| 1549 | 1551 |
| 1550 #if BUILDFLAG(ENABLE_PLUGINS) | 1552 #if BUILDFLAG(ENABLE_PLUGINS) |
| 1551 if (focused_pepper_plugin_) { | 1553 if (focused_pepper_plugin_) { |
| 1552 focused_pepper_plugin_->render_frame()->OnImeCommitText( | 1554 focused_pepper_plugin_->render_frame()->OnImeCommitText( |
| 1553 text, replacement_range, relative_cursor_pos); | 1555 text, replacement_range, relative_cursor_pos); |
| 1554 return; | 1556 return; |
| 1555 } | 1557 } |
| 1556 #endif | 1558 #endif |
| 1557 if (replacement_range.IsValid()) { | 1559 if (replacement_range.IsValid()) { |
| 1558 GetWebWidget()->applyReplacementRange( | 1560 GetWebWidget()->applyReplacementRange( |
| 1559 WebRange(replacement_range.start(), replacement_range.length())); | 1561 WebRange(replacement_range.start(), replacement_range.length())); |
| 1560 } | 1562 } |
| 1561 | 1563 |
| 1562 if (!GetWebWidget()) | 1564 if (!GetWebWidget()) |
| 1563 return; | 1565 return; |
| 1564 ImeEventGuard guard(this); | 1566 ImeEventGuard guard(this); |
| 1565 input_handler_->set_handling_input_event(true); | 1567 input_handler_->set_handling_input_event(true); |
| 1566 if (auto* controller = GetInputMethodController()) | 1568 if (auto* controller = GetInputMethodController()) |
| 1567 controller->commitText(text, relative_cursor_pos); | 1569 controller->commitText(text, WebVector<WebCompositionUnderline>(underlines), |
| 1570 relative_cursor_pos); |
| 1568 input_handler_->set_handling_input_event(false); | 1571 input_handler_->set_handling_input_event(false); |
| 1569 UpdateCompositionInfo(false /* not an immediate request */); | 1572 UpdateCompositionInfo(false /* not an immediate request */); |
| 1570 } | 1573 } |
| 1571 | 1574 |
| 1572 void RenderWidget::OnImeFinishComposingText(bool keep_selection) { | 1575 void RenderWidget::OnImeFinishComposingText(bool keep_selection) { |
| 1573 if (!ShouldHandleImeEvents()) | 1576 if (!ShouldHandleImeEvents()) |
| 1574 return; | 1577 return; |
| 1575 | 1578 |
| 1576 #if BUILDFLAG(ENABLE_PLUGINS) | 1579 #if BUILDFLAG(ENABLE_PLUGINS) |
| 1577 if (focused_pepper_plugin_) { | 1580 if (focused_pepper_plugin_) { |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2273 // browser side (https://crbug.com/669219). | 2276 // browser side (https://crbug.com/669219). |
| 2274 // If there is no WebFrameWidget, then there will be no | 2277 // If there is no WebFrameWidget, then there will be no |
| 2275 // InputMethodControllers for a WebLocalFrame. | 2278 // InputMethodControllers for a WebLocalFrame. |
| 2276 return nullptr; | 2279 return nullptr; |
| 2277 } | 2280 } |
| 2278 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) | 2281 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) |
| 2279 ->getActiveWebInputMethodController(); | 2282 ->getActiveWebInputMethodController(); |
| 2280 } | 2283 } |
| 2281 | 2284 |
| 2282 } // namespace content | 2285 } // namespace content |
| OLD | NEW |