Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_mac.mm |
| diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm |
| index 139d3b6ce10d89662b90ee90c1d8217a640b3699..1ce81f226613dd1eabbf473423eb84b8405b1a52 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_mac.mm |
| +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm |
| @@ -483,8 +483,6 @@ void RenderWidgetHostViewBase::GetDefaultScreenInfo( |
| RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, |
| bool is_guest_view_hack) |
| : render_widget_host_(RenderWidgetHostImpl::From(widget)), |
| - text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| - can_compose_inline_(true), |
| page_at_minimum_scale_(true), |
| is_loading_(false), |
| allow_pause_for_resize_or_repaint_(true), |
| @@ -529,6 +527,9 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, |
| // first to rebaseline some unreliable layout tests. |
| ignore_result(rvh->GetWebkitPreferences()); |
| } |
| + |
| + if (GetTextInputManager()) |
| + GetTextInputManager()->AddObserver(this); |
| } |
| RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { |
| @@ -567,6 +568,12 @@ cc::SurfaceId RenderWidgetHostViewMac::SurfaceIdForTesting() const { |
| return browser_compositor_->GetDelegatedFrameHost()->SurfaceIdForTesting(); |
| } |
| +ui::TextInputType RenderWidgetHostViewMac::GetTextInputType() { |
| + if (!GetTextInputManager() || !GetTextInputManager()->GetActiveWidget()) |
| + return ui::TEXT_INPUT_TYPE_NONE; |
| + return GetTextInputManager()->GetTextInputState()->type; |
| +} |
| + |
| /////////////////////////////////////////////////////////////////////////////// |
| // RenderWidgetHostViewMac, RenderWidgetHostView implementation: |
| @@ -883,24 +890,28 @@ void RenderWidgetHostViewMac::SetIsLoading(bool is_loading) { |
| // like Chrome does on Windows, call |UpdateCursor()| here. |
| } |
| -void RenderWidgetHostViewMac::TextInputStateChanged( |
| - const TextInputState& params) { |
| - if (text_input_type_ != params.type |
| - || can_compose_inline_ != params.can_compose_inline) { |
| - text_input_type_ = params.type; |
| - can_compose_inline_ = params.can_compose_inline; |
| - if (HasFocus()) { |
| - SetTextInputActive(true); |
| +void RenderWidgetHostViewMac::OnUpdateTextInputStateCalled( |
| + TextInputManager* text_input_manager, |
| + RenderWidgetHostViewBase* updated_view, |
| + bool did_update_state) { |
| + if (!did_update_state) |
| + return; |
| - // Let AppKit cache the new input context to make IMEs happy. |
| - // See http://crbug.com/73039. |
| - [NSApp updateWindows]; |
| + if (HasFocus()) { |
| + SetTextInputActive(true); |
| + |
| + // Let AppKit cache the new input context to make IMEs happy. |
| + // See http://crbug.com/73039. |
| + [NSApp updateWindows]; |
| #ifndef __LP64__ |
| - UseInputWindow(TSMGetActiveDocument(), !can_compose_inline_); |
| + bool can_compose_inline = |
| + !!GetTextInputManager()->GetActiveWidget() |
| + ? GetTextInputManager()->GetTextInputState()->can_compose_inline |
| + : true; |
| + UseInputWindow(TSMGetActiveDocument(), !can_compose_inline); |
| #endif |
| } |
|
kenrb
2016/07/21 21:48:16
This closing brace is indented too far.
EhsanK
2016/07/25 17:12:02
Acknowledged.
|
| - } |
| } |
| void RenderWidgetHostViewMac::ImeCancelComposition() { |
| @@ -956,6 +967,9 @@ void RenderWidgetHostViewMac::Destroy() { |
| // we release render_widget_host_. |
| NotifyObserversAboutShutdown(); |
| + if (text_input_manager_) |
| + text_input_manager_->RemoveObserver(this); |
| + |
| // We get this call just before |render_widget_host_| deletes |
| // itself. But we are owned by |cocoa_view_|, which may be retained |
| // by some other code. Examples are WebContentsViewMac's |
| @@ -1547,12 +1561,12 @@ gfx::Point RenderWidgetHostViewMac::AccessibilityOriginInScreen( |
| void RenderWidgetHostViewMac::SetTextInputActive(bool active) { |
| if (active) { |
| - if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD) |
| + if (GetTextInputType() == ui::TEXT_INPUT_TYPE_PASSWORD) |
| EnablePasswordInput(); |
| else |
| DisablePasswordInput(); |
| } else { |
| - if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD) |
| + if (GetTextInputType() == ui::TEXT_INPUT_TYPE_PASSWORD) |
| DisablePasswordInput(); |
| } |
| } |
| @@ -2895,7 +2909,7 @@ extern NSString *NSTextInputReplacementRangeAttributeName; |
| // nil when the caret is in non-editable content or password box to avoid |
| // making input methods do their work. |
| - (NSTextInputContext *)inputContext { |
| - switch(renderWidgetHostView_->text_input_type_) { |
| + switch (renderWidgetHostView_->GetTextInputType()) { |
| case ui::TEXT_INPUT_TYPE_NONE: |
| case ui::TEXT_INPUT_TYPE_PASSWORD: |
| return nil; |
| @@ -3172,7 +3186,7 @@ extern NSString *NSTextInputReplacementRangeAttributeName; |
| BOOL returnTypeIsString = [returnType isEqual:NSStringPboardType]; |
| BOOL hasText = !renderWidgetHostView_->selected_text().empty(); |
| BOOL takesText = |
| - renderWidgetHostView_->text_input_type_ != ui::TEXT_INPUT_TYPE_NONE; |
| + renderWidgetHostView_->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE; |
| if (sendTypeIsString && hasText && !returnType) { |
| requestor = self; |