8388313: ContextMenu.show(node, side,x, y) evaluates CSS multiple times. - #2215
Conversation
…ide,x.y) is called
|
👋 Welcome back fkirmaier! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
This looks like a risky fix that will need very careful review, which can happen some time after tomorrow's RDP1 fork. CSS performance fixes have a fairly high risk of regression, so this is the sort of change that is better earlier in the release cycle. |
|
Just noticed that i accidentally removed a line. Readded it. Conceptional the fix is quite simple. Basically fixes a half implementation which was done before. Targeting the Release after makes of course sense! |
| System.out.println("new Skin: " + skin); | ||
| new Exception().printStackTrace(); |
There was a problem hiding this comment.
Removed them.
But honestly, tests should have debugging code, and be loud about everything thats happening.
Makes it easier to go back into the topic. And the junit-test-report separates the outputs by test anyways.
But thats just my opinion. And it's no where done in the project.
|
|
||
| @Test public void test_css_skin_counter() { | ||
| anchorBtn.getScene().getStylesheets().add( | ||
| getClass().getResource("test_css_skin_counter.css").toExternalForm() |
There was a problem hiding this comment.
you could create a data url CSS, then you don't need a separate CSS file.
There was a problem hiding this comment.
Used it, by making the method public.
Tell me, if another way to use it would be prefered.
Removed the css-file.
| assertEquals(anchorBounds.getMinY(), cmBounds.getMinY(), 0.0); | ||
| } | ||
|
|
||
| @Test public void test_css_skin_counter() { |
There was a problem hiding this comment.
testCssNewSkinAppliedByStyleClassChange
Or something like that would be suggestion to better express what we test here
There was a problem hiding this comment.
It's now named testCssProcessedOnlyOnce,
And i also updated the test, to check for 1 instead of 2 (subscribe triggered once before the change, not its a real change-listener)
| PopupWindowHelper.ownerWindow(this).set(anchor.getScene().getWindow()); | ||
| PopupWindowHelper.ownerNode(this).set(anchor); | ||
| PopupWindowHelper.applyStylesheetFromOwner(this, anchor.getScene().getWindow()); |
There was a problem hiding this comment.
Those seem to be set already later in doShow -> show -> showImpl.
And also the stylesheet is applied there as well. So I wonder if can instead just remove the stylesheet stuff below and this as well, and let be done later.
There was a problem hiding this comment.
No, this is basically the heart of the PR.
We have to set all this before the layout is computed at:
Point2D point = Utils.pointRelativeTo(anchor,
prefWidth(-1), prefHeight(-1),
hpos, vpos, dx, dy, true);
Which happens before the show.
The double-assignment is a bit odd.
But the other solution would be to split the show() into a "preShow()" which prepares CSS and owners.
Which would be a bigger change.
When ContextMenu.show(node, side, x, y) is executed, the CSS is evaluated multiple times.
Of these 3 times, 2 process a non-final CSS state.
This leads to temporary, unnecessary changes.
This is fixed by properly defining the stylesheets and the ownerWindow/ownerNode properties of the context menu
before applyCss is called. The previous solution was incomplete and resulted in unnecessary CSS calls.
Slightly related to my other PR: #2213
But it is fixed in a way that works independently of it.
Progress
Error
- [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).Integration blocker
Warning
8388313: ContextMenu.show(node, side,x, y) evaluates CSS multiple times.Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2215/head:pull/2215$ git checkout pull/2215Update a local copy of the PR:
$ git checkout pull/2215$ git pull https://git.openjdk.org/jfx.git pull/2215/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2215View PR using the GUI difftool:
$ git pr show -t 2215Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2215.diff