| Index: content/browser/renderer_host/ime_adapter_android.cc
|
| diff --git a/content/browser/renderer_host/ime_adapter_android.cc b/content/browser/renderer_host/ime_adapter_android.cc
|
| index 3a7d18b94da7ce41b8a4981e98e7d87b3eda70cc..0c852a3ef8436b47c5f37c577e5a6feaf345df1b 100644
|
| --- a/content/browser/renderer_host/ime_adapter_android.cc
|
| +++ b/content/browser/renderer_host/ime_adapter_android.cc
|
| @@ -14,11 +14,8 @@
|
| #include "base/android/scoped_java_ref.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/time/time.h"
|
| -#include "content/browser/frame_host/frame_tree.h"
|
| -#include "content/browser/frame_host/frame_tree_node.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_impl.h"
|
| #include "content/browser/renderer_host/render_widget_host_view_android.h"
|
| #include "content/common/input_messages.h"
|
| @@ -110,6 +107,7 @@ void AppendUnderlineSpan(JNIEnv*,
|
|
|
| ImeAdapterAndroid::ImeAdapterAndroid(RenderWidgetHostViewAndroid* rwhva)
|
| : rwhva_(rwhva) {
|
| + DCHECK(rwhva_);
|
| }
|
|
|
| ImeAdapterAndroid::~ImeAdapterAndroid() {
|
| @@ -142,7 +140,7 @@ void ImeAdapterAndroid::SetComposingText(JNIEnv* env,
|
| const JavaParamRef<jobject>& text,
|
| const JavaParamRef<jstring>& text_str,
|
| int relative_cursor_pos) {
|
| - RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl();
|
| + RenderWidgetHostImpl* rwhi = GetFocusedWidget();
|
| if (!rwhi)
|
| return;
|
|
|
| @@ -172,7 +170,7 @@ void ImeAdapterAndroid::CommitText(JNIEnv* env,
|
| const JavaParamRef<jobject>& text,
|
| const JavaParamRef<jstring>& text_str,
|
| int relative_cursor_pos) {
|
| - RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl();
|
| + RenderWidgetHostImpl* rwhi = GetFocusedWidget();
|
| if (!rwhi)
|
| return;
|
|
|
| @@ -195,7 +193,7 @@ void ImeAdapterAndroid::CommitText(JNIEnv* env,
|
|
|
| void ImeAdapterAndroid::FinishComposingText(JNIEnv* env,
|
| const JavaParamRef<jobject>&) {
|
| - RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl();
|
| + RenderWidgetHostImpl* rwhi = GetFocusedWidget();
|
| if (!rwhi)
|
| return;
|
|
|
| @@ -288,7 +286,7 @@ void ImeAdapterAndroid::DeleteSurroundingText(JNIEnv*,
|
| bool ImeAdapterAndroid::RequestTextInputStateUpdate(
|
| JNIEnv* env,
|
| const JavaParamRef<jobject>&) {
|
| - RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl();
|
| + RenderWidgetHostImpl* rwhi = GetFocusedWidget();
|
| if (!rwhi)
|
| return false;
|
| rwhi->Send(new InputMsg_RequestTextInputStateUpdate(rwhi->GetRoutingID()));
|
| @@ -300,7 +298,7 @@ void ImeAdapterAndroid::RequestCursorUpdate(
|
| const base::android::JavaParamRef<jobject>& obj,
|
| bool immediate_request,
|
| bool monitor_request) {
|
| - RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl();
|
| + RenderWidgetHostImpl* rwhi = GetFocusedWidget();
|
| if (!rwhi)
|
| return;
|
| rwhi->Send(new InputMsg_RequestCompositionUpdate(
|
| @@ -312,36 +310,25 @@ void ImeAdapterAndroid::ResetImeAdapter(JNIEnv* env,
|
| java_ime_adapter_.reset();
|
| }
|
|
|
| -RenderWidgetHostImpl* ImeAdapterAndroid::GetRenderWidgetHostImpl() {
|
| +RenderWidgetHostImpl* ImeAdapterAndroid::GetFocusedWidget() {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| - DCHECK(rwhva_);
|
| - RenderWidgetHost* rwh = rwhva_->GetRenderWidgetHost();
|
| - if (!rwh)
|
| - return nullptr;
|
| -
|
| - return RenderWidgetHostImpl::From(rwh);
|
| + return rwhva_->GetFocusedWidget();
|
| }
|
|
|
| RenderFrameHost* ImeAdapterAndroid::GetFocusedFrame() {
|
| - RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
|
| - if (!rwh)
|
| - return nullptr;
|
| - RenderViewHost* rvh = RenderViewHost::From(rwh);
|
| - if (!rvh)
|
| - return nullptr;
|
| - FrameTreeNode* focused_frame =
|
| - rvh->GetDelegate()->GetFrameTree()->GetFocusedFrame();
|
| - if (!focused_frame)
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| + // We get the focused frame from the WebContents of the page. Although
|
| + // |rwhva_->GetFocusedWidget()| does a similar thing, there is no direct way
|
| + // to get a RenderFrameHost from its RWH.
|
| + RenderWidgetHostImpl* rwh =
|
| + RenderWidgetHostImpl::From(rwhva_->GetRenderWidgetHost());
|
| + if (!rwh || !rwh->delegate())
|
| return nullptr;
|
|
|
| - return focused_frame->current_frame_host();
|
| -}
|
| + if (auto* contents = rwh->delegate()->GetAsWebContents())
|
| + return contents->GetFocusedFrame();
|
|
|
| -WebContents* ImeAdapterAndroid::GetWebContents() {
|
| - RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
|
| - if (!rwh)
|
| - return nullptr;
|
| - return WebContents::FromRenderViewHost(RenderViewHost::From(rwh));
|
| + return nullptr;
|
| }
|
|
|
| std::vector<blink::WebCompositionUnderline>
|
|
|