-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
feat: add webPreferences.enablePreferredSizeMode #25874
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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.
This is pretty nice.
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::EnablePreferredSizeMode
exists 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 test
passesRelease Notes
Notes: Added
webPreferences.preferredSizeMode
to allow sizing views according to their document's minimum size.