feat: add webPreferences.enablePreferredSizeMode (#25874)
* feat: add preferredSizeMode preference * docs: webPreferences.preferredSizeMode and event * docs: better explain preferred size * docs: small improvement * refactor: preferredSizeMode -> enablePreferredSizeMode
This commit is contained in:
parent
2aa5a1f494
commit
10a209ecba
7 changed files with 34 additions and 0 deletions
|
@ -1173,6 +1173,11 @@ void WebContents::DidStartLoading() {
|
|||
|
||||
void WebContents::DidStopLoading() {
|
||||
Emit("did-stop-loading");
|
||||
|
||||
auto* web_preferences = WebContentsPreferences::From(web_contents());
|
||||
if (web_preferences &&
|
||||
web_preferences->IsEnabled(options::kEnablePreferredSizeMode))
|
||||
web_contents()->GetRenderViewHost()->EnablePreferredSizeMode();
|
||||
}
|
||||
|
||||
bool WebContents::EmitNavigationEvent(
|
||||
|
@ -2903,6 +2908,11 @@ v8::Local<v8::Promise> WebContents::TakeHeapSnapshot(
|
|||
return handle;
|
||||
}
|
||||
|
||||
void WebContents::UpdatePreferredSize(content::WebContents* web_contents,
|
||||
const gfx::Size& pref_size) {
|
||||
Emit("preferred-size-changed", pref_size);
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::ObjectTemplate> WebContents::FillObjectTemplate(
|
||||
v8::Isolate* isolate,
|
||||
|
|
|
@ -551,6 +551,8 @@ class WebContents : public gin::Wrappable<WebContents>,
|
|||
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
|
||||
content::WebContents* source) override;
|
||||
void OnAudioStateChanged(bool audible) override;
|
||||
void UpdatePreferredSize(content::WebContents* web_contents,
|
||||
const gfx::Size& pref_size) override;
|
||||
|
||||
// content::WebContentsObserver:
|
||||
void BeforeUnloadFired(bool proceed,
|
||||
|
|
|
@ -143,6 +143,7 @@ WebContentsPreferences::WebContentsPreferences(
|
|||
SetDefaultBoolIfUndefined(options::kTextAreasAreResizable, true);
|
||||
SetDefaultBoolIfUndefined(options::kWebGL, true);
|
||||
SetDefaultBoolIfUndefined(options::kEnableWebSQL, true);
|
||||
SetDefaultBoolIfUndefined(options::kEnablePreferredSizeMode, false);
|
||||
bool webSecurity = true;
|
||||
SetDefaultBoolIfUndefined(options::kWebSecurity, webSecurity);
|
||||
// If webSecurity was explicitly set to false, let's inherit that into
|
||||
|
|
|
@ -191,6 +191,8 @@ const char kEnableRemoteModule[] = "enableRemoteModule";
|
|||
|
||||
const char kEnableWebSQL[] = "enableWebSQL";
|
||||
|
||||
const char kEnablePreferredSizeMode[] = "enablePreferredSizeMode";
|
||||
|
||||
} // namespace options
|
||||
|
||||
namespace switches {
|
||||
|
|
|
@ -87,6 +87,7 @@ extern const char kTextAreasAreResizable[];
|
|||
extern const char kWebGL[];
|
||||
extern const char kNavigateOnDragDrop[];
|
||||
extern const char kEnableWebSQL[];
|
||||
extern const char kEnablePreferredSizeMode[];
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
extern const char kSpellcheck[];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue