New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: webview should maximize on requestFullscreen #29952
Conversation
|
||
Note that we also need to manually update embedder's | ||
`api::WebContents::IsFullscreenForTabOrPending` value. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this something we can potentially upstream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch itself is not enough to fix the issue, so we can not upstream it directly.
To fix the problem we also have to make the fullscreen state sync between the webview and its embedder frame, and in Electron we are just manually synchronizing the states. A decent patch should change callers or callees of IsFullscreenForTabOrPending
to be aware of outer frames (webviews), but it would require much more refactoring.
So I think it does not worth such efforts upstreaming the changes to Chromium, as very few people would encounter this problem in Chrome browser and the patch in this PR is very easy to maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still one issue, when you exit window fullscreen by clicking the green semaphore button on Mac, the webview's webContents does not exit HTML fullscreen mode. It works propertly for iframes.
I still need this workaround to make it work fully app.on('web-contents-created', (event, webContents) => {
webContents.on('enter-html-full-screen', () => {
if (webContents.getType() === 'webview') {
const window = webContents.getOwnerBrowserWindow();
window.once('leave-html-full-screen', () => {
webContents.executeJavaScript('document.exitFullscreen()', true);
});
}
});
}); |
cac2915
to
241117c
Compare
241117c
to
7adeee4
Compare
@miniak The mentioned problem should have been fixed, can you test again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it works now!
Release Notes Persisted
|
I have automatically backported this PR to "13-x-y", please check out #29987 |
I have automatically backported this PR to "12-x-y", please check out #29988 |
I have automatically backported this PR to "14-x-y", please check out #29989 |
Is there a way to prevent that behavior ? |
Description of Change
Close #27719.
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 the latter are essentially main frames instead of child frames.
This PR makes sure webviews propagate the fullscreen state to embedder.
Note that the patch itself in this PR is not enough to fix the issue, to fix it we have to make the fullscreen state sync between the webview and its embedder frame, and in Electron we are just manually synchronizing the states. A decent patch should change callers or callees of
IsFullscreenForTabOrPending
to be aware of outer frames (webviews), but it would require much more refactoring. I think it does not worth such efforts upstreaming the patch to Chromium, because very few people would encounter this problem in Chrome browser and the patch in this PR is very easy to maintain.Release Notes
Notes: Fix
requestFullscreen
inside webview does not make the element take fullscreen.