8389092: PopupWindow.show() unconditionally overwrites user-set scene stylesheets with the owner's stylesheets - #2236
Conversation
… stylesheets with the owner's stylesheets
|
👋 Welcome back mhanl! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
The total number of required reviews for this PR has been set to 2 based on the presence of this label: |
|
|
||
| private void showImpl(final Window owner) { | ||
| Window rootWindow = getRootWindow(owner); | ||
| if (rootWindow == null) { |
There was a problem hiding this comment.
not equivalent change: the old code set this.ownerWindow (to null in this case, see L467)
| private void showImpl(final Window owner) { | ||
| Window rootWindow = getRootWindow(owner); | ||
| if (rootWindow == null) { | ||
| return; |
There was a problem hiding this comment.
I am just a bit confused here. Referring to old version' line numbers, it looks like we should not have a null value returned from getRootWindow(owner): it's being dereferenced in L477 and also L485.
| void applyStylesheetFromOwner(Window owner) { | ||
| // JDK-8116444 | ||
| Window rootWindow = getRootWindow(owner); | ||
| if (rootWindow == null) { |
There was a problem hiding this comment.
same thing - is it even possible for the rootWindow to be null?
There was a problem hiding this comment.
Yes, as you can see in the tests I wrote.
PopupWindowwill always overwrite itsScene(user agent) stylesheets when an owner was set andshowis called.Code like this:
will do nothing, because your added stylesheets will be later overwritten when
showis called.Andy and I were already wondering about this behavior two years ago: #1394 (comment)
I can't see any reason why we should do that. Instead, this PR will only add the stylesheets of the owner if they do not exist already.
Additionally, we will not overwrite the user agent stylesheet if it was already set.
Added tests for all combinations I can think of. This PR also fixes NPEs that can happen when the owner window has no 'root window'.
There is already a test for the
Cursorbehavior, but there was none that verifies that theCursoris not overwritten, so added one as well.jfx/modules/javafx.graphics/src/main/java/javafx/stage/PopupWindow.java
Lines 479 to 481 in 05a7b6d
Now, we will never overwrite anything that the developer set (before
showing). And as we can see above, this was already done this way with theCursor.Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2236/head:pull/2236$ git checkout pull/2236Update a local copy of the PR:
$ git checkout pull/2236$ git pull https://git.openjdk.org/jfx.git pull/2236/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2236View PR using the GUI difftool:
$ git pr show -t 2236Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2236.diff
Using Webrev
Link to Webrev Comment