Skip to content

Commit 1eb2aed

Browse files
fix: Handle calc() with number type in CSS position checking
Bug: A conic-gradient() position containing a calc() that resolves to a number causes a ClassCastException to be thrown. Cause: CssCalc.getLength() only handled computed_type == CSS_LENGTH. When CssBackgroundPosition.checkSyntax() calls getLength() on a calc with computed_type == CSS_NUMBER, it falls through to the throw. Fix: Delegate to the inner value’s getLength() when computed_type is CSS_NUMBER, matching how CssNumber.getLength() handles the zero-check.
1 parent e62bbcf commit 1eb2aed

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

org/w3c/css/values/CssCalc.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,14 @@ public CssLength getLength() throws InvalidParamException {
410410
return val2.getLength();
411411
}
412412
}
413+
if (computed_type == CssTypes.CSS_NUMBER) {
414+
if (val1.getType() == CssTypes.CSS_NUMBER) {
415+
return val1.getLength();
416+
}
417+
if (val2.getType() == CssTypes.CSS_NUMBER) {
418+
return val2.getLength();
419+
}
420+
}
413421
throw new ClassCastException("unknown");
414422
}
415423

0 commit comments

Comments
 (0)