Skip to content

Commit 57eae3d

Browse files
Added WebContents.getPreferredSize()
1 parent ef4e122 commit 57eae3d

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

docs/api/web-contents.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,6 +1999,10 @@ This corresponds to the [animationPolicy][] accessibility feature in Chromium.
19991999

20002000
[animationPolicy]: https://developer.chrome.com/docs/extensions/reference/accessibilityFeatures/#property-animationPolicy
20012001

2002+
#### `contents.getPreferredSize()`
2003+
2004+
Returns [`Size`](structures/size.md) - The preferred size of the contents.
2005+
20022006
### Instance Properties
20032007

20042008
#### `contents.audioMuted`

shell/browser/api/electron_api_web_contents.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3430,6 +3430,10 @@ void WebContents::SetImageAnimationPolicy(const std::string& new_policy) {
34303430
web_contents()->OnWebPreferencesChanged();
34313431
}
34323432

3433+
gfx::Size WebContents::GetPreferredSize() {
3434+
return web_contents()->GetPreferredSize();
3435+
}
3436+
34333437
v8::Local<v8::Promise> WebContents::GetProcessMemoryInfo(v8::Isolate* isolate) {
34343438
gin_helper::Promise<gin_helper::Dictionary> promise(isolate);
34353439
v8::Local<v8::Promise> handle = promise.GetHandle();
@@ -4068,6 +4072,7 @@ v8::Local<v8::ObjectTemplate> WebContents::FillObjectTemplate(
40684072
.SetMethod("takeHeapSnapshot", &WebContents::TakeHeapSnapshot)
40694073
.SetMethod("setImageAnimationPolicy",
40704074
&WebContents::SetImageAnimationPolicy)
4075+
.SetMethod("getPreferredSize", &WebContents::GetPreferredSize)
40714076
.SetMethod("_getProcessMemoryInfo", &WebContents::GetProcessMemoryInfo)
40724077
.SetProperty("id", &WebContents::ID)
40734078
.SetProperty("session", &WebContents::Session)

shell/browser/api/electron_api_web_contents.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ class WebContents : public ExclusiveAccessContext,
434434
void DoGetZoomLevel(
435435
electron::mojom::ElectronBrowser::DoGetZoomLevelCallback callback);
436436
void SetImageAnimationPolicy(const std::string& new_policy);
437+
gfx::Size GetPreferredSize();
437438

438439
// Grants |origin| access to |device|.
439440
// To be used in place of ObjectPermissionContextBase::GrantObjectPermission.

0 commit comments

Comments
 (0)