LibWeb: Update to_color to take ColorResolutionContext

Using a generic context argument will allow us to resolve colors in
places where we have all the required information but not in the form of
a layout node as was expected previously.
This commit is contained in:
Callum Law 2025-07-19 11:31:07 +12:00 committed by Sam Atkins
commit 46153910ec
Notes: github-actions[bot] 2025-08-04 10:30:51 +00:00
31 changed files with 129 additions and 127 deletions

View file

@ -945,15 +945,13 @@ void CanvasRenderingContext2D::set_shadow_color(String color)
// 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);
if (style_value && style_value->has_color()) {
Optional<Layout::NodeWithStyle const&> layout_node;
CSS::CalculationResolutionContext resolution_context;
CSS::ColorResolutionContext color_resolution_context {};
if (auto node = context.layout_node()) {
layout_node = *node;
resolution_context.length_resolution_context = CSS::Length::ResolutionContext::for_layout_node(*node);
color_resolution_context = CSS::ColorResolutionContext::for_layout_node_with_style(*context.layout_node());
}
auto parsedValue = style_value->to_color(layout_node, resolution_context).value_or(Color::Black);
auto parsedValue = style_value->to_color(color_resolution_context).value_or(Color::Black);
// 4. Set this's shadow color to parsedValue.
drawing_state().shadow_color = parsedValue;