RFR: 8355774: RichTextArea: provide mechanism for CSS styling of highlights
Andy Goryachev
andy.goryachev at oracle.com
Thu May 8 18:25:18 UTC 2025
Pavel:
I think your comments in the ticket are still invisible to me, so I can't comment.
About your recent comment in the PR - I have difficulty understanding what you mean. We are not adding methods to "style individual properties". We are adding methods that allow the application to use CSS to style parts of the visual representation of the given RichParagraph.
Perhaps if you describe what kind of visual representation you have in mind, we can show how to achieve that in the code.
-andy
From: openjfx-dev <openjfx-dev-retn at openjdk.org> on behalf of PavelTurk <pavelturk2000 at gmail.com>
Date: Thursday, May 8, 2025 at 11:04
To: openjfx-dev at openjdk.org <openjfx-dev at openjdk.org>
Subject: Re: RFR: 8355774: RichTextArea: provide mechanism for CSS styling of highlights
I am not a member of the JavaFX team, but if I may, I’d like to express my opinion. I believe that creating separate
methods for styling individual properties is a very problematic and dangerous decision.
First, the usefulness of such methods is minimal because when styling is done via CSS, the assumption is that
adjusting the CSS file should be sufficient—something that won’t work in this case. For example one user for search
result wants to set background color for matches but another one wants to set foreground color + weight.
Second, it violates fundamental CSS principles. Third, if these methods are added to the API, they cannot later
be removed without breaking backward compatibility.
I wrote about this in detail in the additional information for JDK-8356436, but my comment has not yet been approved
by a moderator.
When in doubt, it’s very helpful to see how others are doing it. In RichTextFX, special CSS properties were introduced,
which resulted in a consistent standard for applying CSS styles to all properties—fully aligned with established CSS norms.
This is my personal opinion, which, of course, can be wrong.
Best regards, Pavel
On 5/8/25 20:46, Andy Goryachev wrote:
> Adding missing APIs related to styling the highlights with CSS:
>
> 
>
>
>
> Adds methods to the `RichParagraph.Builder`:
>
>
> /**
> * Adds a wavy underline (typically used as a spell checker indicator) with the specified style name(s).
> * <p>
> * The corresponding styles should define CSS properties applicable to {@link javafx.scene.shape.Path}.
> *
> * @param start the start offset
> * @param length the end offset
> * @param css the style name(s)
> * @return this {@code Builder} instance
> * @since 25
> */
> public Builder addWavyUnderline(int start, int length, String ... css) {
>
>
>
> /**
> * Adds a highlight with the specified style name(s).
> * Use translucent colors to enable multiple highlights in the same region of text.
> * <p>
> * The corresponding styles should define CSS properties applicable to {@link javafx.scene.shape.Path}.
> *
> * @param start the start offset
> * @param length the end offset
> * @param css the style name(s)
> * @return this {@code Builder} instance
> * @since 25
> */
> public Builder addHighlight(int start, int length, String ... css) {
>
>
>
> Also adding similar methods to the `SimpleViewOnlyStyledModel` class:
>
>
> /**
> * Adds a highlight of the given color to the specified range within the last paragraph,
> * with the specified style name(s).
> *
> * @param start the start offset
> * @param length the length of the highlight
> * @param css the highlight style name(s)
> * @return this model instance
> * @since 25
> */
> public SimpleViewOnlyStyledModel highlight(int start, int length, String ... css) {
>
>
> /**
> * Adds a wavy underline (typically used as a spell checker indicator)
> * to the specified range within the last paragraph, with the specified style name(s).
> *
> * @param start the start offset
> * @param length the length of the highlight
> * @param css the highlight style name(s)
> * @return this model instance
> * @since 25
> */
> public SimpleViewOnlyStyledModel addWavyUnderline(int start, int length, String ... css) {
>
> -------------
>
> Commit messages:
> - tab
> - css
>
> Changes: https://git.openjdk.org/jfx/pull/1802/files
> Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1802&range=00
> Issue: https://bugs.openjdk.org/browse/JDK-8355774
> Stats: 128 lines in 4 files changed: 110 ins; 8 del; 10 mod
> Patch: https://git.openjdk.org/jfx/pull/1802.diff
> Fetch: git fetch https://git.openjdk.org/jfx.git pull/1802/head:pull/1802
>
> PR: https://git.openjdk.org/jfx/pull/1802
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20250508/47480c84/attachment-0001.htm>
More information about the openjfx-dev
mailing list