Skip to content

Commit b34f353

Browse files
committed
Use LexicalValue instead of VarValue in ValueComparator
1 parent 713e611 commit b34f353

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

ci/io/github/css4j/ci/ValueComparator.java

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@
3131
import io.sf.carte.doc.style.css.om.BaseCSSStyleDeclaration;
3232
import io.sf.carte.doc.style.css.om.CSSOMBridge;
3333
import io.sf.carte.doc.style.css.parser.ParseHelper;
34+
import io.sf.carte.doc.style.css.property.LexicalValue;
3435
import io.sf.carte.doc.style.css.property.NumberValue;
3536
import io.sf.carte.doc.style.css.property.PropertyDatabase;
3637
import io.sf.carte.doc.style.css.property.StyleValue;
3738
import io.sf.carte.doc.style.css.property.URIValue;
38-
import io.sf.carte.doc.style.css.property.ValueFactory;
3939
import io.sf.carte.doc.style.css.property.ValueList;
40-
import io.sf.carte.doc.style.css.property.VarValue;
4140

4241
class ValueComparator {
4342

@@ -251,31 +250,23 @@ && similarAlphaValue(color.getAlpha(), otherColor.getAlpha())) {
251250
&& otherValue.getCssValueType() == CssType.PROXY) {
252251
Type ptype = value.getPrimitiveType();
253252
Type otype = otherValue.getPrimitiveType();
254-
if (ptype == Type.VAR && otype == Type.VAR) {
255-
VarValue var = (VarValue) value;
256-
VarValue varOther = (VarValue) otherValue;
257-
if (var.getName().equals(varOther.getName())) {
258-
LexicalUnit fb = var.getFallback();
259-
LexicalUnit fbOther = varOther.getFallback();
260-
if (fb == null) {
261-
if (fbOther == null) {
253+
if (ptype == Type.LEXICAL && otype == Type.LEXICAL) {
254+
LexicalValue var = (LexicalValue) value;
255+
LexicalValue varOther = (LexicalValue) otherValue;
256+
LexicalUnit lu = var.getLexicalUnit().getParameters();
257+
LexicalUnit luOther = varOther.getLexicalUnit().getParameters();
258+
do {
259+
lu = lu.getNextLexicalUnit();
260+
luOther = luOther.getNextLexicalUnit();
261+
if (lu == null) {
262+
if (luOther == null) {
262263
return 1;
263264
}
264-
} else if (fbOther != null) {
265-
if (fb.equals(fbOther)) {
266-
return 1;
267-
}
268-
ValueFactory vf = new ValueFactory();
269-
StyleValue fbOm, fbOtherOm;
270-
try {
271-
fbOm = vf.createCSSValue(fb);
272-
fbOtherOm = vf.createCSSValue(fbOther);
273-
} catch (DOMException e) {
274-
return 2;
275-
}
276-
return testDifferentValue(fbOm, fbOtherOm);
265+
break;
266+
} else if (luOther != null && !lu.equals(luOther)) {
267+
break;
277268
}
278-
}
269+
} while (true);
279270
}
280271
return 2;
281272
} else if (value.getCssValueType() == CssType.LIST

0 commit comments

Comments
 (0)