Skip to content

Commit 18a45cb

Browse files
Simplify internal CSS-version handling for colors
Internally the code was maintaining a list of “CSS4” colors and a list of “CSS3” colors, but the only difference between the two was the color `rebeccapurple`. So this change adds `rebeccapurple` to the list of “CSS3” colors and changes the rest of the code to use that wherever it was previously using the “CSS4” list. That old code was the only place where a “CSS4” distinction was used for any feature being checked. So this change makes the color-checking version behavior consistent with the rest of the code, where the “CSS3” label now just means in practice “the latest relevant spec for whatever feature is being checked”.
1 parent 096fa5a commit 18a45cb

File tree

3 files changed

+4
-210
lines changed

3 files changed

+4
-210
lines changed

org/w3c/css/values/CssColor.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ protected void setIdentColor(String s, ApplContext ac)
307307
break;
308308
case CSS3:
309309
case CSS_2015:
310+
case CSS:
310311
// test RGB colors, RGBA colors (transparent), deprecated system colors
311312
rgb = CssColorCSS3.getRGB(lower_s);
312313
if (rgb != null) {
@@ -325,25 +326,6 @@ protected void setIdentColor(String s, ApplContext ac)
325326
}
326327
// inherit or current color will be handled in the property def
327328
throw new InvalidParamException("value", s, "color", ac);
328-
case CSS:
329-
// test RGB colors, RGBA colors (transparent), deprecated system colors
330-
rgb = CssColorCSS4.getRGB(lower_s);
331-
if (rgb != null) {
332-
color = lower_s;
333-
break;
334-
}
335-
rgba = CssColorCSS4.getRGBA(lower_s);
336-
if (rgba != null) {
337-
color = lower_s;
338-
break;
339-
}
340-
color = CssColorCSS4.getSystem(lower_s);
341-
if (color != null) {
342-
ac.getFrame().addWarning("deprecated", s);
343-
break;
344-
}
345-
// inherit or current color will be handled in the property def
346-
throw new InvalidParamException("value", s, "color", ac);
347329
default:
348330
throw new InvalidParamException("value", s, "color", ac);
349331
}

org/w3c/css/values/CssColorCSS3.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.util.HashMap;
88

99
/**
10-
* @spec http://www.w3.org/TR/2011/REC-css3-color-20110607/
10+
* @spec https://www.w3.org/TR/2016/WD-css-color-4-20160705/
1111
*/
1212
public class CssColorCSS3 {
1313
protected static final HashMap<String, RGB> definedRGBColorsCSS3;
@@ -34,7 +34,7 @@ public static String getSystem(String ident) {
3434

3535
static {
3636
trans = new RGBA(0,0,0,0.f);
37-
// http://www.w3.org/TR/2011/REC-css3-color-20110607/#svg-color
37+
// https://www.w3.org/TR/2016/WD-css-color-4-20160705/#named-colors
3838
definedRGBColorsCSS3 = new HashMap<String, RGB>();
3939

4040
definedRGBColorsCSS3.put("aliceblue", new RGB(240, 248, 255));
@@ -156,6 +156,7 @@ public static String getSystem(String ident) {
156156
definedRGBColorsCSS3.put("plum", new RGB(221, 160, 221));
157157
definedRGBColorsCSS3.put("powderblue", new RGB(176, 224, 230));
158158
definedRGBColorsCSS3.put("purple", new RGB(128, 0, 128));
159+
definedRGBColorsCSS3.put("rebeccapurple", new RGB(102, 51, 153));
159160
definedRGBColorsCSS3.put("red", new RGB(255, 0, 0));
160161
definedRGBColorsCSS3.put("rosybrown", new RGB(188, 143, 143));
161162
definedRGBColorsCSS3.put("royalblue", new RGB(65, 105, 225));

org/w3c/css/values/CssColorCSS4.java

Lines changed: 0 additions & 189 deletions
This file was deleted.

0 commit comments

Comments
 (0)