RFR: JDK-8292276 : Add named colors from CSS Color Module Level 4 [v23]
ScientificWare
duke at openjdk.org
Wed Oct 5 14:50:15 UTC 2022
On Fri, 30 Sep 2022 17:42:43 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>>> Shall I edit the subject of the issue to be more specific? “Add named colors from CSS Color Module Level 4”?
>>
>> Yes, you may. Thanks.
>>
>>> ... please create a [CSR](https://wiki.openjdk.org/display/csr/Main) request for issue [JDK-8292276](https://bugs.openjdk.org/browse/JDK-8292276) with the correct fix version. This pull request cannot be integrated until the CSR request is approved.
>>
>> Do I need an access to JBS ? I don't have a JBS user account.
>
>> > Shall I edit the subject of the issue to be more specific? “Add named colors from CSS Color Module Level 4”?
>>
>> Yes, you may. Thanks.
>
> I have updated the subject in JBS. Please edit the title of this PR accordingly.
@aivanov-jdk A proposition to update the specification of `StyleSheet.stringToColor`.
/**
* Converts a color string such as "RED" or "#NNN", "#NNNN", "#NNNNNN",
* "#NNNNNNNN" N digits in radix-16 or "rgb(r, g, b)" or
* "rgba(r, g, b, a)" to a Color.
* <p>
* Note : This will only convert string colors using names or 3, 4, 6, 8
* digit hexadecimal notations as they are listed and described in
* the CSS Color Module Level 4;
* otherwise, it will return null.
* This method is case-insensitive.
* <p>
* The following code defines instances of the same color :
* {@snippet lang="java" :
* import java.awt.Color;
* import javax.swing.text.html.StyleSheet;
* StyleSheet styleSheet = new StyleSheet();
* // An opaque lightseagreen
* Color color1 = styleSheet.stringToColor("Lightseagreen");
* Color color2 = styleSheet.stringToColor("LIGHTSEAGREEN");
* Color color3 = styleSheet.stringToColor("rgb(32 178 170)");
* Color color4 = styleSheet.stringToColor("#20b2aa");
* // A slightly-transparent lightseagreen
* Color color5 = styleSheet.stringToColor("rgba(32 178 170 0.8)");
* Color color6 = styleSheet.stringToColor("#20b2aacc");
* }
* <p>
* @param string color, string such as "RED" or "#NNNNNNNN" or
* "rgb(r, g, b)" or "rgba(r, g, b, a)"
* @return the color
*/
-------------
PR: https://git.openjdk.org/jdk/pull/9825
More information about the client-libs-dev
mailing list