RFR: 8371067: RichTextArea: requestLayout by inline node doesn't reach VFlow [v2]
Marius Hanl
mhanl at openjdk.org
Fri Nov 21 08:44:15 UTC 2025
On Thu, 20 Nov 2025 16:23:13 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> Yes, this is by design. VFlow is the component that manages the text cells.
>
>> is to take another look at the problem and how to solve it.
>
> The RTA design is that VFlow deals with the layout. It views the thing not as a collection of independent cells, but as a virtual flow - a change in one cell might require the reflow of many other parts, toggling scroll bars visibility, reshaping the selection shapes, etc.
>
> In an ideal world, the layout of text and embedded nodes would be a responsibility of the (prism) text layout, making it easier to have for example a Label with rich text. But we don't have that option, so this design uses a collection of text cells to present the visible area, managed by the VFlow.
Let me repeat what I mean:
- If you call: `setManaged(false)`, you will effectively tell JavaFX: I'm the layout root, I can handle ALL layout changes from my children without my parents.
- This is not the case here, so making the `TextCell` unmanaged while still retrieving a parent (`VFlow`) fights this design.
- Which leads me to the conclusion: Maybe this should not be unmanaged, since it does not fulfill the required preconditions
- Checking the `VirtualFlow` as an example, it will not set anything to unmanaged
Lets check some existing examples of unmanaged nodes:
`XYChart`. See how this was done by design, the consequences were known:
https://github.com/openjdk/jfx/blob/33abf5d4b3d2b90f66581c4e25c542adf285fadd/modules/javafx.controls/src/main/java/javafx/scene/chart/XYChart.java#L523-L525
---
`ScrollPaneSkin` has actually the same case as you. This is how they dealt with it:
https://github.com/openjdk/jfx/blob/33abf5d4b3d2b90f66581c4e25c542adf285fadd/modules/javafx.controls/src/main/java/javafx/scene/control/skin/ScrollPaneSkin.java#L652-L653
https://github.com/openjdk/jfx/blob/33abf5d4b3d2b90f66581c4e25c542adf285fadd/modules/javafx.controls/src/main/java/javafx/scene/control/skin/ScrollPaneSkin.java#L679-L689
This could be a solution for your problem. Since they also set the parent `viewRect` as unmanaged, the layout request will never hit the `ScrollPane`. But with that solution the child of the `viewRect`, called `viewContent` does request the `ScrollPane` layout. A clever solution without anything like ancestor searching. What do you think?
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1975#discussion_r2548963033
More information about the openjfx-dev
mailing list