Chromium Code Reviews| Index: content/renderer/render_widget.cc |
| diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc |
| index 57bb2085f61e3f419307f96fb827956bc7ba7206..d5bc6ce03fe5e2b3607966d3c19860952540babf 100644 |
| --- a/content/renderer/render_widget.cc |
| +++ b/content/renderer/render_widget.cc |
| @@ -64,6 +64,7 @@ |
| #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_scheduler.h" |
| #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" |
| #include "third_party/WebKit/public/web/WebFrameWidget.h" |
| +#include "third_party/WebKit/public/web/WebInputMethodController.h" |
| #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| #include "third_party/WebKit/public/web/WebNode.h" |
| #include "third_party/WebKit/public/web/WebPagePopup.h" |
| @@ -106,6 +107,7 @@ using blink::WebDeviceEmulationParams; |
| using blink::WebGestureEvent; |
| using blink::WebInputEvent; |
| using blink::WebInputEventResult; |
| +using blink::WebInputMethodController; |
| using blink::WebKeyboardEvent; |
| using blink::WebMouseEvent; |
| using blink::WebMouseWheelEvent; |
| @@ -1396,7 +1398,10 @@ void RenderWidget::OnImeSetComposition( |
| if (!ShouldHandleImeEvent()) |
| return; |
| ImeEventGuard guard(this); |
| - if (!GetWebWidget()->setComposition( |
| + auto* controller = GetInputMethodController(); |
|
Charlie Reis
2016/11/02 20:57:38
nit: Let's avoid auto here. It's helpful to know
EhsanK
2016/11/02 22:16:34
Acknowledged.
|
| + DCHECK(controller); |
| + if (!controller || |
| + !controller->setComposition( |
| text, WebVector<WebCompositionUnderline>(underlines), selection_start, |
| selection_end)) { |
| // If we failed to set the composition text, then we need to let the browser |
| @@ -1426,7 +1431,8 @@ void RenderWidget::OnImeCommitText(const base::string16& text, |
| return; |
| ImeEventGuard guard(this); |
| input_handler_->set_handling_input_event(true); |
| - GetWebWidget()->commitText(text, relative_cursor_pos); |
| + if (auto* controller = GetInputMethodController()) |
| + controller->commitText(text, relative_cursor_pos); |
| input_handler_->set_handling_input_event(false); |
| UpdateCompositionInfo(false /* not an immediate request */); |
| } |
| @@ -1444,9 +1450,11 @@ void RenderWidget::OnImeFinishComposingText(bool keep_selection) { |
| return; |
| ImeEventGuard guard(this); |
| input_handler_->set_handling_input_event(true); |
| - GetWebWidget()->finishComposingText(keep_selection |
| - ? WebWidget::KeepSelection |
| - : WebWidget::DoNotKeepSelection); |
| + if (auto* controller = GetInputMethodController()) { |
| + controller->finishComposingText( |
| + keep_selection ? WebInputMethodController::KeepSelection |
| + : WebInputMethodController::DoNotKeepSelection); |
| + } |
| input_handler_->set_handling_input_event(false); |
| UpdateCompositionInfo(false /* not an immediate request */); |
| } |
| @@ -1953,7 +1961,10 @@ void RenderWidget::resetInputMethod() { |
| if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { |
| // If a composition text exists, then we need to let the browser process |
| // to cancel the input method's ongoing composition session. |
| - if (GetWebWidget()->finishComposingText(WebWidget::DoNotKeepSelection)) |
| + auto* controller = GetInputMethodController(); |
| + if (controller && |
| + controller->finishComposingText( |
| + WebInputMethodController::DoNotKeepSelection)) |
| Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
| } |
| @@ -2094,4 +2105,13 @@ blink::WebWidget* RenderWidget::GetWebWidget() const { |
| return webwidget_internal_; |
| } |
| +blink::WebInputMethodController* RenderWidget::GetInputMethodController() |
| + const { |
| + // TODO(ekaramad): Will this DCHECK ever fire? Remove when GetWebWidget() is |
| + // always a WebFrameWidget. |
| + DCHECK(GetWebWidget()->isWebFrameWidget()); |
|
Charlie Reis
2016/11/02 20:57:38
This can't be a DCHECK, since we'll get a potentia
EhsanK
2016/11/02 22:16:34
I see. Thanks! I don't think we can have a WebWidg
|
| + return static_cast<blink::WebFrameWidget*>(GetWebWidget()) |
| + ->getActiveWebInputMethodController(); |
| +} |
| + |
| } // namespace content |