LibWeb: Disallow random() in canvas context value setters

This introduces two new top-level `ValueParsingContext`s,
`OnScreenCanvasContextFontValue` and `CanvasContextGenericValue`, while
these are handled the same for now, there is a distinction is whether or
not they allow tree counting functions (which will come in a later
commit)
This commit is contained in:
Callum Law
2026-04-04 01:22:29 +13:00
committed by Sam Atkins
parent 3342fc897f
commit 1fdcea2b7b
Notes: github-actions[bot] 2026-04-08 13:34:02 +00:00
10 changed files with 107 additions and 9 deletions

View File

@@ -295,7 +295,7 @@ void OffscreenCanvasRenderingContext2D::set_shadow_color(String color)
// 1. Let context be this's canvas attribute's value, if that is an element; otherwise null.
// 2. Let parsedValue be the result of parsing the given value with context if non-null.
auto style_value = parse_css_value(CSS::Parser::ParsingParams(), color, CSS::PropertyID::Color);
auto style_value = parse_css_value(CSS::Parser::ParsingParams { CSS::Parser::SpecialContext::CanvasContextGenericValue }, color, CSS::PropertyID::Color);
if (style_value && style_value->has_color()) {
auto parsedValue = style_value->to_color({}).value_or(Color::Black);