On Fri, 2 May 2025 17:42:45 GMT, Andy Goryachev <ango...@openjdk.org> wrote:
>> Please refer to >> >> https://github.com/andy-goryachev-oracle/Test/blob/main/doc/Text/LayoutInfo.md >> >> 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 25 >> */ >> public final LayoutInfo getLayoutInfo() >> >> >> The `LayoutInfo` provides a view into the text layout within >> `Text`/`TextFlow` nodes such as: >> >> - caret information >> - text lines: offsets and bounds >> - overall layout bounds >> - text selection geometry >> - strike-through geometry >> - underline geometry >> >> >> This PR also adds the missing `strikeThroughShape()` method to complement >> the existing `underlineShape()` and `rangeShape()` for consistency sake: >> >> >> /** >> * Returns the shape for the strike-through in local coordinates. >> * >> * @param start the beginning character index for the range >> * @param end the end character index (non-inclusive) for the range >> * @return an array of {@code PathElement} which can be used to create a >> {@code Shape} >> * @since 25 >> */ >> public final PathElement[] strikeThroughShape(int start, int end) >> >> >> >> >> ## WARNING >> >> Presently, information obtained via certain Text/TextField methods is >> incorrect with non-zero padding and borders, see >> [JDK-8341438](https://bugs.openjdk.org/browse/JDK-8341438). >> >> This PR provides correct answers in the new API, leaving the behavior of the >> existing methods unchanged (there is a compatibility risk associated with >> trying to fix [JDK-8341438](https://bugs.openjdk.org/browse/JDK-8341438) ). >> >> >> >> ## Testing >> >> The new APIs can be visually tested using the Monkey Tester on this branch: >> https://github.com/andy-goryachev-oracle/MonkeyTest/tree/text.layout.api >> >> in the Text and TextFlow pages: >>  >> >> Two very basic headful tests have been added. >> >> >> ## See Also >> >> https://github.com/FXMisc/RichTextFX/pull/1246 > > Andy Goryachev has updated the pull request with a new target base due to a > merge or a rebase. The pull request now contains 53 commits: > > - review comments > - Merge remote-tracking branch 'origin/master' into ag.text.layout.api > - sealed > - indent > - Merge remote-tracking branch 'origin/master' into ag.text.layout.api > - Merge remote-tracking branch 'origin/master' into ag.text.layout.api > - Merge remote-tracking branch 'origin/master' into ag.text.layout.api > - twice > - tests > - review comments > - ... and 43 more: https://git.openjdk.org/jfx/compare/498b7e4c...982ef1f7 The changes to the API look good. I left a few wording suggestions. Once those are resolved, update the CSR. I see that this PR lists [JDK-8341671](https://bugs.openjdk.org/browse/JDK-8341671) and [JDK-8341672](https://bugs.openjdk.org/browse/JDK-8341672) as additional issues solved. They are included as part of the text LayoutInfo, so it would be better to close them as duplicates and remove them from this PR (using `/issue remove`). modules/javafx.graphics/src/main/java/javafx/scene/text/LayoutInfo.java line 32: > 30: > 31: /** > 32: * Provides a snapshot of the text layout geometry in a {@code Text} or a > {@code TextFlow} node, I might either remove the word "Provides" or else replace it with "Holds". modules/javafx.graphics/src/main/java/javafx/scene/text/Text.java line 2097: > 2095: * this lightweight object remains valid until the next layout > cycle. > 2096: * > 2097: * @return the layout information maybe "a copy of the ..."? modules/javafx.graphics/src/main/java/javafx/scene/text/TextFlow.java line 719: > 717: > 718: /** > 719: * Returns the object which provides a snapshot of the text layout > geometry for this node. Same comment as for Text::getLayoutInfo ------------- PR Review: https://git.openjdk.org/jfx/pull/1596#pullrequestreview-2859084182 PR Review Comment: https://git.openjdk.org/jfx/pull/1596#discussion_r2101152942 PR Review Comment: https://git.openjdk.org/jfx/pull/1596#discussion_r2101145917 PR Review Comment: https://git.openjdk.org/jfx/pull/1596#discussion_r2101146652