Hi Ajit, David,

I came accross a potential issue introduced by JDK-8090462 (
https://bugs.openjdk.java.net/browse/JDK-8090462), (
https://github.com/openjdk/jfx/commit/834b0d05e7a2a8351403ec4a121eab312d80fd24#diff-9ec098280fa1aeed53c70243347e76ab).
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 (
https://github.com/openjdk/jfx/blob/20325e1c3ec4c4e81af74d3d43bf3a803dbe1a51/modules/javafx.graphics/src/main/java/javafx/scene/CssStyleHelper.java#L322
):

        CssStyleHelper parentHelper =
getStyleHelper(node.styleHelper.firstStyleableAncestor);

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?

Dean

Reply via email to