Skip to content

fix: Handle calc() with number type in CSS position checking#494

Open
sideshowbarker wants to merge 1 commit intomainfrom
fix-calc-number-getlength
Open

fix: Handle calc() with number type in CSS position checking#494
sideshowbarker wants to merge 1 commit intomainfrom
fix-calc-number-getlength

Conversation

@sideshowbarker
Copy link
Member

@sideshowbarker sideshowbarker commented Mar 17, 2026

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.

The exception is reproducible by checking http://loconto.net

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant