Commit 799e6365 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

[Mac] Handle a child frame for TextInputClientMac

This CL fixes the problem that GetCharacterIndexAtPoint or
GetFirstRectForRange from TextInputClientMac couldn't handle a child
widget. When TextInputClientMac requests mojo calls for them, it
tries to find the focused frame but it couldn't handle a child widget
since it uses RenderViewHostImpl and RenderViewHostImpl is nullptr
when the widget's owner_delegate is empty. So, it introduces
GetFrameTree to RenderWidgetHostDelegate, gets FrameTree* through
the method, and finds the focused RenderFrameHostImpl using FrameTree.

Bug: 1094841, 1007365
Change-Id: I8da969886ef8d99347c09ae226bcbdeefc84ec0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2245450Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#781099}
parent 259c5525
...@@ -162,4 +162,8 @@ bool RenderWidgetHostDelegate::IsPortal() { ...@@ -162,4 +162,8 @@ bool RenderWidgetHostDelegate::IsPortal() {
return false; return false;
} }
FrameTree* RenderWidgetHostDelegate::GetFrameTree() {
return nullptr;
}
} // namespace content } // namespace content
...@@ -42,6 +42,7 @@ class Sample; ...@@ -42,6 +42,7 @@ class Sample;
namespace content { namespace content {
class BrowserAccessibilityManager; class BrowserAccessibilityManager;
class FrameTree;
class RenderFrameHostImpl; class RenderFrameHostImpl;
class RenderWidgetHostImpl; class RenderWidgetHostImpl;
class RenderWidgetHostInputEventRouter; class RenderWidgetHostInputEventRouter;
...@@ -338,6 +339,12 @@ class CONTENT_EXPORT RenderWidgetHostDelegate { ...@@ -338,6 +339,12 @@ class CONTENT_EXPORT RenderWidgetHostDelegate {
// Notify the delegate that the screen orientation has been changed. // Notify the delegate that the screen orientation has been changed.
virtual void DidChangeScreenOrientation() {} virtual void DidChangeScreenOrientation() {}
// Returns the FrameTree that this RenderWidgetHost is attached to. If the
// RenderWidgetHost is attached to a frame, then its RenderFrameHost will be
// in the tree. Otherwise, the RenderWidgetHost is for a popup which was
// opened by a frame in the FrameTree.
virtual FrameTree* GetFrameTree();
protected: protected:
virtual ~RenderWidgetHostDelegate() {} virtual ~RenderWidgetHostDelegate() {}
}; };
......
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
#include "content/browser/frame_host/frame_tree.h" #include "content/browser/frame_host/frame_tree.h"
#include "content/browser/frame_host/frame_tree_node.h" #include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/frame_host/render_frame_host_impl.h" #include "content/browser/frame_host/render_frame_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_delegate.h" #include "content/browser/renderer_host/render_widget_host_delegate.h"
#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/common/text_input_client_messages.h" #include "content/common/text_input_client_messages.h"
...@@ -52,15 +50,14 @@ bool IsFullScreenRenderWidget(RenderWidgetHost* widget) { ...@@ -52,15 +50,14 @@ bool IsFullScreenRenderWidget(RenderWidgetHost* widget) {
} }
RenderFrameHostImpl* GetFocusedRenderFrameHostImpl(RenderWidgetHost* widget) { RenderFrameHostImpl* GetFocusedRenderFrameHostImpl(RenderWidgetHost* widget) {
RenderViewHostImpl* rvhi = RenderViewHostImpl::From(widget); RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget);
if (!rvhi || !rvhi->GetDelegate()->GetFrameTree()) FrameTree* tree = rwhi->delegate()->GetFrameTree();
return nullptr; FrameTreeNode* focused_node = tree->GetFocusedFrame();
FrameTreeNode* frame_tree_node = return focused_node ? focused_node->current_frame_host() : nullptr;
rvhi->GetDelegate()->GetFrameTree()->GetFocusedFrame();
return frame_tree_node ? frame_tree_node->current_frame_host() : nullptr;
}
} }
} // namespace
// The amount of time in milliseconds that the browser process will wait for a // The amount of time in milliseconds that the browser process will wait for a
// response from the renderer. // response from the renderer.
// TODO(rsesek): Using the histogram data, find the best upper-bound for this // TODO(rsesek): Using the histogram data, find the best upper-bound for this
......
...@@ -924,6 +924,9 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents, ...@@ -924,6 +924,9 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
bool AddDomainInfoToRapporSample(rappor::Sample* sample) override; bool AddDomainInfoToRapporSample(rappor::Sample* sample) override;
bool IsShowingContextMenuOnPage() const override; bool IsShowingContextMenuOnPage() const override;
void DidChangeScreenOrientation() override; void DidChangeScreenOrientation() override;
// The following function is already listed under RenderViewHostDelegate
// overrides:
// FrameTree* GetFrameTree() override;
// RenderFrameHostManager::Delegate ------------------------------------------ // RenderFrameHostManager::Delegate ------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment