LibWeb: Don't resolve colors with unresolved components

`CSSColorValue`s which have unresolved `calc` components should be able
to be resolved. Previously we would always resolve them but with
incorrect values.

This is useful as we will now be able to now whether we should serialize
colors in their normalized form or not.

Slight regression in that we now serialize (RGB, HSL and HWB) colors
with components that rely on compute-time information as an empty
string, but that will be fixed in the next commit.
This commit is contained in:
Callum Law 2025-07-03 12:59:24 +12:00 committed by Sam Atkins
commit 6a9c8d7767
Notes: github-actions[bot] 2025-07-16 12:06:47 +00:00
30 changed files with 278 additions and 129 deletions

View file

@ -9,7 +9,7 @@
namespace Web::CSS {
Color CSSLightDark::to_color(Optional<Layout::NodeWithStyle const&> node, CalculationResolutionContext const& resolution_context) const
Optional<Color> CSSLightDark::to_color(Optional<Layout::NodeWithStyle const&> node, CalculationResolutionContext const& resolution_context) const
{
if (node.has_value() && node.value().computed_values().color_scheme() == PreferredColorScheme::Dark)
return m_properties.dark->to_color(node, resolution_context);