Skip to content

Commit 99afe5f

Browse files
committed
fixing RGB to allow non-numerical values (might need more work)
1 parent a59c0aa commit 99afe5f

14 files changed

Lines changed: 169 additions & 103 deletions

org/w3c/css/values/CssAngle.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ public void checkEqualsZero(ApplContext ac, String callername)
229229
* @param ac the validation context
230230
* @param callername the String value of the object it is defined in
231231
*/
232-
public void warnEqualsZero(ApplContext ac, String callername) {
233-
warnEqualsZero(ac, new String[]{"angle", callername});
232+
public boolean warnEqualsZero(ApplContext ac, String callername) {
233+
return warnEqualsZero(ac, new String[]{"angle", callername});
234234
}
235235

236236
}

org/w3c/css/values/CssAttr.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,13 @@ public void checkInteger(ApplContext ac, String callername)
307307
* @param ac the validation context
308308
* @param property the property the value is defined in
309309
*/
310-
public void warnPositiveness(ApplContext ac, CssProperty property) {
310+
public boolean warnPositiveness(ApplContext ac, CssProperty property) {
311311
// TODO do our best...
312312
if (false/*!isPositive()*/) {
313313
ac.getFrame().addWarning("negative", toString());
314+
return false;
314315
}
316+
return true;
315317
}
316318

317319
public CssLength getLength() throws InvalidParamException {
@@ -377,10 +379,12 @@ public void checkEqualsZero(ApplContext ac, String callername)
377379
* @param ac the validation context
378380
* @param callername the property the value is defined in
379381
*/
380-
public void warnEqualsZero(ApplContext ac, String callername) {
382+
public boolean warnEqualsZero(ApplContext ac, String callername) {
381383
// TODO should we do that only for CSS_NUMBER type?
382384
if (!isZero()) {
383385
ac.getFrame().addWarning("dynamic", new String[]{toString(), callername});
386+
return false;
384387
}
388+
return true;
385389
}
386390
}

org/w3c/css/values/CssCalc.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,13 @@ public void checkInteger(ApplContext ac, String callername)
356356
* @param ac the validation context
357357
* @param callername the property the value is defined in
358358
*/
359-
public void warnPositiveness(ApplContext ac, String callername) {
359+
public boolean warnPositiveness(ApplContext ac, String callername) {
360360
// TODO do our best...
361361
if (false/*!isPositive()*/) {
362362
ac.getFrame().addWarning("negative", toString());
363+
return false;
363364
}
365+
return true;
364366
}
365367

366368
public CssLength getLength() throws InvalidParamException {
@@ -455,10 +457,12 @@ public void checkEqualsZero(ApplContext ac, String callername)
455457
* @param ac the validation context
456458
* @param callername the property the value is defined in
457459
*/
458-
public void warnEqualsZero(ApplContext ac, String callername) {
460+
public boolean warnEqualsZero(ApplContext ac, String callername) {
459461
// TODO should we do that only for CSS_NUMBER type?
460462
if (!isZero()) {
461463
ac.getFrame().addWarning("dynamic", toString());
464+
return false;
462465
}
466+
return true;
463467
}
464468
}

org/w3c/css/values/CssCheckableValue.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,12 @@ public void checkStrictPositiveness(ApplContext ac, CssProperty property)
107107
* @param ac the validation context
108108
* @param callername the property the value is defined in
109109
*/
110-
public void warnPositiveness(ApplContext ac, String callername) {
110+
public boolean warnPositiveness(ApplContext ac, String callername) {
111111
if (!isPositive()) {
112112
ac.getFrame().addWarning("negative", new String[]{toString(), callername});
113+
return false;
113114
}
115+
return true;
114116
}
115117

116118
/**
@@ -119,8 +121,8 @@ public void warnPositiveness(ApplContext ac, String callername) {
119121
* @param ac the validation context
120122
* @param property the property the value is defined in
121123
*/
122-
public void warnPositiveness(ApplContext ac, CssProperty property) {
123-
warnPositiveness(ac, property.getPropertyName());
124+
public boolean warnPositiveness(ApplContext ac, CssProperty property) {
125+
return warnPositiveness(ac, property.getPropertyName());
124126
}
125127

126128
/**
@@ -129,8 +131,8 @@ public void warnPositiveness(ApplContext ac, CssProperty property) {
129131
* @param ac the validation context
130132
* @param mediafeature the property the value is defined in
131133
*/
132-
public void warnPositiveness(ApplContext ac, MediaFeature mediafeature) {
133-
warnPositiveness(ac, mediafeature.getFeatureName());
134+
public boolean warnPositiveness(ApplContext ac, MediaFeature mediafeature) {
135+
return warnPositiveness(ac, mediafeature.getFeatureName());
134136
}
135137

136138

@@ -191,10 +193,12 @@ public void checkEqualsZero(ApplContext ac, MediaFeature mediafeature)
191193
* @param ac the validation context
192194
* @param messages an array of Strings
193195
*/
194-
public void warnEqualsZero(ApplContext ac, String[] messages) {
196+
public boolean warnEqualsZero(ApplContext ac, String[] messages) {
195197
if (!isZero()) {
196198
ac.getFrame().addWarning("zero", messages);
199+
return false;
197200
}
201+
return true;
198202
}
199203

200204
/**
@@ -203,8 +207,8 @@ public void warnEqualsZero(ApplContext ac, String[] messages) {
203207
* @param ac the validation context
204208
* @param callername the String value of the object it is defined in
205209
*/
206-
public void warnEqualsZero(ApplContext ac, String callername) {
207-
warnEqualsZero(ac, new String[]{callername});
210+
public boolean warnEqualsZero(ApplContext ac, String callername) {
211+
return warnEqualsZero(ac, new String[]{callername});
208212
}
209213

210214
/**
@@ -213,8 +217,8 @@ public void warnEqualsZero(ApplContext ac, String callername) {
213217
* @param ac the validation context
214218
* @param property the property the value is defined in
215219
*/
216-
public void warnEqualsZero(ApplContext ac, CssProperty property) {
217-
warnEqualsZero(ac, property.getPropertyName());
220+
public boolean warnEqualsZero(ApplContext ac, CssProperty property) {
221+
return warnEqualsZero(ac, property.getPropertyName());
218222
}
219223

220224
/**
@@ -223,8 +227,8 @@ public void warnEqualsZero(ApplContext ac, CssProperty property) {
223227
* @param ac the validation context
224228
* @param mediafeature the property the value is defined in
225229
*/
226-
public void warnEqualsZero(ApplContext ac, MediaFeature mediafeature) {
227-
warnEqualsZero(ac, mediafeature.getFeatureName());
230+
public boolean warnEqualsZero(ApplContext ac, MediaFeature mediafeature) {
231+
return warnEqualsZero(ac, mediafeature.getFeatureName());
228232
}
229233

230234
public boolean isInteger() {

org/w3c/css/values/CssColor.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,12 @@ public void setRGBColor(CssExpression exp, ApplContext ac)
113113

114114
switch (val.getType()) {
115115
case CssTypes.CSS_NUMBER:
116-
CssNumber number = (CssNumber) val;
117-
rgb.setRed(clippedIntValue(number.getInt(), ac));
118116
rgb.setPercent(false);
117+
rgb.setRed(ac, val);
119118
break;
120119
case CssTypes.CSS_PERCENTAGE:
121-
CssPercentage percent = (CssPercentage) val;
122-
rgb.setRed(clippedPercentValue(percent.floatValue(), ac));
123120
rgb.setPercent(true);
121+
rgb.setRed(ac, val);
124122
break;
125123
default:
126124
throw new InvalidParamException("rgb", val, ac);
@@ -139,15 +137,13 @@ public void setRGBColor(CssExpression exp, ApplContext ac)
139137
if (rgb.isPercent()) {
140138
throw new InvalidParamException("percent", val, ac);
141139
}
142-
CssNumber number = (CssNumber) val;
143-
rgb.setGreen(clippedIntValue(number.getInt(), ac));
140+
rgb.setGreen(ac, val);
144141
break;
145142
case CssTypes.CSS_PERCENTAGE:
146143
if (!rgb.isPercent()) {
147144
throw new InvalidParamException("integer", val, ac);
148145
}
149-
CssPercentage percent = (CssPercentage) val;
150-
rgb.setGreen(clippedPercentValue(percent.floatValue(), ac));
146+
rgb.setGreen(ac, val);
151147
break;
152148
default:
153149
throw new InvalidParamException("rgb", val, ac);
@@ -166,15 +162,13 @@ public void setRGBColor(CssExpression exp, ApplContext ac)
166162
if (rgb.isPercent()) {
167163
throw new InvalidParamException("percent", val, ac);
168164
}
169-
CssNumber number = (CssNumber) val;
170-
rgb.setBlue(clippedIntValue(number.getInt(), ac));
165+
rgb.setBlue(ac, val);
171166
break;
172167
case CssTypes.CSS_PERCENTAGE:
173168
if (!rgb.isPercent()) {
174169
throw new InvalidParamException("integer", val, ac);
175170
}
176-
CssPercentage percent = (CssPercentage) val;
177-
rgb.setBlue(clippedPercentValue(percent.floatValue(), ac));
171+
rgb.setBlue(ac, val);
178172
break;
179173
default:
180174
throw new InvalidParamException("rgb", val, ac);
@@ -248,7 +242,8 @@ public void setShortRGBColor(String s, ApplContext ac)
248242

249243
color = null;
250244
rgb = new RGB(r, g, b);
251-
rgb.output = s;
245+
// we force the specific display of it
246+
rgb.setRepresentationString(s);
252247
}
253248

254249
protected boolean computeIdentColor(HashMap<String, Object> definitions,

org/w3c/css/values/CssFlexibleLength.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ public void checkEqualsZero(ApplContext ac, String callername)
179179
* @param ac the validation context
180180
* @param callername the String value of the object it is defined in
181181
*/
182-
public void warnEqualsZero(ApplContext ac, String callername) {
183-
warnEqualsZero(ac, new String[]{"length", callername});
182+
public boolean warnEqualsZero(ApplContext ac, String callername) {
183+
return warnEqualsZero(ac, new String[]{"length", callername});
184184
}
185185

186186
}

org/w3c/css/values/CssFrequency.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ public void checkEqualsZero(ApplContext ac, String callername)
199199
* @param ac the validation context
200200
* @param callername the String value of the object it is defined in
201201
*/
202-
public void warnEqualsZero(ApplContext ac, String callername) {
203-
warnEqualsZero(ac, new String[]{"frequency", callername});
202+
public boolean warnEqualsZero(ApplContext ac, String callername) {
203+
return warnEqualsZero(ac, new String[]{"frequency", callername});
204204
}
205205

206206
}

org/w3c/css/values/CssLength.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ public void checkEqualsZero(ApplContext ac, String callername)
278278
* @param ac the validation context
279279
* @param callername the String value of the object it is defined in
280280
*/
281-
public void warnEqualsZero(ApplContext ac, String callername) {
282-
warnEqualsZero(ac, new String[]{"length", callername});
281+
public boolean warnEqualsZero(ApplContext ac, String callername) {
282+
return warnEqualsZero(ac, new String[]{"length", callername});
283283
}
284284

285285
}

org/w3c/css/values/CssNumber.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ public void checkEqualsZero(ApplContext ac, String callername)
328328
* @param ac the validation context
329329
* @param callername the String value of the object it is defined in
330330
*/
331-
public void warnEqualsZero(ApplContext ac, String callername) {
332-
warnEqualsZero(ac, new String[]{"unit", callername});
331+
public boolean warnEqualsZero(ApplContext ac, String callername) {
332+
return warnEqualsZero(ac, new String[]{"unit", callername});
333333
}
334334

335335
/**

org/w3c/css/values/CssPercentage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ public void checkEqualsZero(ApplContext ac, String callername)
227227
* @param ac the validation context
228228
* @param callername the String value of the object it is defined in
229229
*/
230-
public void warnEqualsZero(ApplContext ac, String callername) {
231-
warnEqualsZero(ac, new String[]{"percentage", callername});
230+
public boolean warnEqualsZero(ApplContext ac, String callername) {
231+
return warnEqualsZero(ac, new String[]{"percentage", callername});
232232
}
233233

234234
}

0 commit comments

Comments
 (0)