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

@ -116,18 +116,7 @@ String EasingStyleValue::CubicBezier::to_string(SerializationMode mode) const
} else if (*this == CubicBezier::ease_in_out()) {
builder.append("ease-in-out"sv);
} else {
auto x1_value = x1;
auto y1_value = y1;
auto x2_value = x2;
auto y2_value = y2;
if (mode == SerializationMode::ResolvedValue) {
x1_value = clamp(x1_value.resolved({}).value_or(0.0), 0.0, 1.0);
x2_value = clamp(x2_value.resolved({}).value_or(0.0), 0.0, 1.0);
y1_value = y1_value.resolved({}).value_or(0.0);
y2_value = y2_value.resolved({}).value_or(0.0);
}
builder.appendff("cubic-bezier({}, {}, {}, {})",
x1_value.to_string(mode), y1_value.to_string(mode), x2_value.to_string(mode), y2_value.to_string(mode));
builder.appendff("cubic-bezier({}, {}, {}, {})", x1.to_string(mode), y1.to_string(mode), x2.to_string(mode), y2.to_string(mode));
}
return MUST(builder.to_string());
}