Skip to content
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

Merged
merged 14 commits into from Aug 7, 2019

Conversation

erickzhao
Copy link
Member

@erickzhao erickzhao commented Jul 30, 2019

Description of Change

Small fix to normalize behavior for invalid values for the win.setOpacity().

For example: win.setOpacity(100) or win.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 in opacity * 255 leads to unexpected behavior.
    • win.getOpacity(): retrieves the invalid opacity 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 invalid opacity value that was previously passed in.
  • Linux (unsupported):

    • win.setOpacity(opacity): takes no action on the actual window opacity, but stores the opacity value.
    • win.getOpacity(): retrieves the previously stored opacity value.

Proposed behavior

  • macOS/Windows:
    • win.setOpacity(opacity): bounds opacity value to the [0,1] range
    • win.getOpacity(): retrieves the bounded opacity value.
  • Linux:
    • win.setOpacity(opacity): takes no action.
    • win.getOpacity(): always returns 1.

Checklist

Release Notes

Notes: Normalized out-of-bound value behavior for the setOpacity() API in BrowserWindow.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jul 30, 2019
@erickzhao erickzhao removed the request for review from codebytere July 30, 2019 15:47
@erickzhao erickzhao changed the title [WIP] fix: normalize behavior of win.setOpacity() for invalid number values [WIP] fix: normalize behavior of win.setOpacity() for invalid number values across OSes Jul 30, 2019
@erickzhao erickzhao changed the title [WIP] fix: normalize behavior of win.setOpacity() for invalid number values across OSes [WIP] fix: normalize behavior of win.setOpacity() for invalid number values across operating systems Jul 30, 2019
@erickzhao erickzhao changed the title [WIP] fix: normalize behavior of win.setOpacity() for invalid number values across operating systems fix: normalize behavior of win.setOpacity() for invalid number values across operating systems Jul 30, 2019
@erickzhao erickzhao removed the wip ⚒ label Jul 30, 2019
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jul 31, 2019
shell/browser/native_window_mac.mm Outdated Show resolved Hide resolved
shell/browser/native_window_views.cc Outdated Show resolved Hide resolved
docs/api/browser-window.md Show resolved Hide resolved
shell/browser/native_window_views.cc Outdated Show resolved Hide resolved
spec-main/api-browser-window-spec.ts Outdated Show resolved Hide resolved
@erickzhao erickzhao force-pushed the intern/set-opacity-beyond-bounds branch from 036a33c to db9cefd Compare August 2, 2019 21:09
@trop
Copy link
Contributor

trop bot commented Aug 7, 2019

I was unable to backport this PR to "5-0-x" cleanly;
you will need to perform this backport manually.

@codebytere
Copy link
Member

@erickzhao can you please handle these manual backports when you have a moment?

erickzhao added a commit that referenced this pull request Aug 7, 2019
…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>
@trop
Copy link
Contributor

trop bot commented Aug 7, 2019

A maintainer has manually backported this PR to "7-0-x", please check out #19673

@trop
Copy link
Contributor

trop bot commented Aug 12, 2019

A maintainer has manually backported this PR to "6-0-x", please check out #19723

@trop
Copy link
Contributor

trop bot commented Aug 12, 2019

A maintainer has manually backported this PR to "5-0-x", please check out #19724

@sofianguy sofianguy added this to 7.0.0-beta.3 in 7.2.x Aug 15, 2019
@sofianguy sofianguy added this to 6.0.3 in 6.1.x Aug 20, 2019
@sofianguy sofianguy added this to Fixed in 5.0.10 in 5.0.x Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
5.0.x
Fixed in 5.0.10
6.1.x
6.0.3
7.2.x
Fixed in 7.0.0-beta.3
Development

Successfully merging this pull request may close these issues.

None yet

5 participants