RFR: 8365637: Unmanaged nodes are not added to the Scene's dirty layout list
John Hendrikx
jhendrikx at openjdk.org
Mon Aug 18 18:04:18 UTC 2025
On Mon, 18 Aug 2025 17:01:59 GMT, Nir Lisker <nlisker at openjdk.org> wrote:
> If the node is unmanaged, why does it need a relayout in practice?
The unmanaged node does not need relayout, but its potentially managed children do. Just like a Scene does not need layout, but its root does. A node being unmanaged affects its **parent** (the parent must skip it for layout calculations), but does not free it from doing layout on its own children (if I interpret the documentation correctly).
Let's take this hierarchy:
Region
StackPane (unmanaged)
ImageView
The Region will not lay out the stack pane as it is unmanaged, so I position the unmanaged child manually with `resizeRelocate`. The StackPane now has a defined position and size. When I add children to it, the StackPane's `layout` (and conversely `layoutChildren`) should still be called to ensure the children nicely fill the StackPane's space.
JavaFX currently will do steps 1 and 2, but does not do step 3:
1. Another child is added to the StackPane (an overlay for the ImageView) this triggers a requestLayout on that child which marks it as needing layout
2. This propagates to the parent, which is also marked as needing layout, but it is considered to be a layout root, so no further propagation occurs
3. Since a layout root was encountered, it should be added to the list of dirty layout roots (implemented in this PR). This will clear all the needs layout flags (otherwise they stay `true` and never go back to `false` again).
The documentation however seems quite clear that step 3 is also supposed to be done.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1874#issuecomment-3197898264
More information about the openjfx-dev
mailing list