-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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 (#29987)
* fix: webview should maximize on requestFullscreen * chore: update patches Co-authored-by: Cheng Zhao <zcbenz@gmail.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
- Loading branch information
1 parent
ddc44e1
commit fc75bf0
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 59d855ec17efe9117ee9bca5074b1ab28dfb40fa..4af3384ebbd000926a1f7606511fd6b94dc8aabe 100644 | ||
--- a/content/browser/renderer_host/render_frame_host_impl.cc | ||
+++ b/content/browser/renderer_host/render_frame_host_impl.cc | ||
@@ -4844,6 +4844,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