RFR: JDK-8292276 : Missing color names in CSS. [v10]
ScientificWare
duke at openjdk.org
Sat Sep 3 03:29:32 UTC 2022
On Sat, 3 Sep 2022 01:33:02 GMT, SWinxy <duke at openjdk.org> wrote:
>> To avoid change method behaviour, I tried to reproduce previous behaviors because returned objects can be publicly exposed trough javax.swing.text.html.StyleSheet stringToColor method.
>> Previous implementation :
>> When, "" returns always the same object Color.Black.
>> When, "black", "silver", "white", ..., rgb colors defined ... returns a new object.
>> I haven't a example list in mind but at least Color1 == Color2 is different according implementation.
>
> I think Phil is talking about just `return`ing the result, which doesn't change behavior. `""` can still `return Color.BLACK;` with the others creating a new object, ditching the oddly-placed temporary `Color` object.
@SWinxy,
- if you're suggesting this
```
} else {
return colorNamed.get(strlc);
```
We change the behavior (your comment) and lose the last test (color hex coded but without # prefix).
- or if you have in mind
} else {
return new Color(colorNamed.get(strlc).color.getRGB(), true);
We preserve the behavior but still lose the last test (color hex coded but without # prefix).
- The way I interpreted @prrace comment :
```
} else {
Color color = colorNamed.get(strlc);
if (color != null) {
return color;
```
We change the behavior :
- In the code before this PR. The results were : null, Color.Black if "", and new Color Object for all other colors (the 10 named colors and all hex coded colors).
- In the first implementation achieved in this PR, like the code above, results changed to : null, Color.Black if "", the same Object for each (149) named-color or hex coded color.
- After your comment, results became : null, Color.Black if "", and new Color Object for all other Color (149 named or hex coded).
-------------
PR: https://git.openjdk.org/jdk/pull/9825
More information about the client-libs-dev
mailing list