diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 65fd843f508a..2b98b0840cd9 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -821,6 +821,10 @@ void WebContents::OnInterfaceRequestFromFrame( registry_.TryBindInterface(interface_name, interface_pipe, render_frame_host); } +void WebContents::DidAcquireFullscreen(content::RenderFrameHost* rfh) { + set_fullscreen_frame(rfh); +} + void WebContents::DocumentLoadedInFrame( content::RenderFrameHost* render_frame_host) { if (!render_frame_host->GetParent()) diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 9df39f1f03f3..60ad3d23faae 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -455,6 +455,7 @@ class WebContents : public mate::TrackableObject, content::RenderFrameHost* render_frame_host, const std::string& interface_name, mojo::ScopedMessagePipeHandle* interface_pipe) override; + void DidAcquireFullscreen(content::RenderFrameHost* rfh) override; // InspectableWebContentsDelegate: void DevToolsReloadPage() override; diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index 1163403cc752..9cbc07cee5f2 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -326,9 +326,12 @@ void CommonWebContentsDelegate::EnterFullscreenModeForTab( const blink::WebFullscreenOptions& options) { if (!owner_window_) return; + if (IsFullscreenForTabOrPending(source)) { + DCHECK_EQ(fullscreen_frame_, source->GetFocusedFrame()); + return; + } SetHtmlApiFullscreen(true); owner_window_->NotifyWindowEnterHtmlFullScreen(); - source->GetRenderViewHost()->GetWidget()->SynchronizeVisualProperties(); } void CommonWebContentsDelegate::ExitFullscreenModeForTab( @@ -337,7 +340,6 @@ void CommonWebContentsDelegate::ExitFullscreenModeForTab( return; SetHtmlApiFullscreen(false); owner_window_->NotifyWindowLeaveHtmlFullScreen(); - source->GetRenderViewHost()->GetWidget()->SynchronizeVisualProperties(); } bool CommonWebContentsDelegate::IsFullscreenForTabOrPending( diff --git a/atom/browser/common_web_contents_delegate.h b/atom/browser/common_web_contents_delegate.h index 1e194ac9b5af..a9ac315066b6 100644 --- a/atom/browser/common_web_contents_delegate.h +++ b/atom/browser/common_web_contents_delegate.h @@ -68,6 +68,10 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate, bool is_html_fullscreen() const { return html_fullscreen_; } + void set_fullscreen_frame(content::RenderFrameHost* rfh) { + fullscreen_frame_ = rfh; + } + protected: #if BUILDFLAG(ENABLE_OSR) virtual OffScreenWebContentsView* GetOffScreenWebContentsView() const; @@ -201,6 +205,9 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate, scoped_refptr file_task_runner_; + // Stores the frame thats currently in fullscreen, nullptr if there is none. + content::RenderFrameHost* fullscreen_frame_ = nullptr; + base::WeakPtrFactory weak_factory_; DISALLOW_COPY_AND_ASSIGN(CommonWebContentsDelegate);