From c82ef82c2105b22004c338176252f0e1534a9045 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 15 Feb 2017 16:03:00 -0500 Subject: [PATCH] Fix OSR popup transparency (issue #2099) --- libcef/browser/osr/browser_platform_delegate_osr.cc | 2 +- libcef/browser/osr/web_contents_view_osr.cc | 7 ++++++- libcef/browser/osr/web_contents_view_osr.h | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libcef/browser/osr/browser_platform_delegate_osr.cc b/libcef/browser/osr/browser_platform_delegate_osr.cc index 51d78a8ab..2cf44f6dc 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr.cc +++ b/libcef/browser/osr/browser_platform_delegate_osr.cc @@ -40,7 +40,7 @@ void CefBrowserPlatformDelegateOsr::WebContentsCreated( DCHECK(!view_osr_->web_contents()); // Associate the WebContents with the OSR view. - view_osr_->set_web_contents(web_contents); + view_osr_->WebContentsCreated(web_contents); } void CefBrowserPlatformDelegateOsr::BrowserCreated( diff --git a/libcef/browser/osr/web_contents_view_osr.cc b/libcef/browser/osr/web_contents_view_osr.cc index 2f8ba5876..05e82bf99 100644 --- a/libcef/browser/osr/web_contents_view_osr.cc +++ b/libcef/browser/osr/web_contents_view_osr.cc @@ -24,10 +24,13 @@ CefWebContentsViewOSR::CefWebContentsViewOSR(bool transparent) CefWebContentsViewOSR::~CefWebContentsViewOSR() { } -void CefWebContentsViewOSR::set_web_contents( +void CefWebContentsViewOSR::WebContentsCreated( content::WebContents* web_contents) { DCHECK(!web_contents_); web_contents_ = web_contents; + + // Call this again for popup browsers now that the view should exist. + RenderViewCreated(web_contents_->GetRenderViewHost()); } gfx::NativeView CefWebContentsViewOSR::GetNativeView() const { @@ -114,6 +117,8 @@ void CefWebContentsViewOSR::SetPageTitle(const base::string16& title) { } void CefWebContentsViewOSR::RenderViewCreated(content::RenderViewHost* host) { + // |view| will be nullptr the first time this method is called for popup + // browsers. CefRenderWidgetHostViewOSR* view = GetView(); if (view) view->InstallTransparency(); diff --git a/libcef/browser/osr/web_contents_view_osr.h b/libcef/browser/osr/web_contents_view_osr.h index d96fa33e3..cd7637fd3 100644 --- a/libcef/browser/osr/web_contents_view_osr.h +++ b/libcef/browser/osr/web_contents_view_osr.h @@ -25,7 +25,7 @@ class CefWebContentsViewOSR : public content::WebContentsView, explicit CefWebContentsViewOSR(bool transparent); ~CefWebContentsViewOSR() override; - void set_web_contents(content::WebContents* web_contents); + void WebContentsCreated(content::WebContents* web_contents); content::WebContents* web_contents() const { return web_contents_; } // WebContentsView methods.