Skip to content

Commit 35c5705

Browse files
committed
Fix for #505, might add better handling of fallback types later
1 parent cee4a1d commit 35c5705

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

org/w3c/css/values/CssCalc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public CssCalc(ApplContext ac, CssValue value) {
6262
if (value.getRawType() == CssTypes.CSS_CALC) {
6363
CssCalc c = (CssCalc) value;
6464
contains_variable = c.hasCssVariable();
65-
} else if (value.getType() == CssTypes.CSS_VARIABLE) {
65+
} else if (value.getRawType() == CssTypes.CSS_VARIABLE) {
6666
contains_variable = true;
6767
}
6868
}
@@ -128,7 +128,7 @@ public CssCalc addRightSide(String oper, CssValue value) throws InvalidParamExce
128128
throw new InvalidParamException("operator", oper, ac);
129129
}
130130
val2 = value;
131-
if (val2.getType() == CssTypes.CSS_VARIABLE) {
131+
if (val2.getRawType() == CssTypes.CSS_VARIABLE) {
132132
contains_variable = true;
133133
}
134134
_computeResultingType(false);

org/w3c/css/values/CssCheckableValue.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public void markCssVariable() {
3131
contains_variable = true;
3232
}
3333

34+
public boolean isCheckableValue() {
35+
return true;
36+
}
37+
3438
/**
3539
* check if the value is positive or null
3640
*

org/w3c/css/values/CssMathFunction.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,13 @@ private void _computeResultingTypeTrig(boolean is_final)
485485
}
486486
}
487487

488+
// a var() with a fallback reports the fallback's type, so getType() alone is
489+
// not enough to tell that a value is dynamic
490+
private static boolean valueHasVar(CssValue v)
491+
throws InvalidParamException {
492+
return v.isCheckableValue() && v.getCheckableValue().hasCssVariable();
493+
}
494+
488495
private void _computeResultingTypeList(boolean is_final)
489496
throws InvalidParamException {
490497
int valtype = CssTypes.CSS_MATH_FUNCTION;
@@ -495,7 +502,7 @@ private void _computeResultingTypeList(boolean is_final)
495502
if (firstVal) {
496503
valtype = v.getType();
497504
// Variable? defer to the next type
498-
if (valtype == CssTypes.CSS_VARIABLE) {
505+
if (valtype == CssTypes.CSS_VARIABLE || valueHasVar(v)) {
499506
markCssVariable();
500507
continue;
501508
}
@@ -525,7 +532,8 @@ private void _computeResultingTypeList(boolean is_final)
525532
continue;
526533
}
527534
// if it is a variable without a computed type, skip it
528-
if ((v.getType() == CssTypes.CSS_VARIABLE) || (v.getRawType() == CssTypes.CSS_VARIABLE)) {
535+
if ((v.getType() == CssTypes.CSS_VARIABLE) || (v.getRawType() == CssTypes.CSS_VARIABLE)
536+
|| valueHasVar(v)) {
529537
markCssVariable();
530538
continue;
531539
}

org/w3c/css/values/CssValue.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ public CssFrequency getFrequency() throws InvalidParamException {
8282
throw new ClassCastException("unknown");
8383
}
8484

85+
public boolean isCheckableValue() {
86+
return false;
87+
}
88+
8589
public CssCheckableValue getCheckableValue() throws InvalidParamException {
8690
throw new ClassCastException("unknown");
8791
}

0 commit comments

Comments
 (0)