Skip to content

Commit 6f1e40c

Browse files
committed
old values from the SVG REC are now deprecated and emit a warning, the old SVG-only profile still accept those as valid without the new values. CSS3+SVG uses the CSS3 definition over SVG.
1 parent b89537e commit 6f1e40c

File tree

3 files changed

+116
-1
lines changed

3 files changed

+116
-1
lines changed

org/w3c/css/properties/CSS3Properties.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ transform: org.w3c.css.properties.css3.CssTransform
203203
object-fit: org.w3c.css.properties.css3.CssObjectFit
204204
object-position: org.w3c.css.properties.css3.CssObjectPosition
205205
image-orientation: org.w3c.css.properties.css3.CssImageOrientation
206+
image-rendering: org.w3c.css.properties.css3.CssImageRendering
206207
image-resolution: org.w3c.css.properties.css3.CssImageResolution
207208

208209
# http://www.w3.org/TR/2009/CR-css3-background-20091217/

org/w3c/css/properties/CSS3SVGProperties.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ color-interpolation: org.w3c.css.properties.svg.CssColorInter
33
color-rendering: org.w3c.css.properties.svg.CssColorRendering
44
fill-opacity: org.w3c.css.properties.svg.CssFillOpacity
55
fill-rule: org.w3c.css.properties.svg.CssFillRule
6-
image-rendering: org.w3c.css.properties.svg.CssImageRendering
76
shape-rendering: org.w3c.css.properties.svg.CssShapeRendering
87
stroke-dasharray: org.w3c.css.properties.svg.CssStrokeDasharray
98
stroke-dashoffset: org.w3c.css.properties.svg.CssStrokeDashoffset
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
//
2+
// Author: Yves Lafon <ylafon@w3.org>
3+
//
4+
// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2019.
5+
// Please first read the full copyright statement in file COPYRIGHT.html
6+
package org.w3c.css.properties.css3;
7+
8+
import org.w3c.css.util.ApplContext;
9+
import org.w3c.css.util.InvalidParamException;
10+
import org.w3c.css.values.CssExpression;
11+
import org.w3c.css.values.CssIdent;
12+
import org.w3c.css.values.CssTypes;
13+
import org.w3c.css.values.CssValue;
14+
15+
/**
16+
* @spec https://www.w3.org/TR/2019/CR-css-images-3-20191010/#propdef-image-rendering
17+
*/
18+
public class CssImageRendering extends org.w3c.css.properties.css.CssImageRendering {
19+
20+
public static final CssIdent[] allowed_values, deprecated_values;
21+
22+
static {
23+
String[] _deprecated_values = {"optimizeSpeed", "optimizeQuality"};
24+
String[] _allowed_values = {"auto", "smooth", "high-quality", "crisp-edges", "pixelated"};
25+
26+
allowed_values = new CssIdent[_allowed_values.length];
27+
int i = 0;
28+
for (String s : _allowed_values) {
29+
allowed_values[i++] = CssIdent.getIdent(s);
30+
}
31+
32+
deprecated_values = new CssIdent[_deprecated_values.length];
33+
i = 0;
34+
for (String s : _deprecated_values) {
35+
deprecated_values[i++] = CssIdent.getIdent(s);
36+
}
37+
38+
}
39+
40+
public static final CssIdent getAllowedValue(CssIdent ident) {
41+
for (CssIdent id : allowed_values) {
42+
if (id.equals(ident)) {
43+
return id;
44+
}
45+
}
46+
return null;
47+
}
48+
49+
public static final CssIdent getDeprecatedValue(CssIdent ident) {
50+
for (CssIdent id : deprecated_values) {
51+
if (id.equals(ident)) {
52+
return id;
53+
}
54+
}
55+
return null;
56+
}
57+
58+
/**
59+
* Create a new CssImageRendering
60+
*/
61+
public CssImageRendering() {
62+
value = initial;
63+
}
64+
65+
/**
66+
* Creates a new CssImageRendering
67+
*
68+
* @param expression The expression for this property
69+
* @throws org.w3c.css.util.InvalidParamException
70+
* Expressions are incorrect
71+
*/
72+
public CssImageRendering(ApplContext ac, CssExpression expression, boolean check)
73+
throws InvalidParamException {
74+
if (check && expression.getCount() > 1) {
75+
throw new InvalidParamException("unrecognize", ac);
76+
}
77+
setByUser();
78+
79+
CssValue val;
80+
char op;
81+
82+
val = expression.getValue();
83+
op = expression.getOperator();
84+
85+
if (val.getType() == CssTypes.CSS_IDENT) {
86+
CssIdent ident = (CssIdent) val;
87+
if (inherit.equals(ident)) {
88+
value = inherit;
89+
} else {
90+
value = getAllowedValue(ident);
91+
if (value == null) {
92+
value = getDeprecatedValue(ident);
93+
if (value == null) {
94+
throw new InvalidParamException("value",
95+
val.toString(),
96+
getPropertyName(), ac);
97+
}
98+
ac.getFrame().addWarning("deprecated", value.toString());
99+
}
100+
}
101+
} else {
102+
throw new InvalidParamException("value",
103+
val.toString(),
104+
getPropertyName(), ac);
105+
}
106+
expression.next();
107+
}
108+
109+
public CssImageRendering(ApplContext ac, CssExpression expression)
110+
throws InvalidParamException {
111+
this(ac, expression, false);
112+
}
113+
114+
}
115+

0 commit comments

Comments
 (0)