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 51d18a0b1a43a10a6ce486dac2d2a40ee032d1b5..f68bc2ffea079c72707fd1b89ec83fb9272ed01a 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,9 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, |
GetSurfaceIdNamespace(), this); |
} |
+ if (GetTextInputManager()) |
+ GetTextInputManager()->AddObserver(this); |
+ |
bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> |
GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; |
SetOverscrollControllerEnabled(overscroll_enabled); |
@@ -877,25 +876,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); |
@@ -1497,7 +1477,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); |
+ |
// TODO(wjmaclean): can host_ ever be null? |
if (host_) |
host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false); |
@@ -1520,19 +1501,27 @@ void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) { |
} |
ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const { |
- return text_input_type_; |
+ if (GetTextInputManager() && GetTextInputManager()->GetTextInputState()) |
+ return GetTextInputManager()->GetTextInputState()->type; |
+ return ui::TEXT_INPUT_TYPE_NONE; |
} |
ui::TextInputMode RenderWidgetHostViewAura::GetTextInputMode() const { |
- return text_input_mode_; |
+ if (GetTextInputManager() && GetTextInputManager()->GetTextInputState()) |
+ return GetTextInputManager()->GetTextInputState()->mode; |
+ return ui::TEXT_INPUT_MODE_DEFAULT; |
} |
int RenderWidgetHostViewAura::GetTextInputFlags() const { |
- return text_input_flags_; |
+ if (GetTextInputManager() && GetTextInputManager()->GetTextInputState()) |
+ return GetTextInputManager()->GetTextInputState()->flags; |
+ return 0; |
} |
bool RenderWidgetHostViewAura::CanComposeInline() const { |
- return can_compose_inline_; |
+ if (GetTextInputManager() && GetTextInputManager()->GetTextInputState()) |
+ return GetTextInputManager()->GetTextInputState()->can_compose_inline; |
+ return true; |
} |
gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen( |
@@ -2390,6 +2379,12 @@ RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { |
// be set to NULL. |
DCHECK(!legacy_render_widget_host_HWND_); |
#endif |
+ // We will ask the TextInputManager to unregister this view in the dtor or |
+ // RenderWidgetHostViewBase. Therefore, |
+ // if this view is still being tracked by TextInputManager, then we are also |
+ // observing the TextInputManager. |
+ if (GetTextInputManager() && GetTextInputManager()->IsRegisteredView(this)) |
+ GetTextInputManager()->RemoveObserver(this); |
EhsanK
2016/05/06 18:23:43
We need to remove the observer here. If not, the R
|
} |
void RenderWidgetHostViewAura::CreateAuraWindow() { |
@@ -2953,6 +2948,24 @@ cc::SurfaceId RenderWidgetHostViewAura::SurfaceIdForTesting() const { |
return delegated_frame_host_->SurfaceIdForTesting(); |
} |
+void RenderWidgetHostViewAura::OnTextInputStateUpdated( |
+ TextInputManager* text_input_manager, |
+ RenderWidgetHostViewBase* updated_view, |
+ bool changed) { |
+ DCHECK(GetTextInputManager() == text_input_manager); |
+ if (!GetInputMethod()) |
+ return; |
+ |
+ if (changed) |
+ GetInputMethod()->OnTextInputTypeChanged(this); |
+ |
+ const TextInputState* state = GetTextInputManager()->GetTextInputState(); |
+ |
+ if (state && state->show_ime_if_needed && |
+ state->type != ui::TEXT_INPUT_TYPE_NONE) |
+ GetInputMethod()->ShowImeIfNeeded(); |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// RenderWidgetHostViewBase, public: |