Repository navigation
feat: add webPreferences.enablePreferredSizeMode - #25874
Conversation
Depends on changes in electron/electron#25873 and electron/electron#25874
| auto* web_preferences = WebContentsPreferences::From(web_contents()); | ||
| if (web_preferences && | ||
| web_preferences->IsEnabled(options::kPreferredSizeMode)) | ||
| web_contents()->GetRenderViewHost()->EnablePreferredSizeMode(); |
There was a problem hiding this comment.
The location for calling this is based on Chromium's implementation: https://source.chromium.org/chromium/chromium/src/+/master:components/guest_view/browser/guest_view_base.cc;l=573;drc=d1252b1460e53a48e235c3bd9555bf5926c49100
|
Great job! Could this be backported to 9-x-y? |
At the will of @electron/wg-releases, probably. I'd like to target |
|
linux CI failure seems unrelated: |
|
The API WG approved this at our Oct 19 2020 meeting. |
|
Release Notes Persisted
|
|
@codebytere oof, I just realized the notes were not updated to reflect the renamed API. It should be |
…ectron#78) * feat: add preferredSizeMode preference * docs: webPreferences.preferredSizeMode and event * docs: better explain preferred size * docs: small improvement * refactor: preferredSizeMode -> enablePreferredSizeMode
Description of Change
For Chrome extension popups and options windows, the size of their frame corresponds to the minimum size of their document's layout. To enable this,
RenderViewHost::EnablePreferredSizeModeexists to notify the RenderView to send back updates with its size. This gives an interesting result where the document can dictate its frame's size.In practice, it looks like this:

Example code:
I could see this being useful for specialized modal popups as well.
cc @electron/wg-api -- Question for you: is it worth adding tests for just adding bindings to existing Chromium functionality?
relates to #19447
Checklist
npm testpassesRelease Notes
Notes: Added
webPreferences.preferredSizeModeto allow sizing views according to their document's minimum size.