Skip to content

Commit cea339d

Browse files
committed
modernized and removed all problematic casts to allow use of css3 variables (and other shifting types)
1 parent c6b6f58 commit cea339d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+285
-346
lines changed

org/w3c/css/properties/svg/CssAlignmentBaseline.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public CssAlignmentBaseline() {
5151
* Creates a new CssAlignmentBaseline
5252
*
5353
* @param expression The expression for this property
54-
* @throws org.w3c.css.util.InvalidParamException
55-
* Expressions are incorrect
54+
* @throws org.w3c.css.util.InvalidParamException Expressions are incorrect
5655
*/
5756
public CssAlignmentBaseline(ApplContext ac, CssExpression expression, boolean check)
5857
throws InvalidParamException {
@@ -66,16 +65,19 @@ public CssAlignmentBaseline(ApplContext ac, CssExpression expression, boolean ch
6665
val = expression.getValue();
6766

6867
if (val.getType() == CssTypes.CSS_IDENT) {
69-
CssIdent id = (CssIdent) val;
70-
if (inherit.equals(id)) {
71-
value = inherit;
68+
CssIdent id = val.getIdent();
69+
if (CssIdent.isCssWide(id)) {
70+
value = val;
7271
} else {
73-
value = getAllowedIdent(id);
74-
if (value == null) {
72+
if (getAllowedIdent(id) == null) {
7573
// we also check if CSS version is CSS3 and onward.
7674
if (ac.getCssVersion().compareTo(CssVersion.CSS3) >= 0) {
77-
value = org.w3c.css.properties.css3.CssAlignmentBaseline.getAllowedIdent(id);
78-
}
75+
if (org.w3c.css.properties.css3.CssAlignmentBaseline.getAllowedIdent(id) != null) {
76+
value = val;
77+
}
78+
}
79+
} else {
80+
value = val;
7981
}
8082
if (value == null) {
8183
throw new InvalidParamException("value",

org/w3c/css/properties/svg/CssBaselineShift.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public static final CssIdent getAllowedIdent(CssIdent ident) {
4444
* Creates a new CssBaselineShift
4545
*
4646
* @param expression The expression for this property
47-
* @throws org.w3c.css.util.InvalidParamException
48-
* Expressions are incorrect
47+
* @throws org.w3c.css.util.InvalidParamException Expressions are incorrect
4948
*/
5049
public CssBaselineShift(ApplContext ac, CssExpression expression, boolean check)
5150
throws InvalidParamException {
@@ -61,19 +60,19 @@ public CssBaselineShift(ApplContext ac, CssExpression expression, boolean check)
6160
switch (val.getType()) {
6261
case CssTypes.CSS_NUMBER:
6362
// zero is a valid length. otherwise it will fail.
64-
val.getLength();
63+
val.getCheckableValue().checkEqualsZero(ac, getPropertyName());
6564
case CssTypes.CSS_LENGTH:
6665
case CssTypes.CSS_PERCENTAGE:
6766
value = val;
6867
break;
6968
case CssTypes.CSS_IDENT:
70-
CssIdent id = (CssIdent) val;
71-
if (inherit.equals(id)) {
72-
value = inherit;
69+
CssIdent id = val.getIdent();
70+
if (CssIdent.isCssWide(id)) {
71+
value = val;
7372
break;
7473
}
75-
value = getAllowedIdent(id);
76-
if (value != null) {
74+
if (getAllowedIdent(id) != null) {
75+
value = val;
7776
break;
7877
}
7978
// unrecognized ident -> fail.

org/w3c/css/properties/svg/CssClipPath.java

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ public CssClipPath() {
8989
* Creates a new CssClipPath
9090
*
9191
* @param expression The expression for this property
92-
* @throws org.w3c.css.util.InvalidParamException
93-
* Expressions are incorrect
92+
* @throws org.w3c.css.util.InvalidParamException Expressions are incorrect
9493
*/
9594
public CssClipPath(ApplContext ac, CssExpression expression, boolean check)
9695
throws InvalidParamException {
@@ -110,7 +109,7 @@ public CssClipPath(ApplContext ac, CssExpression expression, boolean check)
110109
switch (val.getType()) {
111110
case CssTypes.CSS_FUNCTION:
112111
if (!gotBasicShape) {
113-
CssFunction func = (CssFunction) val;
112+
CssFunction func = val.getFunction();
114113
String funcname = func.getName().toLowerCase();
115114
switch (funcname) {
116115
case "inset":
@@ -139,19 +138,19 @@ public CssClipPath(ApplContext ac, CssExpression expression, boolean check)
139138
value = val;
140139
break;
141140
case CssTypes.CSS_IDENT:
142-
if (inherit.equals(val)) {
143-
value = inherit;
141+
CssIdent id = val.getIdent();
142+
if (CssIdent.isCssWide(id)) {
143+
value = val;
144144
break;
145145
}
146-
if (none.equals(val)) {
147-
value = none;
146+
if (none.equals(id)) {
147+
value = val;
148148
break;
149149
}
150150
if (!gotGeometryBox) {
151-
CssIdent ident = getGeometryBoxAllowedValue((CssIdent) val);
152-
if (ident != null) {
151+
if (getGeometryBoxAllowedValue(id) != null) {
153152
gotGeometryBox = true;
154-
values.add(ident);
153+
values.add(val);
155154
break;
156155
}
157156
}
@@ -198,7 +197,7 @@ protected static void checkInsetFunction(ApplContext ac, CssExpression expressio
198197
}
199198
break;
200199
case CssTypes.CSS_IDENT:
201-
if (inset_round.equals((CssIdent) val)) {
200+
if (inset_round.equals(val.getIdent())) {
202201
// the remainder must be a border-radius
203202
CssExpression nex = new CssExpression();
204203
expression.next();
@@ -253,9 +252,8 @@ protected static void checkCircleFunction(ApplContext ac, CssExpression expressi
253252
gotRadius = true;
254253
break;
255254
case CssTypes.CSS_IDENT:
256-
CssIdent ident = (CssIdent) val;
257-
CssIdent id = getShapeRadiusAllowedValue(ident);
258-
if (id != null) {
255+
CssIdent ident = val.getIdent();
256+
if (getShapeRadiusAllowedValue(ident) != null) {
259257
if (gotRadius) {
260258
throw new InvalidParamException("unrecognize", ac);
261259
}
@@ -318,9 +316,8 @@ protected static void checkEllipseFunction(ApplContext ac, CssExpression express
318316
nbRadius++;
319317
break;
320318
case CssTypes.CSS_IDENT:
321-
CssIdent ident = (CssIdent) val;
322-
CssIdent id = getShapeRadiusAllowedValue(ident);
323-
if (id != null) {
319+
CssIdent ident = val.getIdent();
320+
if (getShapeRadiusAllowedValue(ident) != null) {
324321
if (nbRadius >= 2) {
325322
throw new InvalidParamException("unrecognize", ac);
326323
}
@@ -385,9 +382,7 @@ protected static void checkPolygonFunction(ApplContext ac, CssExpression express
385382
case CssTypes.CSS_IDENT:
386383
// can only happen at the beginning.
387384
if (!gotFillRule && nbPoints == 0 && nbShapeArgs == 0) {
388-
CssIdent ident = (CssIdent) val;
389-
CssIdent id = CssFillRule.getAllowedIdent(ident);
390-
if (id != null) {
385+
if (CssFillRule.getAllowedIdent(val.getIdent()) != null) {
391386
gotFillRule = true;
392387
break;
393388
}

org/w3c/css/properties/svg/CssClipRule.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public CssClipRule() {
5050
* Creates a new CssClipRule
5151
*
5252
* @param expression The expression for this property
53-
* @throws org.w3c.css.util.InvalidParamException
54-
* Expressions are incorrect
53+
* @throws org.w3c.css.util.InvalidParamException Expressions are incorrect
5554
*/
5655
public CssClipRule(ApplContext ac, CssExpression expression, boolean check)
5756
throws InvalidParamException {
@@ -68,16 +67,13 @@ public CssClipRule(ApplContext ac, CssExpression expression, boolean check)
6867
getPropertyName(), ac);
6968
}
7069
// ident, so inherit, or allowed value
71-
if (inherit.equals(val)) {
72-
value = inherit;
73-
} else {
74-
val = getAllowedIdent((CssIdent) val);
75-
if (val == null) {
76-
throw new InvalidParamException("value",
77-
expression.getValue(),
78-
getPropertyName(), ac);
79-
}
70+
CssIdent id = val.getIdent();
71+
if (CssIdent.isCssWide(id) || getAllowedIdent(id) != null) {
8072
value = val;
73+
} else {
74+
throw new InvalidParamException("value",
75+
expression.getValue(),
76+
getPropertyName(), ac);
8177
}
8278
expression.next();
8379
}

org/w3c/css/properties/svg/CssColorInterpolation.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ public CssColorInterpolation() {
4848
* Creates a new CssColorInterpolation
4949
*
5050
* @param expression The expression for this property
51-
* @throws org.w3c.css.util.InvalidParamException
52-
* Expressions are incorrect
51+
* @throws org.w3c.css.util.InvalidParamException Expressions are incorrect
5352
*/
5453
public CssColorInterpolation(ApplContext ac, CssExpression expression, boolean check)
5554
throws InvalidParamException {
@@ -64,18 +63,14 @@ public CssColorInterpolation(ApplContext ac, CssExpression expression, boolean c
6463
val = expression.getValue();
6564
op = expression.getOperator();
6665

67-
if (val.getType() == CssTypes.CSS_IDENT) {
68-
CssIdent ident = (CssIdent) val;
69-
if (inherit.equals(ident)) {
70-
value = inherit;
71-
} else {
72-
value = getAllowedValue(ident);
73-
if (value == null) {
74-
throw new InvalidParamException("value",
75-
val.toString(),
76-
getPropertyName(), ac);
77-
}
78-
}
66+
if (val.getType() != CssTypes.CSS_IDENT) {
67+
throw new InvalidParamException("value",
68+
expression.getValue(),
69+
getPropertyName(), ac);
70+
}
71+
CssIdent ident = val.getIdent();
72+
if (CssIdent.isCssWide(ident) || (getAllowedValue(ident) != null)) {
73+
value = val;
7974
} else {
8075
throw new InvalidParamException("value",
8176
val.toString(),

org/w3c/css/properties/svg/CssColorProfile.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,13 @@ public CssColorProfile(ApplContext ac, CssExpression expression, boolean check)
5151
value = val;
5252
break;
5353
case CssTypes.CSS_IDENT:
54-
if (inherit.equals(val)) {
55-
value = inherit;
54+
CssIdent id = val.getIdent();
55+
if (CssIdent.isCssWide(id)) {
56+
value = val;
5657
break;
5758
}
58-
if (sRBG.equals(val)) {
59-
value = sRBG;
59+
if (sRBG.equals(id)) {
60+
value = val;
6061
break;
6162
}
6263
// or else it's a name

org/w3c/css/properties/svg/CssColorRendering.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,14 @@ public CssColorRendering(ApplContext ac, CssExpression expression, boolean check
6464
val = expression.getValue();
6565
op = expression.getOperator();
6666

67-
if (val.getType() == CssTypes.CSS_IDENT) {
68-
CssIdent ident = (CssIdent) val;
69-
if (inherit.equals(ident)) {
70-
value = inherit;
71-
} else {
72-
value = getAllowedValue(ident);
73-
if (value == null) {
74-
throw new InvalidParamException("value",
75-
val.toString(),
76-
getPropertyName(), ac);
77-
}
78-
}
67+
if (val.getType() != CssTypes.CSS_IDENT) {
68+
throw new InvalidParamException("value",
69+
expression.getValue(),
70+
getPropertyName(), ac);
71+
}
72+
CssIdent ident = val.getIdent();
73+
if (CssIdent.isCssWide(ident) || (getAllowedValue(ident) != null)) {
74+
value = val;
7975
} else {
8076
throw new InvalidParamException("value",
8177
val.toString(),

org/w3c/css/properties/svg/CssDominantBaseline.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,19 @@ public CssDominantBaseline(ApplContext ac, CssExpression expression, boolean che
6565
val = expression.getValue();
6666

6767
if (val.getType() == CssTypes.CSS_IDENT) {
68-
CssIdent id = (CssIdent) val;
69-
if (inherit.equals(id)) {
70-
value = inherit;
68+
CssIdent id = val.getIdent();
69+
if (CssIdent.isCssWide(id)) {
70+
value = val;
7171
} else {
72-
value = getAllowedIdent(id);
73-
if (value == null) {
72+
if (getAllowedIdent(id) == null) {
7473
// we also check if CSS version is CSS3 and onward.
7574
if (ac.getCssVersion().compareTo(CssVersion.CSS3) >= 0) {
76-
value = org.w3c.css.properties.css3.CssDominantBaseline.getAllowedIdent(id);
75+
if (org.w3c.css.properties.css3.CssDominantBaseline.getAllowedIdent(id) != null) {
76+
value = val;
77+
}
7778
}
79+
} else {
80+
value = val;
7881
}
7982
if (value == null) {
8083
throw new InvalidParamException("value",

org/w3c/css/properties/svg/CssEnableBackground.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,27 @@ public CssEnableBackground(ApplContext ac, CssExpression expression, boolean che
6767
values.add(val);
6868
break;
6969
case CssTypes.CSS_IDENT:
70-
if (inherit.equals(val)) {
70+
CssIdent id = val.getIdent();
71+
if (CssIdent.isCssWide(id)) {
7172
if (expression.getCount() > 1) {
7273
throw new InvalidParamException("value",
7374
val.toString(),
7475
getPropertyName(), ac);
7576
}
76-
value = inherit;
77+
value = val;
7778
break;
7879
}
79-
if (accumulate.equals(val)) {
80+
if (accumulate.equals(id)) {
8081
if (expression.getCount() > 1) {
8182
throw new InvalidParamException("value",
8283
val.toString(),
8384
getPropertyName(), ac);
8485
}
85-
value = accumulate;
86+
value = val;
8687
break;
8788
}
88-
if (id_new.equals(val) && !got_new) {
89-
values.add(id_new);
89+
if (id_new.equals(id) && !got_new) {
90+
values.add(val);
9091
got_new = true;
9192
break;
9293
}

org/w3c/css/properties/svg/CssFill.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ public CssFill() {
4343
* Creates a new CssFill
4444
*
4545
* @param expression The expression for this property
46-
* @throws org.w3c.css.util.InvalidParamException
47-
* Expressions are incorrect
46+
* @throws org.w3c.css.util.InvalidParamException Expressions are incorrect
4847
*/
4948
public CssFill(ApplContext ac, CssExpression expression, boolean check)
5049
throws InvalidParamException {
@@ -168,7 +167,7 @@ static CssValue parsePaint(ApplContext ac, CssExpression expression,
168167
values.add(val);
169168
break;
170169
case CssTypes.CSS_FUNCTION:
171-
CssFunction f = (CssFunction) val;
170+
CssFunction f = val.getFunction();
172171
if (gotColor || gotFuncIRI || gotIccColor) {
173172
throw new InvalidParamException("value",
174173
val.toString(),

org/w3c/css/properties/svg/CssFillOpacity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.w3c.css.util.InvalidParamException;
1010
import org.w3c.css.util.Util;
1111
import org.w3c.css.values.CssExpression;
12+
import org.w3c.css.values.CssIdent;
1213
import org.w3c.css.values.CssNumber;
1314
import org.w3c.css.values.CssTypes;
1415
import org.w3c.css.values.CssValue;
@@ -72,8 +73,8 @@ public CssFillOpacity(ApplContext ac, CssExpression expression, boolean check)
7273
value = val;
7374
break;
7475
case CssTypes.CSS_IDENT:
75-
if (inherit.equals(val)) {
76-
value = inherit;
76+
if (CssIdent.isCssWide(val.getIdent())) {
77+
value = val;
7778
break;
7879
}
7980
default:

0 commit comments

Comments
 (0)