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: - font code added: https://bugs.openjdk.org/browse/JDK-8123731 - font 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). ------------- Commit messages: - 8388140: Significant CSS performance regression after JDK-8268657 Changes: https://git.openjdk.org/jfx/pull/2210/files Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=2210&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8388140 Stats: 64 lines in 1 file changed: 30 ins; 23 del; 11 mod Patch: https://git.openjdk.org/jfx/pull/2210.diff Fetch: git fetch https://git.openjdk.org/jfx.git pull/2210/head:pull/2210 PR: https://git.openjdk.org/jfx/pull/2210
