On Wed, 11 Nov 2026 00:31:50 GMT, Marius Hanl <[email protected]> wrote:

> This PR is a mix between fixing the regression and fixing the actual root 
> cause of it.
> 
> #### Starting with the regression:
> 
> 1. When a `Tooltip` is shown again, `applyCss()` is called before showing it 
> (So we can resolve the `-fx-show-delay`). 
> That pass used the stale helper, leading to broken CSS (reset).
> 2. The `CssStyleHelper.resetProperties` now walks all the 
> `CssStyleHelper.cssSetProperties`, including metadata the node no longer has, 
> for example after its skin was removed. This can lead to a wrong reset or NPE.
> 
> #### Preexisting bugs (root causes):
> 
> 3. `Window.hide()` and `Window.setScene()` drop the scene CSS cache (-> 
> `forget()`), but the nodes keep their old style helpers.
> Applying CSS before the window is shown again styled the node with 
> `StyleMap.EMPTY_MAP` because of the stale helper.
> 
> This is the root cause of the issue, which before worked by accident (due to 
> the inherit).
> 
> 4. `CssStyleHelper.resetToInitialValues` always reset every tracked property, 
> removed skin metadata included, with the same NPE or wrong reset.
> 
> Root cause: This was never right and I accidentally made it worse by doing 
> the same in the `transitionToState` reset as we did in 
> `resetToInitialValues`. We now remove stale entries.
> 
> #### Related, also fixed by accident:
> 
> 5. `scheduleReapplyCSS()` set `REAPPLY` without marking the root `NODE_CSS` 
> dirty, so `applyCss()` on a child skipped the root and only saw the change 
> after the next pulse. 
> Fix is to call `notifyParentsOfInvalidatedCSS()` after. Found because I'm 
> reusing this method now for the fix.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

modules/javafx.graphics/src/main/java/javafx/scene/CssStyleHelper.java line 960:

> 958:             Entry<CssMetaData, CalculatedValue> entry = it.next();
> 959:             CssMetaData cssMetaData = entry.getKey();
> 960:             if (cssMetaData != 
> TransitionDefinitionCssMetaData.getInstance() && 
> !styleables.contains(cssMetaData)) {

unlikely but legitimate scenario: when a custom skin provides a different 
metadata for the same control property.  this check seems to discard the 
original reset entry.

modules/javafx.graphics/src/main/java/javafx/scene/Node.java line 627:

> 625:             public void scheduleReapplyCSS(Node node, boolean 
> requestPulse) {
> 626:                 node.cssFlag = CssFlags.REAPPLY;
> 627:                 node.notifyParentsOfInvalidatedCSS();

this might trigger NPE in Node:9895 when replacing the scene root (for example, 
when the old root's `sceneProperty` listener updates css).

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2366#discussion_r4555373213
PR Review Comment: https://git.openjdk.org/jfx/pull/2366#discussion_r4555343967

Reply via email to