On Wed, 15 Jul 2026 13:10:13 GMT, Florian Kirmaier <[email protected]> 
wrote:

> 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: https://github.com/openjdk/jfx/pull/2213
> But it is fixed in a way that works independently of it.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

some questions

modules/javafx.controls/src/main/java/javafx/scene/control/ContextMenu.java 
line 257:

> 255:         
> PopupWindowHelper.ownerWindow(this).set(anchor.getScene().getWindow());
> 256:         PopupWindowHelper.ownerNode(this).set(anchor);
> 257:         PopupWindowHelper.applyStylesheetFromOwner(this, 
> anchor.getScene().getWindow());

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.

modules/javafx.controls/src/test/java/test/javafx/scene/control/ContextMenuTest.java
 line 700:

> 698:     }
> 699: 
> 700:     @Test public void test_css_skin_counter() {

`testCssNewSkinAppliedByStyleClassChange`

Or something like that would be suggestion to better express what we test here

modules/javafx.controls/src/test/java/test/javafx/scene/control/ContextMenuTest.java
 line 702:

> 700:     @Test public void test_css_skin_counter() {
> 701:         anchorBtn.getScene().getStylesheets().add(
> 702:                 
> getClass().getResource("test_css_skin_counter.css").toExternalForm()

you could create a data url CSS, then you don't need a separate CSS file.

https://github.com/openjdk/jfx/blob/17189589cb82a2cec6397e1e14024593f5ce30c3/modules/javafx.graphics/src/test/java/test/javafx/scene/CssStyleHelperTest.java#L943

https://github.com/openjdk/jfx/blob/17189589cb82a2cec6397e1e14024593f5ce30c3/modules/javafx.graphics/src/test/java/test/javafx/scene/CssStyleHelperTest.java#L968-L970

modules/javafx.controls/src/test/java/test/javafx/scene/control/ContextMenuTest.java
 line 709:

> 707:         button.skinProperty().subscribe(skin -> {
> 708:             System.out.println("new Skin: " + skin);
> 709:             new Exception().printStackTrace();

looks like debugging code?

modules/javafx.controls/src/test/java/test/javafx/scene/control/ContextMenuTest.java
 line 725:

> 723:         assertEquals(2, skinCounter.get());
> 724:     }
> 725: 

unnecessary newline

-------------

PR Review: https://git.openjdk.org/jfx/pull/2215#pullrequestreview-4722258873
PR Review Comment: https://git.openjdk.org/jfx/pull/2215#discussion_r3602873118
PR Review Comment: https://git.openjdk.org/jfx/pull/2215#discussion_r3602817015
PR Review Comment: https://git.openjdk.org/jfx/pull/2215#discussion_r3602806880
PR Review Comment: https://git.openjdk.org/jfx/pull/2215#discussion_r3602797405
PR Review Comment: https://git.openjdk.org/jfx/pull/2215#discussion_r3602808437

Reply via email to