Skip to content

Commit ddf6091

Browse files
committed
do not forget the quad-comma separated value known as 'old syntax'
1 parent d56e63d commit ddf6091

1 file changed

Lines changed: 40 additions & 25 deletions

File tree

org/w3c/css/values/CssColor.java

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -273,33 +273,48 @@ public void setModernRGBColor(CssExpression exp, ApplContext ac)
273273
}
274274
exp.next();
275275

276+
// check for optional alpha channel
276277
if (!exp.end()) {
277-
if (op != SPACE) {
278-
throw new InvalidParamException("invalid-color", ac);
279-
}
280-
// now we need an alpha.
281-
val = exp.getValue();
282-
op = exp.getOperator();
278+
// care for old syntax
279+
if (op == COMMA && !separator_space) {
280+
val = exp.getValue();
281+
switch (val.getType()) {
282+
case CssTypes.CSS_NUMBER:
283+
case CssTypes.CSS_PERCENTAGE:
284+
rgba.setAlpha(ac, val);
285+
break;
286+
default:
287+
throw new InvalidParamException("rgb", val, ac);
288+
}
289+
} else {
290+
// otherwise modern syntax
291+
if (op != SPACE) {
292+
throw new InvalidParamException("invalid-color", ac);
293+
}
294+
// now we need an alpha.
295+
val = exp.getValue();
296+
op = exp.getOperator();
283297

284-
if (val.getType() != CssTypes.CSS_SWITCH) {
285-
throw new InvalidParamException("rgb", val, ac);
286-
}
287-
if (op != SPACE) {
288-
throw new InvalidParamException("invalid-color", ac);
289-
}
290-
exp.next();
291-
// now we get the alpha value
292-
if (exp.end()) {
293-
throw new InvalidParamException("rgb", exp.getValue(), ac);
294-
}
295-
val = exp.getValue();
296-
switch (val.getType()) {
297-
case CssTypes.CSS_NUMBER:
298-
case CssTypes.CSS_PERCENTAGE:
299-
rgba.setAlpha(ac, val);
300-
break;
301-
default:
298+
if (val.getType() != CssTypes.CSS_SWITCH) {
302299
throw new InvalidParamException("rgb", val, ac);
300+
}
301+
if (op != SPACE) {
302+
throw new InvalidParamException("invalid-color", ac);
303+
}
304+
exp.next();
305+
// now we get the alpha value
306+
if (exp.end()) {
307+
throw new InvalidParamException("rgb", exp.getValue(), ac);
308+
}
309+
val = exp.getValue();
310+
switch (val.getType()) {
311+
case CssTypes.CSS_NUMBER:
312+
case CssTypes.CSS_PERCENTAGE:
313+
rgba.setAlpha(ac, val);
314+
break;
315+
default:
316+
throw new InvalidParamException("rgb", val, ac);
317+
}
303318
}
304319
exp.next();
305320

@@ -501,7 +516,7 @@ public void setRGBAColor(CssExpression exp, ApplContext ac)
501516
throw new InvalidParamException("notversion", sb.toString(),
502517
ac.getCssVersionString(), ac);
503518
}
504-
setModernRGBColor(exp,ac);
519+
setModernRGBColor(exp, ac);
505520
}
506521

507522
// use only for atsc profile, superseded by setModernRGBColor

0 commit comments

Comments
 (0)