Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_base.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc |
| index 780ced5af6016c192761f09227148b61bae5ff28..a0cbf9df77fcdd5ef22ebd27bb20e6b5be0548a8 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_base.cc |
| +++ b/content/browser/renderer_host/render_widget_host_view_base.cc |
| @@ -7,12 +7,17 @@ |
| #include "base/logging.h" |
| #include "build/build_config.h" |
| #include "content/browser/accessibility/browser_accessibility_manager.h" |
| +#include "content/browser/frame_host/frame_tree.h" |
| #include "content/browser/gpu/gpu_data_manager_impl.h" |
| #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" |
| #include "content/browser/renderer_host/render_process_host_impl.h" |
| +#include "content/browser/renderer_host/render_view_host_delegate.h" |
| +#include "content/browser/renderer_host/render_view_host_impl.h" |
| #include "content/browser/renderer_host/render_widget_host_impl.h" |
| #include "content/common/content_switches_internal.h" |
| +#include "content/common/view_messages.h" |
| #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| +#include "content/public/common/browser_plugin_guest_mode.h" |
| #include "ui/gfx/display.h" |
| #include "ui/gfx/geometry/point_conversions.h" |
| #include "ui/gfx/geometry/size_conversions.h" |
| @@ -377,7 +382,11 @@ RenderWidgetHostViewBase::RenderWidgetHostViewBase() |
| current_display_rotation_(gfx::Display::ROTATE_0), |
| pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), |
| renderer_frame_number_(0), |
| + text_input_state_(new TextInputState), |
| + cached_text_input_state_(text_input_state_.get()), |
| + focused_guest_rwhv_(nullptr), |
| weak_factory_(this) { |
| + text_input_state_->can_compose_inline = true; |
| } |
| RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { |
| @@ -547,6 +556,20 @@ bool RenderWidgetHostViewBase::HasDisplayPropertyChanged(gfx::NativeView view) { |
| return true; |
| } |
| +RenderFrameHostImpl* RenderWidgetHostViewBase::GetFocusedFrame() const { |
| + RenderViewHost* rvh = |
| + RenderViewHost::From(RenderWidgetHostImpl::From(GetRenderWidgetHost())); |
| + if (!rvh) |
| + return nullptr; |
| + |
| + FrameTreeNode* focused_frame = |
| + rvh->GetDelegate()->GetFrameTree()->GetFocusedFrame(); |
| + if (!focused_frame) |
| + return nullptr; |
| + |
| + return focused_frame->current_frame_host(); |
| +} |
| + |
| base::WeakPtr<RenderWidgetHostViewBase> RenderWidgetHostViewBase::GetWeakPtr() { |
| return weak_factory_.GetWeakPtr(); |
| } |
| @@ -701,4 +724,64 @@ void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace( |
| *transformed_point = point; |
| } |
| +void RenderWidgetHostViewBase::TextInputStateChanged( |
| + const ViewHostMsg_TextInputState_Params& params) { |
| + if (text_input_state_->type != params.type || |
| +#ifndef OS_MACOSX |
| + text_input_state_->mode != params.mode || |
| + text_input_state_->flags != params.flags || |
| +#endif |
| + text_input_state_->can_compose_inline != params.can_compose_inline) { |
| + *text_input_state_ = params; |
| + NotifyTextInputStateChanged(); |
| + } |
| +} |
| + |
| +const TextInputState* RenderWidgetHostViewBase::FindCurrentTextInputState() { |
| + if (!ShouldObtainTextInputStateFromSubFrameViews()) |
|
kenrb
2016/02/01 20:12:43
Why is this needed? Can't you just compare GetFocu
EhsanK
2016/02/12 15:46:59
Good point! I removed this part and all other code
|
| + return text_input_state_.get(); |
| + |
| + // TODO(ekaramad): This is for out of process contents based on BrowserPlugin. |
| + // Remove this block when BrowserPlugin is removed. |
| + if (!BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) |
| + if (focused_guest_rwhv_) |
| + return focused_guest_rwhv_->current_text_input_state(); |
| + |
| + const TextInputState* state = text_input_state_.get(); |
| + RenderFrameHostImpl* rfhi = GetFocusedFrame(); |
| + // TODO(ekaramd): Remove the RVH part when it goes away. |
| + if (rfhi) { |
| + RenderWidgetHostViewBase* focused_view = nullptr; |
| + if (rfhi->GetRenderWidgetHost()) |
| + focused_view = rfhi->GetRenderWidgetHost()->GetView(); |
| + else if (rfhi->GetRenderViewHost()) |
| + focused_view = |
| + RenderWidgetHostImpl::From(rfhi->GetRenderViewHost()->GetWidget()) |
| + ->GetView(); |
| + if (focused_view && focused_view != this) { |
| + DCHECK(!focused_view->ShouldObtainTextInputStateFromSubFrameViews()); |
| + state = focused_view->FindCurrentTextInputState(); |
| + } |
| + } |
| + return state; |
| +} |
| + |
| +void RenderWidgetHostViewBase::NotifyGuestTextInputStateChanged( |
| + RenderWidgetHostViewBase* guest_rwhv) { |
| + if (guest_rwhv->current_text_input_state()->type != ui::TEXT_INPUT_TYPE_NONE) |
| + focused_guest_rwhv_ = guest_rwhv; |
| + else if (focused_guest_rwhv_ == guest_rwhv) |
| + focused_guest_rwhv_ = nullptr; |
| + NotifyTextInputStateChanged(); |
| +} |
| + |
| +void RenderWidgetHostViewBase::NotifyTextInputStateChanged() { |
|
kenrb
2016/02/01 20:12:43
Does this need to be called when the focused frame
EhsanK
2016/02/12 15:46:59
This is called whenever after a ViewHostMsg_TextIn
|
| + cached_text_input_state_ = FindCurrentTextInputState(); |
| +} |
| + |
| +bool RenderWidgetHostViewBase::ShouldObtainTextInputStateFromSubFrameViews() |
| +const { |
| + return true; |
| +} |
| + |
| } // namespace content |