LibWeb: Set context for parsing against <foo-percentage> syntax

This means that we correctly parse dimension percentage mixes (i.e.
`calc(10px + 10%)` is a valid `<length-percentage>`)
This commit is contained in:
Callum Law
2026-03-08 12:43:20 +13:00
committed by Sam Atkins
parent ed2909674f
commit 614a5cf33e
Notes: github-actions[bot] 2026-03-26 01:13:21 +00:00
6 changed files with 28 additions and 10 deletions

View File

@@ -5162,6 +5162,20 @@ RefPtr<CalculatedStyleValue const> Parser::parse_calculated_value(ComponentValue
return {};
}
VERIFY_NOT_REACHED();
},
[](SyntaxParsingContext const& syntax_context) -> Optional<CalculationContext> {
switch (syntax_context.type) {
case ValueType::AnglePercentage:
return CalculationContext { .percentages_resolve_as = ValueType::Angle };
case ValueType::FrequencyPercentage:
return CalculationContext { .percentages_resolve_as = ValueType::Frequency };
case ValueType::LengthPercentage:
return CalculationContext { .percentages_resolve_as = ValueType::Length };
case ValueType::TimePercentage:
return CalculationContext { .percentages_resolve_as = ValueType::Time };
default:
return {};
}
});
if (maybe_context.has_value()) {
context = maybe_context.release_value();