CssStyleHelper canReuseStyleHelper

Dean Wookey wookey.dean at gmail.com
Thu Jan 16 16:33:36 UTC 2020

Hi Ajit, David,

I came accross a potential issue introduced by JDK-8090462 (
https://bugs.openjdk.java.net/browse/JDK-8090462), (
The issue is in the canReuseStyleHelper method. canReuseStyleHelper is
called as a result of changes to the scene graph and for other reasons. The
original code found the parent helper in the following way:

        Styleable parent = node.getStyleableParent();
        while (parent != null) {
            if (parent instanceof Node) {
                parentHelper = ((Node) parent).styleHelper;
                if (parentHelper != null) break;
            parent = parent.getStyleableParent();

This gets the parent helper for the new parent of the node. The code now (

        CssStyleHelper parentHelper =

gets the helper of the previous parent of the node since
firstStyleableAncestor hasn't been updated to reflect the current state of
the scene graph yet. This means if you move a node, it could keep its
CssStyleHelper even if it's under completely new parents.

I'm not sure if this is actually causing any problems. It would be helpful
if I knew the kind of things that could go wrong if you reuse a style
helper so that I could design a test that highlighted the issue.

Can you perhaps think of cases where this could go badly?


More information about the openjfx-dev mailing list