Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: webview should maximize on requestFullscreen (#29989)
Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
- Loading branch information
Showing
8 changed files
with
127 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Cheng Zhao <zcbenz@gmail.com> | ||
Date: Thu, 4 Oct 2018 14:57:02 -0700 | ||
Subject: fix: also propagate fullscreen state for outer frame | ||
|
||
When entering fullscreen with Element.requestFullscreen in child frames, | ||
the parent frame should also enter fullscreen mode too. Chromium handles | ||
this for iframes, but not for webviews as they are essentially main | ||
frames instead of child frames. | ||
|
||
This patch makes webviews propagate the fullscreen state to embedder. | ||
|
||
Note that we also need to manually update embedder's | ||
`api::WebContents::IsFullscreenForTabOrPending` value. | ||
|
||
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc | ||
index 5c16a9ee9bbf461c24456613ff709f4f608e3441..4e4d1fdf50e2d480e099c9af71a45fc864d2cf56 100644 | ||
--- a/content/browser/renderer_host/render_frame_host_impl.cc | ||
+++ b/content/browser/renderer_host/render_frame_host_impl.cc | ||
@@ -5520,6 +5520,15 @@ void RenderFrameHostImpl::EnterFullscreen( | ||
notified_instances.insert(parent_site_instance); | ||
} | ||
|
||
+ // Entering fullscreen from webview should also notify its outer frame. | ||
+ if (frame_tree_node()->render_manager()->IsMainFrameForInnerDelegate()) { | ||
+ RenderFrameProxyHost* outer_proxy = | ||
+ frame_tree_node()->render_manager()->GetProxyToOuterDelegate(); | ||
+ DCHECK(outer_proxy); | ||
+ outer_proxy->GetAssociatedRemoteFrame()->WillEnterFullscreen( | ||
+ options.Clone()); | ||
+ } | ||
+ | ||
delegate_->EnterFullscreenMode(this, *options); | ||
delegate_->FullscreenStateChanged(this, true /* is_fullscreen */, | ||
std::move(options)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<body> | ||
<div id="div"> | ||
WebView | ||
</div> | ||
<script type="text/javascript" charset="utf-8"> | ||
const {ipcRenderer} = require('electron') | ||
ipcRenderer.send('webview-ready') | ||
document.addEventListener('fullscreenchange', () => { | ||
ipcRenderer.send('webview-fullscreenchange') | ||
}) | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<body> | ||
<webview id="webview" nodeintegration="on" webpreferences="contextIsolation=no" src="frame.html"/> | ||
<script type="text/javascript" charset="utf-8"> | ||
document.addEventListener('fullscreenchange', () => { | ||
require('electron').ipcRenderer.send('fullscreenchange') | ||
}) | ||
|
||
function isIframeFullscreen() { | ||
return document.getElementById('webview').shadowRoot.lastElementChild.matches(':fullscreen') | ||
} | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters