From d15e1eb9f6f8d66fd50bc84c0e8f3e8a0295a1cd Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 31 Jan 2025 10:55:58 +0000 Subject: [PATCH] LibWeb/CSS: Don't multiply non-canonical dimensions in calc() This fixes the layout of tweakers.net, which regressed when calc simplification was added in ee712bd98f7d3feccb2de60ddfb695311a55ff3e. --- Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp index 4f1ef90e267..f9884a30328 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp @@ -2486,7 +2486,7 @@ CalculatedStyleValue::CalculationResult CalculatedStyleValue::CalculationResult: // If we don't have a context, we cant resolve the length, so return NAN if (!context.length_resolution_context.has_value()) { - dbgln("Failed to resolve length, likely due to calc() being used with relative units and a property not taking it into account"); + dbgln("Failed to resolve length `{}`, likely due to calc() being used with relative units and a property not taking it into account", length.to_string()); return AK::NaN; } @@ -3091,8 +3091,10 @@ NonnullRefPtr simplify_a_calculation_tree(CalculationNode const // FIXME: The spec doesn't handle unresolved percentages here, but if we don't exit when we see one, // we'll get a wrongly-typed value after multiplying the types. + // Same goes for other numerics with non-canonical units. // Spec bug: https://github.com/w3c/csswg-drafts/issues/11588 - if (numeric_child.value().has() && context.percentages_resolve_as.has_value()) { + if ((numeric_child.value().has() && context.percentages_resolve_as.has_value()) + || !numeric_child.is_in_canonical_unit()) { is_valid = false; break; }