On Wed, 19 Nov 2025 08:54:27 GMT, Marius Hanl <[email protected]> wrote:
>> Requesting `VFlow` re-layout when signaled by a `Node` embedded in >> `TextCell`. >> >> >> ### NOTES >> >> - this PR depends on https://github.com/openjdk/jfx/pull/1974 >> - the fix can be verified visually using the latest Monkey Tester >> >> <img width="1232" height="741" alt="Screenshot 2025-11-17 at 13 43 12" >> src="https://github.com/user-attachments/assets/58b2ef77-094c-45bd-8a04-3caaa4672df1" >> /> > > modules/jfx.incubator.richtext/src/main/java/com/sun/jfx/incubator/scene/control/richtext/util/RichUtils.java > line 751: > >> 749: // with the author's permission >> 750: /** returns a parent of the specified type, or null. if node is an >> instance of the specified class, returns node */ >> 751: public static <T> T getAncestorOfClass(Class<T> c, Node node) { > > I would really recommend to not do anything like that. Normally, the > layouting system, especially when requesting a layout should work and bubble > up correctly. I wonder why this is needed. And if we found a special case, if > we can solve it better. > > Background: In the past projects, I often saw code like that and it turned > out that this was never needed. It is often less readable and hurts the > performance a bit. > We also improve coupling between components, which I would not recommend as > well. Especially since subclasses can change a lot and it would be nice if > everything still work out of the box. 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. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1975#discussion_r2542629583
