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
fix: normalize behavior of win.setOpacity()
for invalid number values across operating systems
#19535
Conversation
win.setOpacity()
for invalid number valueswin.setOpacity()
for invalid number values across OSes
win.setOpacity()
for invalid number values across OSeswin.setOpacity()
for invalid number values across operating systems
win.setOpacity()
for invalid number values across operating systemswin.setOpacity()
for invalid number values across operating systems
Co-Authored-By: Charles Kerr <ckerr@github.com>
…/electron/electron into intern/set-opacity-beyond-bounds
036a33c
to
db9cefd
Compare
I was unable to backport this PR to "5-0-x" cleanly; |
@erickzhao can you please handle these manual backports when you have a moment? |
…es across operating systems (#19535) * fix: define behavior for out-of-bounds setOpacity * fix linux issue * fix getOpacity behaviour * wrong variable * normalize more stuff * docs * test: use ifdescribe helper * Update spec-main/api-browser-window-spec.ts Co-Authored-By: Charles Kerr <ckerr@github.com> * fixes * more tests!!! * Update shell/browser/native_window_views.cc Co-Authored-By: Charles Kerr <ckerr@github.com> * Update shell/browser/native_window_mac.mm Co-Authored-By: Charles Kerr <ckerr@github.com>
A maintainer has manually backported this PR to "7-0-x", please check out #19673 |
A maintainer has manually backported this PR to "6-0-x", please check out #19723 |
A maintainer has manually backported this PR to "5-0-x", please check out #19724 |
Description of Change
Small fix to normalize behavior for invalid values for the
win.setOpacity()
.For example:
win.setOpacity(100)
orwin.setOpacity(-100)
.Current behavior with invalid values
Windows:
win.setOpacity(opacity)
: supposed to normalize the [0,1] opacity values to 255. However, for invalid values, passing inopacity * 255
leads to unexpected behavior.win.getOpacity()
: retrieves the invalidopacity
value that was previously passed in.macOS:
win.setOpacity(opacity)
: bounds opacity value to the [0,1] range (i.e.(opacity < 0) -> (opacity = 0)
and(opacity > 1) -> (opacity = 1)
)win.getOpacity()
: retrieves the invalidopacity
value that was previously passed in.Linux (unsupported):
win.setOpacity(opacity)
: takes no action on the actual window opacity, but stores theopacity
value.win.getOpacity()
: retrieves the previously storedopacity
value.Proposed behavior
win.setOpacity(opacity)
: bounds opacity value to the [0,1] rangewin.getOpacity()
: retrieves the bounded opacity value.win.setOpacity(opacity)
: takes no action.win.getOpacity()
: always returns 1.Checklist
npm test
passesRelease Notes
Notes: Normalized out-of-bound value behavior for the
setOpacity()
API inBrowserWindow
.