On Wed, 9 Oct 2024 20:58:21 GMT, Phil Race <p...@openjdk.org> wrote: >> thank you! >> >> I am struggling with how to explain that it should neither be cached, nor >> compared to another snapshot. >> >> Maybe an example would help. Use case is an editable rich text component >> based on `TextFlow`. The user presses `HOME` and the caret needs to go to >> the beginning of the line. We get the `LayoutInfo`, determine which line >> the caret is currently at and determine the start offset of that line to >> move the caret to. >> >> Another example: in `Text`, to determine whether the mouse is clicked inside >> of the text or beyond the last character (see >> [JDK-8091012](https://bugs.openjdk.org/browse/JDK-8091012) ). >> >> We are not expecting the application to monitor the text layout, so no >> notifications or observable properties or equals() are needed. >> >> (I've added some words to that effect in `Text/TextFlow.getLayoutInfo()` ) > > Clients will usually obtain a LayoutInfo in order to respond to some user > action or an update of the target node. > LayoutInfo should be considered an ephemeral snapshot, to be used and > immediately discarded. > Clients should always obtain a new one when they need to respond again as > likely the trigger to respond again means the target node has changed.
Although I don't see the harm in being more efficient. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1596#discussion_r1794216880