fix: HTML fullscreen request for sub frames (#18736)

Don't re-enter fullscreen if there is a pending operation,
for subframe fullscreen request `EnterFullScreenModeForTab`
will be called for both the frame in question as well as
the outer webContents hosting it.
This commit is contained in:
Robo 2019-06-13 14:02:56 -07:00 committed by Shelley Vohr
parent 9856e5df3b
commit 5e320291b4
4 changed files with 16 additions and 2 deletions

View file

@ -821,6 +821,10 @@ void WebContents::OnInterfaceRequestFromFrame(
registry_.TryBindInterface(interface_name, interface_pipe, render_frame_host); registry_.TryBindInterface(interface_name, interface_pipe, render_frame_host);
} }
void WebContents::DidAcquireFullscreen(content::RenderFrameHost* rfh) {
set_fullscreen_frame(rfh);
}
void WebContents::DocumentLoadedInFrame( void WebContents::DocumentLoadedInFrame(
content::RenderFrameHost* render_frame_host) { content::RenderFrameHost* render_frame_host) {
if (!render_frame_host->GetParent()) if (!render_frame_host->GetParent())

View file

@ -455,6 +455,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
const std::string& interface_name, const std::string& interface_name,
mojo::ScopedMessagePipeHandle* interface_pipe) override; mojo::ScopedMessagePipeHandle* interface_pipe) override;
void DidAcquireFullscreen(content::RenderFrameHost* rfh) override;
// InspectableWebContentsDelegate: // InspectableWebContentsDelegate:
void DevToolsReloadPage() override; void DevToolsReloadPage() override;

View file

@ -326,9 +326,12 @@ void CommonWebContentsDelegate::EnterFullscreenModeForTab(
const blink::WebFullscreenOptions& options) { const blink::WebFullscreenOptions& options) {
if (!owner_window_) if (!owner_window_)
return; return;
if (IsFullscreenForTabOrPending(source)) {
DCHECK_EQ(fullscreen_frame_, source->GetFocusedFrame());
return;
}
SetHtmlApiFullscreen(true); SetHtmlApiFullscreen(true);
owner_window_->NotifyWindowEnterHtmlFullScreen(); owner_window_->NotifyWindowEnterHtmlFullScreen();
source->GetRenderViewHost()->GetWidget()->SynchronizeVisualProperties();
} }
void CommonWebContentsDelegate::ExitFullscreenModeForTab( void CommonWebContentsDelegate::ExitFullscreenModeForTab(
@ -337,7 +340,6 @@ void CommonWebContentsDelegate::ExitFullscreenModeForTab(
return; return;
SetHtmlApiFullscreen(false); SetHtmlApiFullscreen(false);
owner_window_->NotifyWindowLeaveHtmlFullScreen(); owner_window_->NotifyWindowLeaveHtmlFullScreen();
source->GetRenderViewHost()->GetWidget()->SynchronizeVisualProperties();
} }
bool CommonWebContentsDelegate::IsFullscreenForTabOrPending( bool CommonWebContentsDelegate::IsFullscreenForTabOrPending(

View file

@ -68,6 +68,10 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate,
bool is_html_fullscreen() const { return html_fullscreen_; } bool is_html_fullscreen() const { return html_fullscreen_; }
void set_fullscreen_frame(content::RenderFrameHost* rfh) {
fullscreen_frame_ = rfh;
}
protected: protected:
#if BUILDFLAG(ENABLE_OSR) #if BUILDFLAG(ENABLE_OSR)
virtual OffScreenWebContentsView* GetOffScreenWebContentsView() const; virtual OffScreenWebContentsView* GetOffScreenWebContentsView() const;
@ -201,6 +205,9 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate,
scoped_refptr<base::SequencedTaskRunner> file_task_runner_; scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
// Stores the frame thats currently in fullscreen, nullptr if there is none.
content::RenderFrameHost* fullscreen_frame_ = nullptr;
base::WeakPtrFactory<CommonWebContentsDelegate> weak_factory_; base::WeakPtrFactory<CommonWebContentsDelegate> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(CommonWebContentsDelegate); DISALLOW_COPY_AND_ASSIGN(CommonWebContentsDelegate);