Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_aura.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc |
| index c33e325cef30eaab1a331b7c0dcf7f6d7f8f6166..0516c293929574a5613e8055fefe7084dbb0497d 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_aura.cc |
| +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc |
| @@ -370,10 +370,6 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, |
| popup_parent_host_view_(nullptr), |
| popup_child_host_view_(nullptr), |
| is_loading_(false), |
| - text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| - text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
| - text_input_flags_(0), |
| - can_compose_inline_(true), |
| has_composition_text_(false), |
| accept_return_character_(false), |
| begin_frame_source_(nullptr), |
| @@ -400,6 +396,11 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, |
| GetSurfaceIdNamespace(), this); |
| } |
| + // We should start observing the TextInputManager for IME-related events as |
| + // well as monitoring its lifetime. |
| + if (GetTextInputManager()) |
| + GetTextInputManager()->AddObserver(this); |
| + |
| bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> |
| GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; |
| SetOverscrollControllerEnabled(overscroll_enabled); |
| @@ -877,25 +878,6 @@ void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) { |
| UpdateCursorIfOverSelf(); |
| } |
| -void RenderWidgetHostViewAura::TextInputStateChanged( |
| - const TextInputState& params) { |
| - if (text_input_type_ != params.type || |
| - text_input_mode_ != params.mode || |
| - can_compose_inline_ != params.can_compose_inline || |
| - text_input_flags_ != params.flags) { |
| - text_input_type_ = params.type; |
| - text_input_mode_ = params.mode; |
| - can_compose_inline_ = params.can_compose_inline; |
| - text_input_flags_ = params.flags; |
| - if (GetInputMethod()) |
| - GetInputMethod()->OnTextInputTypeChanged(this); |
| - } |
| - if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) { |
| - if (GetInputMethod()) |
| - GetInputMethod()->ShowImeIfNeeded(); |
| - } |
| -} |
| - |
| void RenderWidgetHostViewAura::ImeCancelComposition() { |
| if (GetInputMethod()) |
| GetInputMethod()->CancelComposition(this); |
| @@ -1398,7 +1380,8 @@ void RenderWidgetHostViewAura::ClearCompositionText() { |
| } |
| void RenderWidgetHostViewAura::InsertText(const base::string16& text) { |
| - DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE); |
| + DCHECK(GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE); |
|
Charlie Reis
2016/05/26 06:22:04
nit: DCHECK_NE
EhsanK
2016/05/30 15:06:08
Done.
|
| + |
| // TODO(wjmaclean): can host_ ever be null? |
| if (host_) |
| host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false); |
| @@ -1421,19 +1404,27 @@ void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) { |
| } |
| ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const { |
| - return text_input_type_; |
| + if (text_input_manager_ && text_input_manager_->GetTextInputState()) |
| + return text_input_manager_->GetTextInputState()->type; |
| + return ui::TEXT_INPUT_TYPE_NONE; |
| } |
| ui::TextInputMode RenderWidgetHostViewAura::GetTextInputMode() const { |
| - return text_input_mode_; |
| + if (text_input_manager_ && text_input_manager_->GetTextInputState()) |
| + return text_input_manager_->GetTextInputState()->mode; |
| + return ui::TEXT_INPUT_MODE_DEFAULT; |
| } |
| int RenderWidgetHostViewAura::GetTextInputFlags() const { |
| - return text_input_flags_; |
| + if (text_input_manager_ && text_input_manager_->GetTextInputState()) |
| + return text_input_manager_->GetTextInputState()->flags; |
| + return 0; |
| } |
| bool RenderWidgetHostViewAura::CanComposeInline() const { |
| - return can_compose_inline_; |
| + if (text_input_manager_ && text_input_manager_->GetTextInputState()) |
| + return text_input_manager_->GetTextInputState()->can_compose_inline; |
| + return true; |
| } |
| gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen( |
| @@ -2287,6 +2278,9 @@ RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { |
| // be set to NULL. |
| DCHECK(!legacy_render_widget_host_HWND_); |
| #endif |
| + |
| + if (text_input_manager_) |
| + text_input_manager_->RemoveObserver(this); |
| } |
| void RenderWidgetHostViewAura::CreateAuraWindow() { |
| @@ -2863,6 +2857,25 @@ cc::SurfaceId RenderWidgetHostViewAura::SurfaceIdForTesting() const { |
| return delegated_frame_host_->SurfaceIdForTesting(); |
| } |
| +void RenderWidgetHostViewAura::OnUpdateTextInputStateCalled( |
| + TextInputManager* text_input_manager, |
| + RenderWidgetHostViewBase* updated_view, |
| + bool did_update_state) { |
| + DCHECK_EQ(text_input_manager_, text_input_manager); |
| + |
| + if (!GetInputMethod()) |
| + return; |
| + |
| + if (did_update_state) |
| + GetInputMethod()->OnTextInputTypeChanged(this); |
| + |
| + const TextInputState* state = text_input_manager_->GetTextInputState(); |
| + |
| + if (state && state->show_ime_if_needed && |
| + state->type != ui::TEXT_INPUT_TYPE_NONE) |
| + GetInputMethod()->ShowImeIfNeeded(); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // RenderWidgetHostViewBase, public: |