diff --git a/Libraries/LibWeb/CSS/Interpolation.cpp b/Libraries/LibWeb/CSS/Interpolation.cpp index fb4ab5d561a..56e5d1a5ab2 100644 --- a/Libraries/LibWeb/CSS/Interpolation.cpp +++ b/Libraries/LibWeb/CSS/Interpolation.cpp @@ -1100,39 +1100,18 @@ static RefPtr interpolate_value_impl(DOM::Element& element, Ca } }; - auto to_raw_value = [](StyleValue const& value) -> double { - switch (value.type()) { - case StyleValue::Type::Angle: - return value.as_angle().raw_value(); - case StyleValue::Type::Frequency: - return value.as_frequency().raw_value(); - case StyleValue::Type::Integer: - return value.as_integer().integer(); - case StyleValue::Type::Length: - return value.as_length().raw_value(); - case StyleValue::Type::Number: - return value.as_number().number(); - case StyleValue::Type::Percentage: - return value.as_percentage().raw_value(); - case StyleValue::Type::Time: - return value.as_time().raw_value(); - default: - VERIFY_NOT_REACHED(); - } - }; - // https://drafts.csswg.org/css-values-4/#combine-mixed // The computed value of a percentage-dimension mix is defined as // FIXME: a computed dimension if the percentage component is zero or is defined specifically to compute to a dimension value // a computed percentage if the dimension component is zero // a computed calc() expression otherwise - if (from.type() != StyleValue::Type::Calculated && to.type() == StyleValue::Type::Percentage) { - auto dimension_component = to_raw_value(from) * (1.f - delta); + if (auto const* from_dimension_value = as_if(from); from_dimension_value && to.type() == StyleValue::Type::Percentage) { + auto dimension_component = from_dimension_value->raw_value() * (1.f - delta); auto percentage_component = to.as_percentage().raw_value() * delta; if (dimension_component == 0.f) return PercentageStyleValue::create(Percentage { percentage_component }); - } else if (from.type() == StyleValue::Type::Percentage && to.type() != StyleValue::Type::Calculated) { - auto dimension_component = to_raw_value(to) * delta; + } else if (auto const* to_dimension_value = as_if(to); to_dimension_value && from.type() == StyleValue::Type::Percentage) { + auto dimension_component = to_dimension_value->raw_value() * delta; auto percentage_component = from.as_percentage().raw_value() * (1.f - delta); if (dimension_component == 0) return PercentageStyleValue::create(Percentage { percentage_component });