Skip to content

feat: enable innerWidth and innerHeight for window open#46749

Merged
jkleinsc merged 8 commits intomainfrom
enable-window-open-inner-separate
May 9, 2025
Merged

feat: enable innerWidth and innerHeight for window open#46749
jkleinsc merged 8 commits intomainfrom
enable-window-open-inner-separate

Conversation

@mlaurencin
Copy link
Copy Markdown
Member

@mlaurencin mlaurencin commented Apr 23, 2025

Description of Change

Closes #45816

Previously, our implementation of window.open did not allow for innerWidth and innerHeight as available options for the window.open features string. As per the spec, these options should be available and should also be equivalent to setting the width and height options: https://developer.mozilla.org/en-US/docs/Web/API/Window/open#width

This PR specifically adds in the innerWidth and innerHeight options to set the innerWidth and innerHeight of the window respectively. A follow-up PR will be required to make the width and height options match this functionality, as this will be a breaking change (they currently equate to setting outerWidth and outerHeight respectively).

Checklist

Release Notes

Notes: added innerWidth and innerHeight options for window.open

@mlaurencin mlaurencin added semver/patch backwards-compatible bug fixes target/34-x-y PR should also be added to the "34-x-y" branch. target/35-x-y PR should also be added to the "35-x-y" branch. target/36-x-y PR should also be added to the "36-x-y" branch. labels Apr 23, 2025
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Apr 23, 2025
@mlaurencin mlaurencin changed the title enable innerWidth and innerHeight for window open feat: enable innerWidth and innerHeight for window open Apr 23, 2025
@mlaurencin mlaurencin force-pushed the enable-window-open-inner-separate branch from 612bdf6 to 6b01c06 Compare April 24, 2025 15:01
Comment on lines +301 to +304
if (inner_width)
width = (inner_width < 100) ? 100 : inner_width;
if (inner_height)
height = (inner_height < 100) ? 100 : inner_height;
Copy link
Copy Markdown
Member

@ckerr ckerr Apr 24, 2025

Choose a reason for hiding this comment

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

  1. Better to use foo = std::max(100, inner_foo) here

  2. We're still allowing a value of <100 to be inherited from either width or height via options::kWidth. Is that OK?

  3. Maybe we should update the docs to point out that a minimum of 100 is required?

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.

It's also not clear to me why 100 is being used here?

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.

@codebytere it's in the spec:

https://developer.mozilla.org/en-US/docs/Web/API/Window/open#width

Specifies the width of the content area, including scrollbars. The minimum required value is 100.

But you're right, that's not clear unless one reads the spec or this thread. Maybe a symbolic constant name could be used to make it clearer, e.g.

constexpr int kMinSizeReqdBySpec = 100;

Copy link
Copy Markdown
Member

@codebytere codebytere Apr 25, 2025

Choose a reason for hiding this comment

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

ah cool - ty! perhaps a comment with spec link?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think since this is supposed to be inline with the window.open spec, our docs do not need to also state that it adheres to this requirement specifically. Although, I think linking to the spec in the code is helpful to understand what might seem like an arbitrary value at first glance.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Apr 24, 2025
@github-actions github-actions bot added the target/37-x-y PR should also be added to the "37-x-y" branch. label Apr 29, 2025
@jkleinsc jkleinsc dismissed MarshallOfSound’s stale review May 9, 2025 16:03

requested changes have been made

@jkleinsc jkleinsc merged commit b9f0aeb into main May 9, 2025
58 checks passed
@jkleinsc jkleinsc deleted the enable-window-open-inner-separate branch May 9, 2025 16:03
trop bot added a commit that referenced this pull request May 9, 2025
* feat: enable innerWidth and innerHeight for window open

* update comment for added special innerWidth and innerHeight

* update 100 min spec requirement handling

* update testing to include getContentSize

* update macOS min requirement handling

* adjust refactored consts

* update const values from nativewindowviews

Co-authored-by: Michaela Laurencin <35157522+mlaurencin@users.noreply.github.com>
@trop trop bot removed the target/34-x-y PR should also be added to the "34-x-y" branch. label May 9, 2025
trop bot added a commit that referenced this pull request May 9, 2025
* feat: enable innerWidth and innerHeight for window open

* update comment for added special innerWidth and innerHeight

* update 100 min spec requirement handling

* update testing to include getContentSize

* update macOS min requirement handling

* adjust refactored consts

* update const values from nativewindowviews

Co-authored-by: Michaela Laurencin <35157522+mlaurencin@users.noreply.github.com>
@trop trop bot added needs-manual-bp/34-x-y and removed target/35-x-y PR should also be added to the "35-x-y" branch. labels May 9, 2025
@trop
Copy link
Copy Markdown
Contributor

trop bot commented May 9, 2025

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

@trop
Copy link
Copy Markdown
Contributor

trop bot commented May 9, 2025

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

@trop trop bot added in-flight/36-x-y in-flight/37-x-y and removed target/36-x-y PR should also be added to the "36-x-y" branch. target/37-x-y PR should also be added to the "37-x-y" branch. labels May 9, 2025
mlaurencin added a commit that referenced this pull request May 9, 2025
* feat: enable innerWidth and innerHeight for window open

* update comment for added special innerWidth and innerHeight

* update 100 min spec requirement handling

* update testing to include getContentSize

* update macOS min requirement handling

* adjust refactored consts

* update const values from nativewindowviews
@trop
Copy link
Copy Markdown
Contributor

trop bot commented May 9, 2025

@mlaurencin has manually backported this PR to "35-x-y", please check out #47045

ckerr pushed a commit that referenced this pull request May 14, 2025
feat: enable innerWidth and innerHeight for window open (#46749)

* feat: enable innerWidth and innerHeight for window open

* update comment for added special innerWidth and innerHeight

* update 100 min spec requirement handling

* update testing to include getContentSize

* update macOS min requirement handling

* adjust refactored consts

* update const values from nativewindowviews

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Michaela Laurencin <35157522+mlaurencin@users.noreply.github.com>
@trop trop bot added merged/37-x-y PR was merged to the "37-x-y" branch. and removed in-flight/37-x-y labels May 14, 2025
VerteDinde pushed a commit that referenced this pull request May 15, 2025
)

* feat: enable innerWidth and innerHeight for window open

* update comment for added special innerWidth and innerHeight

* update 100 min spec requirement handling

* update testing to include getContentSize

* update macOS min requirement handling

* adjust refactored consts

* update const values from nativewindowviews
@trop trop bot added merged/35-x-y PR was merged to the "35-x-y" branch. and removed in-flight/35-x-y labels May 15, 2025
VerteDinde pushed a commit that referenced this pull request May 15, 2025
feat: enable innerWidth and innerHeight for window open (#46749)

* feat: enable innerWidth and innerHeight for window open

* update comment for added special innerWidth and innerHeight

* update 100 min spec requirement handling

* update testing to include getContentSize

* update macOS min requirement handling

* adjust refactored consts

* update const values from nativewindowviews

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Michaela Laurencin <35157522+mlaurencin@users.noreply.github.com>
@trop trop bot added merged/36-x-y PR was merged to the "36-x-y" branch. and removed in-flight/36-x-y labels May 15, 2025
kigh-ota pushed a commit to kigh-ota/electron that referenced this pull request Sep 30, 2025
* feat: enable innerWidth and innerHeight for window open

* update comment for added special innerWidth and innerHeight

* update 100 min spec requirement handling

* update testing to include getContentSize

* update macOS min requirement handling

* adjust refactored consts

* update const values from nativewindowviews
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/35-x-y PR was merged to the "35-x-y" branch. merged/36-x-y PR was merged to the "36-x-y" branch. merged/37-x-y PR was merged to the "37-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

window.open does not honor innerHeight and innerWidth in feature list

5 participants