Chromium Code Reviews| Index: content/browser/web_contents/web_contents_view_android.cc |
| diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc |
| index e3b9d4ad53631b2a91caa1b4e1aa2bd54264310e..4be344ea3345a45efc6a9e535973ae98cbdb8b5a 100644 |
| --- a/content/browser/web_contents/web_contents_view_android.cc |
| +++ b/content/browser/web_contents/web_contents_view_android.cc |
| @@ -13,6 +13,7 @@ |
| #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| #include "content/browser/renderer_host/render_view_host_factory.h" |
| #include "content/browser/renderer_host/render_view_host_impl.h" |
| +#include "content/browser/web_contents/web_contents_android.h" |
| #include "content/browser/web_contents/web_contents_impl.h" |
| #include "content/public/browser/render_widget_host.h" |
| #include "content/public/browser/web_contents_delegate.h" |
| @@ -46,6 +47,18 @@ void WebContentsView::GetDefaultScreenInfo(ScreenInfo* results) { |
| results->is_monochrome = display.is_monochrome(); |
| } |
| +// static |
| +void SynchronousCompositor::SetClientForWebContents( |
| + WebContents* contents, |
| + SynchronousCompositorClient* client) { |
| + DCHECK(contents); |
| + DCHECK(client); |
| + WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( |
| + static_cast<WebContentsImpl*>(contents)->GetView()); |
| + DCHECK(!wcva->synchronous_compositor_client()); |
| + wcva->set_synchronous_compositor_client(client); |
| +} |
| + |
| WebContentsView* CreateWebContentsView( |
| WebContentsImpl* web_contents, |
| WebContentsViewDelegate* delegate, |
| @@ -61,7 +74,8 @@ WebContentsViewAndroid::WebContentsViewAndroid( |
| WebContentsViewDelegate* delegate) |
| : web_contents_(web_contents), |
| content_view_core_(NULL), |
| - delegate_(delegate) { |
| + delegate_(delegate), |
| + synchronous_compositor_client_(nullptr) { |
| } |
| WebContentsViewAndroid::~WebContentsViewAndroid() { |
| @@ -74,9 +88,10 @@ void WebContentsViewAndroid::SetContentViewCore( |
| content_view_core_ = content_view_core; |
| RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
| web_contents_->GetRenderWidgetHostView()); |
| - if (rwhv) |
| - rwhv->SetContentViewCore(content_view_core_); |
| - |
| + if (rwhv) { |
| + rwhv->SetContentViewCore(content_view_core); |
| + SetSynchronousCompositorClientFor(rwhv); |
|
boliu
2016/11/08 16:50:13
I don't think this needs to be tied to CVC events
Jinsuk Kim
2016/11/08 17:18:30
Good to know. Done.
|
| + } |
| if (web_contents_->ShowingInterstitialPage()) { |
| rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
| web_contents_->GetInterstitialPage() |
| @@ -84,11 +99,19 @@ void WebContentsViewAndroid::SetContentViewCore( |
| ->GetRenderViewHost() |
| ->GetWidget() |
| ->GetView()); |
| - if (rwhv) |
| - rwhv->SetContentViewCore(content_view_core_); |
| + if (rwhv) { |
| + rwhv->SetContentViewCore(content_view_core); |
| + SetSynchronousCompositorClientFor(rwhv); |
| + } |
| } |
| } |
| +void WebContentsViewAndroid::SetSynchronousCompositorClientFor( |
| + RenderWidgetHostViewAndroid* rwhv) { |
| + if (synchronous_compositor_client_) |
|
boliu
2016/11/08 16:50:13
no need for this check
Jinsuk Kim
2016/11/08 17:18:30
Done. Inlined now that it became just one liner.
|
| + rwhv->set_synchronous_compositor_client(synchronous_compositor_client_); |
| +} |
| + |
| gfx::NativeView WebContentsViewAndroid::GetNativeView() const { |
| return const_cast<gfx::NativeView>(&view_); |
| } |
| @@ -129,10 +152,15 @@ void WebContentsViewAndroid::SizeContents(const gfx::Size& size) { |
| } |
| void WebContentsViewAndroid::Focus() { |
| - if (web_contents_->ShowingInterstitialPage()) |
| + RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
|
boliu
2016/11/08 16:50:13
unrelated change
Jinsuk Kim
2016/11/08 17:18:30
Oops.. reverted.
|
| + web_contents_->GetRenderWidgetHostView()); |
| + if (web_contents_->ShowingInterstitialPage()) { |
| web_contents_->GetInterstitialPage()->Focus(); |
| - else |
| - web_contents_->GetRenderWidgetHostView()->Focus(); |
| + if (content_view_core_) |
| + content_view_core_->ForceUpdateImeAdapter(rwhv->GetNativeImeAdapter()); |
| + } else { |
| + rwhv->Focus(); |
| + } |
| } |
| void WebContentsViewAndroid::SetInitialFocus() { |