RFR: JDK-8292276 : Missing color names in CSS. [v10]

Phil Race prr at openjdk.org
Thu Sep 1 20:43:11 UTC 2022


On Mon, 29 Aug 2022 14:24:59 GMT, ScientificWare <duke at openjdk.org> wrote:

>> This is referenced in Java Bug Database as
>> - [JDK-8292276 : Missing color names in CSS](https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8292276)
>> 
>> This is tracked in JBS as 
>> - [JDK-8292276 : Missing color names in CSS](https://bugs.openjdk.java.net/browse/JDK-8292276)
>> 
>> Adds missing color names, defined by CSS Level 4, in CSS.java :
>> CSS Color Module Level 4
>> W3C Candidate Recommendation Snapshot, 5 July 2022
>> [7.1 Named Colors](https://www.w3.org/TR/css-color-4/#named-color)
>> 
>> Designed from : [ScientificWare JDK-8292276 : Missing color names in CSS](https://github.com/scientificware/jdk/issues/12)
>
> ScientificWare has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Adds transparent and RGB case insensitive tests.
>   
>   When <rgb()> and <rgba()> values contains at least an uppercase character, getAttribute returns null.
>   When using 'transparent' keyword getAttribute returns null.

Changes requested by prr (Reviewer).

src/java.desktop/share/classes/javax/swing/text/html/CSS.java line 1398:

> 1396:     static Color stringToColor(String str) {
> 1397:         String strlc = str.toLowerCase(Locale.ROOT);
> 1398:         if (str == null) {

What's the point in testing if it is null after you already de-referenced it ?

src/java.desktop/share/classes/javax/swing/text/html/CSS.java line 1411:

> 1409:             Color color = colorNamed.get(strlc);
> 1410:             if (color != null) {
> 1411:                 return new Color(color.getRGB(), true);

Can you explain why you can't return the color instance directly ?
They are immutable so I don't see the reason.

src/java.desktop/share/classes/javax/swing/text/html/CSS.java line 1562:

> 1560:             Map.entry("tomato", new Color(255, 99, 71, 255)),
> 1561:             Map.entry("transparent", new Color(0, 0, 0, 0)),
> 1562:             Map.entry("turquoise", new Color(64, 224, 208, 255)),

So all of these have the extra 255 alpha arg just so this ONE entry can be different ? Do you expect others like this ? If not why not special case that in the caller method ?

-------------

PR: https://git.openjdk.org/jdk/pull/9825



More information about the client-libs-dev mailing list