mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 08:48:57 +00:00
LibWeb: Extract mixed-type interpolation to a separate method
This commit is contained in:
parent
b19fee9962
commit
7409c564d7
Notes:
github-actions[bot]
2025-09-15 09:42:10 +00:00
Author: https://github.com/tcl3
Commit: 7409c564d7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6194
Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 117 additions and 112 deletions
|
@ -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)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue