Skip to content

Commit c458d13

Browse files
committed
Revert "prepare for partial analysis of css variable, when a single default is present, alter parsing for normal paramaters (need more work for nested declaration), currently only a failed attempt to just ignore)"
This reverts commit 539e93a.
1 parent 67f5db2 commit c458d13

File tree

11 files changed

+14
-337
lines changed

11 files changed

+14
-337
lines changed

org/w3c/css/parser/CssFouffa.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,7 @@ public CssProperty handleDeclaration(String property, CssExpression expression,
587587
if (Util.onDebug) {
588588
System.err.println("Creating " + property + ": " + expression);
589589
}
590-
if (property.startsWith("--")) {
591-
// css variable
592-
}
590+
593591
final CssValue lastValue = expression.getLastValue();
594592

595593
if (allowBackslash9Hack() && lastValue != null && lastValue.hasBackslash9Hack()) {

org/w3c/css/parser/CssPropertyFactory.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,6 @@ public synchronized CssProperty createProperty(ApplContext ac, AtRule atRule, St
253253
throw new WarningParamException("vendor-extension", expression.toStringFromStart());
254254
}
255255

256-
if (expression.hasCssVariable()) {
257-
throw new WarningParamException("css-variable", expression.toStringFromStart());
258-
}
259-
260256
if (ac.getTreatCssHacksAsWarnings() && expression.hasCssHack()) {
261257
throw new WarningParamException("css-hack", expression.toStringFromStart());
262258
}

org/w3c/css/parser/analyzer/CssParser.jj

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ import org.w3c.css.values.CssRatio;
5959
import org.w3c.css.values.CssSemitone;
6060
import org.w3c.css.values.CssTypes;
6161
import org.w3c.css.values.CssVolume;
62-
import org.w3c.css.values.CssVariable;
6362
import org.w3c.css.properties.css.CssProperty;
6463
import org.w3c.css.parser.CssError;
6564
import org.w3c.css.parser.CssErrorToken;
@@ -406,23 +405,11 @@ public abstract class CssParser {
406405
if (f.getParameters().hasVendorExtensions()) {
407406
expr.markVendorExtension();
408407
}
409-
if (f.getParameters().hasCssVariable()) {
410-
expr.markCssVariable();
411-
}
412408
if (f.getParameters().hasCssHack()) {
413409
expr.markCssHack();
414410
}
415-
} else if ( v.getType() == CssTypes.CSS_CALC) {
416-
CssCalc c = (CssCalc) v;
417-
if (c.hasCssVariable()) {
418-
expr.markCssVariable();
419-
}
420-
}
421-
} else if ( token == FUNCTIONVAR ) {
422-
if (v.getType() == CssTypes.CSS_VARIABLE) {
423-
expr.markCssVariable();
424411
}
425-
}
412+
}
426413
if (n != null) {
427414
if (ac.getCssVersion() == CssVersion.CSS1 &&
428415
(n.image).equals("inherit")) {
@@ -2886,8 +2873,7 @@ void term(CssExpression exp) :
28862873
| func=mathmin() { setValue(func, exp, operator, null, FUNCTION); }
28872874
| func=mathclamp() { setValue(func, exp, operator, null, FUNCTION); }
28882875
| func=attr() { setValue(func, exp, operator, null, FUNCTION); }
2889-
| func=functionvar() { setValue(func, exp, operator, null, FUNCTIONVAR); }
2890-
/* | n=<FUNCTIONVAR> ( <S> )* <CUSTOM_PROPERTY_NAME> ( <COMMA> ( <S> )* expr() )* ( <S> )* <LPARAN> */
2876+
| n=<FUNCTIONVAR> ( <S> )* <CUSTOM_PROPERTY_NAME> ( <COMMA> ( <S> )* expr() )* ( <S> )* <LPARAN>
28912877
| func=function() { setValue(func, exp, operator, null, FUNCTION); }
28922878
| n=<STRING> { setValue(new CssString(), exp, operator, n, STRING); }
28932879
| n=<DIV> { setValue(new CssSwitch(), exp, operator, n, DIV); }
@@ -3128,9 +3114,6 @@ CssCheckableValue mathsum() :
31283114
nb_pre_sp = 0;
31293115
if (concat) {
31303116
nc = new CssCalc(ac, c);
3131-
if (c.hasCssVariable()) {
3132-
nc.markCssVariable();
3133-
}
31343117
nc.addRightSide(o.image.trim(), v2);
31353118
c = nc;
31363119
} else {
@@ -3147,7 +3130,6 @@ CssCheckableValue mathproduct() :
31473130
{ Token n,o;
31483131
CssCheckableValue v1 = null;
31493132
CssCheckableValue v2 = null;
3150-
CssValue f;
31513133
CssCalc c, nc;
31523134
char operator = ' ';
31533135
boolean concat = false;
@@ -3157,14 +3139,11 @@ CssCheckableValue mathproduct() :
31573139
( ( o="*" ( <S> )* v2=mathunit() )
31583140
|
31593141
( o=<DIV> ( <S> )* ( v2=calcnumbervalue()
3160-
| n=<FUNCTIONVAR> ( <S> )* <CUSTOM_PROPERTY_NAME> ( <COMMA> ( <S> )* expr() )* ( <S> )* <LPARAN> { c.markCssVariable(); } )
3142+
| n=<FUNCTIONVAR> ( <S> )* <CUSTOM_PROPERTY_NAME> ( <COMMA> ( <S> )* expr() )* ( <S> )* <LPARAN> )
31613143
)
31623144
) {
31633145
if (concat) {
31643146
nc = new CssCalc(ac, c);
3165-
if (c.hasCssVariable()) {
3166-
nc.markCssVariable();
3167-
}
31683147
nc.addRightSide(o.image, v2);
31693148
c = nc;
31703149
} else {
@@ -3268,7 +3247,7 @@ char operator = ' ';
32683247
| v=mathmin()
32693248
| v=mathclamp()
32703249
| v=attr()
3271-
| n=<FUNCTIONVAR> ( <S> )* <CUSTOM_PROPERTY_NAME> ( <COMMA> ( <S> )* expr() )* ( <S> )* <LPARAN> { CssCalc c = new CssCalc(); c.markCssVariable(); return c; }
3250+
| n=<FUNCTIONVAR> ( <S> )* <CUSTOM_PROPERTY_NAME> ( <COMMA> ( <S> )* expr() )* ( <S> )* <LPARAN>
32723251
) {
32733252
return v;
32743253
}
@@ -3294,35 +3273,6 @@ CssExpression exp = null;
32943273
}
32953274
}
32963275

3297-
CssValue functionvar() :
3298-
{ Token n;
3299-
CssExpression exp = null;
3300-
CssExpression e;
3301-
CssVariable var;
3302-
}
3303-
{
3304-
<FUNCTIONVAR> ( <S> )* n=<CUSTOM_PROPERTY_NAME> {
3305-
var = new CssVariable(ac, convertIdent(n.image));
3306-
}
3307-
( <COMMA> ( <S> )* e=expr() { if (exp == null) {
3308-
exp = e;
3309-
} else {
3310-
exp.setOperator(CssOperator.COMMA) ;
3311-
while (!e.end()) {
3312-
exp.addValue(e.getValue());
3313-
exp.setOperator(e.getOperator());
3314-
e.next();
3315-
}
3316-
}
3317-
} )* ( <S> )* <LPARAN>
3318-
{
3319-
if (exp != null) {
3320-
var.set(exp);
3321-
}
3322-
return var;
3323-
}
3324-
}
3325-
33263276
/**
33273277
* @exception ParseException exception during the parse
33283278
*/

org/w3c/css/properties/css3/CssAspectRatio.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.w3c.css.values.CssValue;
1515
import org.w3c.css.values.CssValueList;
1616

17+
import java.math.BigDecimal;
1718
import java.util.ArrayList;
1819

1920
import static org.w3c.css.values.CssOperator.SPACE;
@@ -48,8 +49,8 @@ public CssAspectRatio(ApplContext ac, CssExpression expression, boolean check)
4849
char op;
4950
int ratio_state = 0;
5051
setByUser();
51-
CssValue dividend = null;
52-
CssValue divisor = null;
52+
BigDecimal dividend = null;
53+
BigDecimal divisor = null;
5354

5455
while (!expression.end()) {
5556
val = expression.getValue();
@@ -59,11 +60,11 @@ public CssAspectRatio(ApplContext ac, CssExpression expression, boolean check)
5960
// so we are cheating and create a CssRatio when needed.
6061
case CssTypes.CSS_NUMBER:
6162
if (ratio_state == 0) {
62-
dividend = val;
63+
dividend = val.getNumber().getBigDecimalValue();
6364
ratio_state++;
6465
break;
6566
} else if (ratio_state == 2) {
66-
divisor = val;
67+
divisor = val.getNumber().getBigDecimalValue();
6768
ratio_state++;
6869
v.add(new CssRatio(dividend, divisor)) ;
6970
break;

org/w3c/css/util/Messages.properties.en

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ warning.noothermedium : Properties for other media might not work for usermedium
311311
warning.vendor-extension : \u201C%s\u201D is an unknown vendor extension
312312
warning.vendor-ext-pseudo-class : \u201C%s\u201D is an unknown vendor extended pseudo-class
313313
warning.vendor-ext-pseudo-element : \u201C%s\u201D is an unknown vendor extended pseudo-element
314-
warning.css-variable: Due to their dynamic nature, CSS variables are currently not statically checked
315314

316315
warning.css-hack : \u201C%s\u201D is a CSS hack
317316

org/w3c/css/util/Messages.properties.fr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,6 @@ error.notforatsc: \u201C%s\u201D ne peut pas être utilisé pour le profil ATSC
420420
error.notfortv: \u201C%s\u201D ne peut pas être utilisé pour le profil TV
421421
error.notversion: \u201C%s\u201D ne peut pas être utilisé pour cette version CSS: \u201C%s\u201D
422422

423-
warning.css-variable: En raison de laur nature dynamique, les variables CSS ne sont pas vérifiées statiquement
424-
425423
warning.css-hack : \u201C%s\u201D est un hack CSS
426424

427425
warning.atsc : il se peut que \u201C%s\u201D ne soit pas supporté par atsc-tv

org/w3c/css/values/CssCalc.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public final int getType() {
3939
boolean hasParen = false;
4040
String _toString = null;
4141
boolean implicit_function = true;
42-
boolean contains_variable = false;
4342

4443

4544
/**
@@ -61,21 +60,9 @@ public CssCalc(ApplContext ac, CssValue value) {
6160
this.ac = ac;
6261
}
6362
if (value != null) {
64-
if (value.getRawType() == CssTypes.CSS_CALC) {
65-
CssCalc c = (CssCalc) value;
66-
contains_variable = c.hasCssVariable();
67-
}
63+
computed_type = value.getType();
64+
val1 = value;
6865
}
69-
computed_type = value.getType();
70-
val1 = value;
71-
}
72-
73-
public boolean hasCssVariable() {
74-
return contains_variable;
75-
}
76-
77-
public void markCssVariable() {
78-
contains_variable = true;
7966
}
8067

8168
public void setImplicitFunction(boolean v) {
@@ -159,10 +146,6 @@ private void _computeResultingType(boolean end)
159146
throws InvalidParamException {
160147
int valtype;
161148

162-
if (contains_variable) {
163-
// nothing to check as we may not have anything yet
164-
return;
165-
}
166149
if (val2 == null) {
167150
// we only have val1 to check.
168151
valtype = val1.getType();

org/w3c/css/values/CssExpression.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public class CssExpression implements CssOperator {
2222

2323
private boolean vendor_extension = false;
2424
private boolean css_hack = false;
25-
private boolean css_variable = false;
2625

2726
public boolean hasVendorExtensions() {
2827
return vendor_extension;
@@ -40,14 +39,6 @@ public void markCssHack() {
4039
css_hack = true;
4140
}
4241

43-
public boolean hasCssVariable() {
44-
return css_variable;
45-
}
46-
47-
public void markCssVariable() {
48-
css_variable = true;
49-
}
50-
5142
/**
5243
* mark the current position, it can be set to this
5344
* position later by using reset

org/w3c/css/values/CssRatio.java

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ public final int getType() {
2424
return type;
2525
}
2626

27-
BigDecimal w = null, h = null;
28-
CssValue gw = null, gh = null;
27+
BigDecimal w, h;
2928

3029

3130
/**
@@ -39,37 +38,6 @@ public CssRatio(BigDecimal w, BigDecimal h) {
3938
this.h = h;
4039
}
4140

42-
public CssRatio(BigDecimal w, CssValue gh) {
43-
this.w = w;
44-
try {
45-
this.h = gh.getNumber().getBigDecimalValue();
46-
} catch (Exception ex) {
47-
this.gh = gh;
48-
}
49-
}
50-
51-
public CssRatio(CssValue gw, BigDecimal h) {
52-
try {
53-
this.w = gw.getNumber().getBigDecimalValue();
54-
} catch (Exception ex) {
55-
this.gw = gw;
56-
}
57-
this.h = h;
58-
}
59-
60-
public CssRatio(CssValue gw, CssValue gh) {
61-
try {
62-
this.w = gw.getNumber().getBigDecimalValue();
63-
} catch (Exception ex) {
64-
this.gw = gw;
65-
}
66-
try {
67-
this.h = gh.getNumber().getBigDecimalValue();
68-
} catch (Exception ex) {
69-
this.gh = gh;
70-
}
71-
}
72-
7341
/**
7442
* Set the value of this ratio.
7543
*
@@ -123,17 +91,7 @@ public Object get() {
12391
*/
12492
public String toString() {
12593
StringBuilder sb = new StringBuilder();
126-
if (w != null) {
127-
sb.append(w.toPlainString());
128-
} else {
129-
sb.append(gw.toString()).append(' ');
130-
}
131-
sb.append('/');
132-
if (h != null) {
133-
sb.append(h.toPlainString());
134-
} else {
135-
sb.append(gh.toString());
136-
}
94+
sb.append(w.toPlainString()).append('/').append(h.toPlainString());
13795
return sb.toString();
13896
}
13997

@@ -152,8 +110,6 @@ public boolean equals(Object value) {
152110
return (ratio.compareTo(other_ratio) == 0);
153111
} catch (ClassCastException cce) {
154112
return false;
155-
} catch (Exception ex) {
156-
return false;
157113
}
158114
}
159115
}

org/w3c/css/values/CssTypes.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public class CssTypes {
3737
public static final int CSS_MIN = 24;
3838
public static final int CSS_MAX = 25;
3939
public static final int CSS_CLAMP = 26;
40-
public static final int CSS_VARIABLE = 27;
4140

4241
// not generated by the parser
4342
public static final int CSS_VALUE_LIST = 30;

0 commit comments

Comments
 (0)