On Mon, 13 Jul 2026 20:30:07 GMT, Marius Hanl <[email protected]> wrote:

> Since the last [PR](https://github.com/openjdk/jfx/pull/2201) made the parent 
> `styleHelper` creation more eager, creating and adding many nodes will be 
> slower (initially).
> 
> The fix is actually something I already had in mind when I did the previous 
> PR: Find the ancestor lazily.
> Now, when we create a `CssStyleHelper` we will not yet set the 
> `firstStyleableAncestor`. 
> This will improve the performance to the level before while all tests still 
> pass.
> 
> This makes sense because `CssStyleHelper` is created (top-down) but not 
> immediately used. It can also be (re)created when a `Node` changes its 
> `Parent` (or deferred from there).
> 
> Later, `transitionToState` is called (top-down) which will then need the 
> `firstStyleableAncestor` (and this is also where we will compute it now). 
> Since in the meantime the scene structure could change, it makes sense to do 
> that as late as possible.
> 
> The days before I also investigated 
> [JDK-8187955](https://bugs.openjdk.org/browse/JDK-8187955) and found a good 
> improvement as well (no recursion needed, we can again use the preexisting 
> loop). Since we now create the `firstStyleableAncestor` lazy, it makes sense 
> to combine it, as otherwise the `isUserSetFont` need to be changed which I 
> think is more risky.
> 
> Also did some digging about `isUserSetFont`, and was added/changed in this 
> tickets:
> - `isUserSetFont` code added: https://bugs.openjdk.org/browse/JDK-8123731
> - `isUserSetFont` code changed: https://bugs.openjdk.org/browse/JDK-8093577
> 
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

I am planning to do more experiments today, but I had the same initial thought: 
it might be better to back out JDK-8268657 given the proximity to RDP1 and the 
risk of regression.

The bigger question is how can we ensure the CSS works as advertised?  Perhaps 
we ought to invest more time into writing a comprehensive test suite against 
the spec, which will be a monumental task.

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

PR Comment: https://git.openjdk.org/jfx/pull/2210#issuecomment-4971959622

Reply via email to