LibWeb: Clamp calculated cubic-bezier() X coords using normal system

Previously we were doing this ad-hoc later in the process but we now
have the `calc` clamping system which can simplify things
This commit is contained in:
Callum Law 2025-10-10 00:59:59 +13:00 committed by Sam Atkins
commit 06a57a280d
Notes: github-actions[bot] 2025-10-20 10:29:21 +00:00
4 changed files with 11 additions and 15 deletions

View file

@ -2957,9 +2957,12 @@ RefPtr<StyleValue const> Parser::parse_easing_value(TokenStream<ComponentValue>&
return parse_number(argument_tokens);
};
m_value_context.append(SpecialContext::CubicBezierFunctionXCoordinate);
auto x1 = parse_argument(0);
auto y1 = parse_argument(1);
auto x2 = parse_argument(2);
m_value_context.take_last();
auto y1 = parse_argument(1);
auto y2 = parse_argument(3);
if (!x1.has_value() || !y1.has_value() || !x2.has_value() || !y2.has_value())
return nullptr;
@ -4136,6 +4139,9 @@ RefPtr<CalculatedStyleValue const> Parser::parse_calculated_value(ComponentValue
switch (special_context) {
case SpecialContext::AngularColorStopList:
return CalculationContext { .percentages_resolve_as = ValueType::Angle };
case SpecialContext::CubicBezierFunctionXCoordinate:
// Coordinates on the X axis must be between 0 and 1
return CalculationContext { .accepted_type_ranges = { { ValueType::Number, { 0, 1 } } } };
case SpecialContext::ShadowBlurRadius:
return CalculationContext { .accepted_type_ranges = { { ValueType::Length, { 0, NumericLimits<float>::max() } } } };
case SpecialContext::TranslateZArgument: