Skip to content

fix: persist BrowserView content bounds when calculating layout - #32747

Merged
zcbenz merged 1 commit into
electron:mainfrom
andreasdj:fix-persist-browserview-contentbounds
Mar 23, 2022
Merged

zcbenz merged 1 commit into
electron:mainfrom
andreasdj:fix-persist-browserview-contentbounds

Conversation

@andreasdj

Copy link
Copy Markdown
Contributor

Description of Change

Closes: #31513

This PR reverts the change introduced in PR: #30510, to persist the content bounds of a BrowserView when it goes outside it's parent window. For background reference to see why this change was done, see: #29778.

The reason for this PR and why we think it's a reasonable change to do is the following:

  • We want to have an option to shift a BrowserView to go outside of it's parent window without having the framework limiting it's bounds, which we had before.
  • If the color issue can be solved by making sure a BrowserView is inside it's parent window, we would prefer to let the application developer solve this and still allow to have a choice to move a BrowserView outside of it's parent bounds.
  • The color issue isn't solved with the introduced change (see: [Bug]: Setting the BackgroundColor to the BrowserView doesn't work on Windows #30700).

Checklist

Release Notes

Notes: Fixed an issue where BrowserView layout bounds where limited to it's visible bounds.

@welcome

welcome Bot commented Feb 4, 2022

Copy link
Copy Markdown

💖 Thanks for opening this pull request! 💖

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Feb 4, 2022
@nornagon
nornagon requested a review from codebytere February 4, 2022 19:52
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Feb 11, 2022
@andreasdj

Copy link
Copy Markdown
Contributor Author

Hi @nornagon, @codebytere! We understand that you are busy, and we really appreciate the hard work you put into this framework. Can we help you out in any way to get this PR moving?

We are currently stuck with electron version 13.2.1 and we really want to be able to upgrade to the latest version but this is blocking us.

The other option of doing what's been done in this PR, would be to introduce a setting for controlling the behavior when a BrowserView extends outside of a parent BrowserWindow. We don't want to spend time on that without getting some kind of feedback from you in regards to the issue though.

All the best! :)

@nornagon

nornagon commented Mar 17, 2022 •

Copy link
Copy Markdown
Contributor

I'm not sure I understand why the background color and the content bounds are linked? Is there a tldr on that anywhere?

Background color shenanigans notwithstanding, this PR seems correct to me.

@andreasdj

Copy link
Copy Markdown
Contributor Author

When testing the behavior of the rendering with the gist that has been referenced in many of the issues/PR:s related to the background color changes I see the same behavior in rendering independent of this change.

Gist: https://gist.github.com/ddramone/712a2fde2757736c9dbf6c3e7e0aa18b.
Updated gist: https://gist.github.com/andreasdj/f33865f96f621d3695bf902e564aca4d (adds the BrowserViews on the main window 'ready-to-show' event to always have them rendered).

Electron 17.1.2 (using Electron Fiddle):
Electron Fiddle 17_2

Electron 18.0.0-nightly.20220201 (using the build output of the current branch):
Custom Electron Nightly 20220201

@codebytere codebytere left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm @andreasdj it appears to have regressed again via Chromium update. Let's fix this for now and look into a better solution for the initial issue.

@codebytere codebytere added semver/patch backwards-compatible bug fixes target/17-x-y labels Mar 21, 2022
@andreasdj

Copy link
Copy Markdown
Contributor Author

Perfect @codebytere! I've always found that particular example a bit odd in the way the background color is set for the BrowserView.

It seems like a background color set on a page would take precedence so why not just set the background color on the rendered web page directly. If you are missing control over the page you could still do it using webContents.setCSS or with a preload script. I tested to set a half transparent background color on the BrowserView that's shifted outside of the view using webContents.setCSS and it worked nicely so at least there are a couple a ways to solve that issue.
Custom Electron Nightly 20220201 with half transparent background

Sorry for drifting away, keep up the good work!

@zcbenz
zcbenz merged commit 3744ac0 into electron:main Mar 23, 2022
@welcome

welcome Bot commented Mar 23, 2022

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

@release-clerk

release-clerk Bot commented Mar 23, 2022

Copy link
Copy Markdown

Release Notes Persisted

Fixed an issue where BrowserView layout bounds where limited to it's visible bounds.

@trop

trop Bot commented Mar 23, 2022

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "17-x-y", please check out #33398

@trop

trop Bot commented Mar 23, 2022

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "18-x-y", please check out #33399

bavulapati pushed a commit to bavulapati/electron that referenced this pull request Apr 29, 2022
khalwa pushed a commit to solarwindscloud/electron that referenced this pull request Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: BrowserView content bounds are incorrectly resized

4 participants