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

Marius Hanl mhanl at openjdk.org
Thu Nov 20 13:24:01 UTC 2025


On Thu, 20 Nov 2025 12:55:09 GMT, Jurgen <duke at openjdk.org> wrote:

>> What I mean is:
>> Everything is part of the `RichTextArea`. Requesting a layout from a node inside should request a layout for each parent, also `RichTextArea`. So you should normally know that on the `RichTextArea` 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 `RichTextArea` 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.

I know why. Because the `TextCell` is not managed. 
https://github.com/openjdk/jfx/blob/f87448ec156608527d77a4204e98e08052ffecd1/modules/jfx.incubator.richtext/src/main/java/com/sun/jfx/incubator/scene/control/richtext/TextCell.java#L70

Therefore, this will be set:
https://github.com/openjdk/jfx/blob/f87448ec156608527d77a4204e98e08052ffecd1/modules/javafx.graphics/src/main/java/javafx/scene/Parent.java#L1331-L1334

Indeed, the `TextCell` will be handled as layout root, therefore not propagating any layout request further up.
So the real problem is, that the `TextCell` is not managed.

Otherwise the layout would be propagated to the `RichTextArea`, which can do the corresponding actions. So I would suggest looking into that.

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

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


More information about the openjfx-dev mailing list