RFR: 8371067: RichTextArea: requestLayout by inline node doesn't reach VFlow

Jurgen duke at openjdk.org
Thu Nov 20 12:58:27 UTC 2025


On Thu, 20 Nov 2025 08:28:57 GMT, Marius Hanl <mhanl at openjdk.org> wrote:

>> Thank you @Maran23 for looking into this PR!
>> 
>> My experience is exactly opposite - I do use it often.  The `Node` (or `JComponent`) hierarchy is a hierarchy, explicitly retaining the pointers to the each member's parent.
>> 
>> A specific member can be a child of a certain Parent, direct or otherwise, by design, and this method allows to get to that parent easily.
>> 
>> Let me ask you this - what is the alternative?  Maintain a duplicate pointer?
>> 
>> Also, keep in mind this is not public API, it's a utility.
>
> What I mean is:
> Everything is part of the `RichTextLabel`. Requesting a layout from a node inside should request a layout for each parent, also `RichTextLabel`. So you should normally know that on the `RichTextLabel` level, which also manages the `VFlow`. So it can do the corresponding actions, just by the node requesting the layout.
> 
> If we take a look at other more complex Controls, they do the following:
> - `VirtualFlow.requestCellLayout` -> sets a flag
> - `layout` is requested, and due to the flag, we know what to do
> 
> Maybe something that could be done here as well? Could also be done by `Properties` perhaps.
> 
>> A specific member can be a child of a certain Parent, direct or otherwise, by design, and this method allows to get to that parent easily.
>> ...
>> Also, keep in mind this is not public API, it's a utility.
> 
> Yes, we can always get the parent hierarchy. But that does not mean we should. 
> Making assumptions about the hierarchy will make subclasses and customizations (e.g. in the Skin) worse. If we extend `RichTextLabel` and use another Node then `VFlow`, then we can expect `TextCell`s not to work anymore?
> 
> In JavaFX, as you can also see in the codebase and other controls, retrieving an ancestor somewhere in the scene graph is pretty much never done or needed. 
> I did not have a look on this particular issue, but what I want to suggest is to take another look at the problem and how to solve it. So we don't need to rely on finding a specific node that might be somewhere in the scene graph.

If I remember correctly from what I've traced, is that _requestLayout_ from the embedded node is propagating upwards until it reaches `TextCell` which extends a `BorderPane`. At this point _requestLayout_ in `Parent` invokes _markDirtyLayout_ with the **forceParentLayout** parameter/flag being **false** and the propagation stops.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1975#discussion_r2545969921


More information about the openjfx-dev mailing list