On Wed, 9 Oct 2024 19:30:06 GMT, Andy Goryachev <ango...@openjdk.org> wrote:
>> The RichTextArea control >> ([JDK-8301121](https://bugs.openjdk.org/browse/JDK-8301121)), or any custom >> control that needs non-trivial navigation within complex or wrapped text >> needs a public API to get information about text layout. >> >> This change fixes the missing functionality by adding a new public method to >> the `Text` and `TextFlow` classes.: >> >> >> /** >> * Obtains the snapshot of the current text layout information. >> * @return the layout information >> * @since 24 >> */ >> public final LayoutInfo getLayoutInfo() >> >> >> The immutable `LayoutInfo` structure contains information about: >> >> - text lines: offsets and bounds >> - overall layout bounds >> >> TBD: >> >> the platform can also report additional information such as: >> >> - individual text lines' left and right side bearings (what are those?) >> - text runs within each line > > Andy Goryachev has updated the pull request incrementally with one additional > commit since the last revision: > > javadoc modules/javafx.graphics/src/main/java/javafx/scene/text/LayoutInfo.java line 32: > 30: * Represents an immutable snapshot of certain aspects of the text layout > 31: * in a {@code Text} or {@code TextFlow} node, > 32: * such as break up of the text into lines and the their bounds. "the their" modules/javafx.graphics/src/main/java/javafx/scene/text/LayoutInfo.java line 35: > 33: * <p> > 34: * The snapshot is valid until the layout changes due to any change that > 35: * triggers that, such as resizing of the container or modification of > properties. "until the layout changes due to any change that triggers that" it's not wrong, but writing change twice reads a bit off. How about The layout snapshot is no longer valid after actions such as resizing of the container, or modification of certain properties. For example updating the text or the font would invalidate the layout snapshot, but a change of color would not. I still don't see how applications can KNOW this has happened. There's nothing on the (immutable) layout which says its invalidated. There's no property to monitor. So people will in effect never be able to do anything but use it and toss it and get a new one every time. Perhaps you can make it 'cheap' to do this. Since it is immutable, the Text or TextFlow can cache it. If it is invalidated, the Text or TextFlow should know and can flush its cached version. So the SAME immutable instance can be returned over and over again until that happens. People can then also use "==" or equals() to check this and save themselves validation too. I notice you don't have equals() so probably that is needed anyway to save people from manual comparison .. also an evolution issue if the class is updated. A consequence of that is then the text about invalidation can be updated with advice on doing a simple equals() call if they need to know if it changed. And equals will start with "==" so will be really fast to return true .. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1596#discussion_r1794123397 PR Review Comment: https://git.openjdk.org/jfx/pull/1596#discussion_r1794137710