Index: content/renderer/render_widget.cc |
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc |
index d4097830ae789584c4dbbaf26709ef67d0019a18..39c513adecd951268e1eabfcdce2702f579cf061 100644 |
--- a/content/renderer/render_widget.cc |
+++ b/content/renderer/render_widget.cc |
@@ -63,6 +63,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" |
@@ -101,6 +102,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; |
@@ -1400,7 +1402,8 @@ void RenderWidget::OnImeSetComposition( |
if (!ShouldHandleImeEvent()) |
return; |
ImeEventGuard guard(this); |
- if (!GetWebWidget()->setComposition( |
+ if (!GetInputMethodController() || |
lfg
2016/09/16 20:17:09
Why do we need these guards? When do we call this
EhsanK
2016/09/20 15:38:29
It will return nullptr if the focused frame is NOT
|
+ !GetInputMethodController()->setComposition( |
text, WebVector<WebCompositionUnderline>(underlines), selection_start, |
selection_end)) { |
// If we failed to set the composition text, then we need to let the browser |
@@ -1430,7 +1433,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 (GetInputMethodController()) |
+ GetInputMethodController()->commitText(text, relative_cursor_pos); |
input_handler_->set_handling_input_event(false); |
UpdateCompositionInfo(false /* not an immediate request */); |
} |
@@ -1448,9 +1452,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 (GetInputMethodController()) { |
+ GetInputMethodController()->finishComposingText( |
+ keep_selection ? WebInputMethodController::KeepSelection |
+ : WebInputMethodController::DoNotKeepSelection); |
+ } |
input_handler_->set_handling_input_event(false); |
UpdateCompositionInfo(false /* not an immediate request */); |
} |
@@ -1980,7 +1986,9 @@ void RenderWidget::resetInputMethod() { |
if (text_input_info_.type != blink::WebTextInputTypeNone) { |
// 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)) |
+ if (GetInputMethodController() && |
+ GetInputMethodController()->finishComposingText( |
+ WebInputMethodController::DoNotKeepSelection)) |
Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
} |
@@ -2155,4 +2163,12 @@ blink::WebWidget* RenderWidget::GetWebWidget() const { |
return webwidget_internal_; |
} |
+blink::WebInputMethodController* RenderWidget::GetInputMethodController() |
+ const { |
+ return GetWebWidget()->isWebFrameWidget() |
lfg
2016/09/16 20:17:09
Should these be a DCHECK instead of returning null
EhsanK
2016/09/20 15:38:29
I think for now that we only use WebInputMethodCon
|
+ ? static_cast<blink::WebFrameWidget*>(GetWebWidget()) |
+ ->getActiveWebInputMethodController() |
+ : nullptr; |
+} |
+ |
} // namespace content |