LibWeb: Extract mixed-type interpolation to a separate method

This commit is contained in:
Tim Ledbetter 2025-09-14 17:34:05 +01:00 committed by Sam Atkins
commit 7409c564d7
Notes: github-actions[bot] 2025-09-15 09:42:10 +00:00

View file

@ -1024,11 +1024,8 @@ RefPtr<StyleValue const> interpolate_box_shadow(DOM::Element& element, Calculati
return StyleValueList::create(move(result_shadows), StyleValueList::Separator::Comma);
}
static RefPtr<StyleValue const> interpolate_value_impl(DOM::Element& element, CalculationContext const& calculation_context, StyleValue const& from, StyleValue const& to, float delta, AllowDiscrete allow_discrete)
static RefPtr<StyleValue const> interpolate_mixed_value(CalculationContext const& calculation_context, StyleValue const& from, StyleValue const& to, float delta)
{
if (from.type() != to.type() || from.is_calculated() || to.is_calculated()) {
// Handle mixed percentage and dimension types, as well as CalculatedStyleValues
// https://www.w3.org/TR/css-values-4/#mixed-percentages
auto get_value_type_of_numeric_style_value = [&calculation_context](StyleValue const& value) -> Optional<ValueType> {
switch (value.type()) {
case StyleValue::Type::Angle:
@ -1143,6 +1140,14 @@ static RefPtr<StyleValue const> interpolate_value_impl(DOM::Element& element, Ca
return {};
}
static RefPtr<StyleValue const> interpolate_value_impl(DOM::Element& element, CalculationContext const& calculation_context, StyleValue const& from, StyleValue const& to, float delta, AllowDiscrete allow_discrete)
{
if (from.type() != to.type() || from.is_calculated() || to.is_calculated()) {
// Handle mixed percentage and dimension types, as well as CalculatedStyleValues
// https://www.w3.org/TR/css-values-4/#mixed-percentages
return interpolate_mixed_value(calculation_context, from, to, delta);
}
static auto interpolate_length_percentage = [](CalculationContext const& calculation_context, LengthPercentage const& from, LengthPercentage const& to, float delta) -> Optional<LengthPercentage> {
if (from.is_length() && to.is_length())
return Length::make_px(interpolate_raw(from.length().raw_value(), to.length().raw_value(), delta, calculation_context.accepted_type_ranges.get(ValueType::Length)));