mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-17 21:49:42 +00:00
LibWeb: Add convenience from_style_value
for LengthPercentage{OrAuto}
This commit is contained in:
parent
4a998879d5
commit
309ff33278
Notes:
github-actions[bot]
2025-10-07 09:51:29 +00:00
Author: https://github.com/Calme1709
Commit: 309ff33278
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6375
Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 32 additions and 60 deletions
|
@ -1330,13 +1330,7 @@ Optional<LengthPercentage> interpolate_length_percentage(CalculationContext cons
|
|||
auto interpolated_style_value = interpolate_mixed_value(calculation_context, from_style_value, to_style_value, delta);
|
||||
if (!interpolated_style_value)
|
||||
return {};
|
||||
if (interpolated_style_value->is_length())
|
||||
return interpolated_style_value->as_length().length();
|
||||
if (interpolated_style_value->is_percentage())
|
||||
return interpolated_style_value->as_percentage().percentage();
|
||||
if (interpolated_style_value->is_calculated())
|
||||
return LengthPercentage { interpolated_style_value->as_calculated() };
|
||||
VERIFY_NOT_REACHED();
|
||||
return LengthPercentage::from_style_value(*interpolated_style_value);
|
||||
}
|
||||
|
||||
Optional<LengthPercentageOrAuto> interpolate_length_percentage_or_auto(CalculationContext const& calculation_context, LengthPercentageOrAuto const& from, LengthPercentageOrAuto const& to, float delta)
|
||||
|
@ -1353,15 +1347,7 @@ Optional<LengthPercentageOrAuto> interpolate_length_percentage_or_auto(Calculati
|
|||
auto interpolated_style_value = interpolate_mixed_value(calculation_context, from_style_value, to_style_value, delta);
|
||||
if (!interpolated_style_value)
|
||||
return {};
|
||||
if (interpolated_style_value->to_keyword() == Keyword::Auto)
|
||||
return LengthPercentageOrAuto::make_auto();
|
||||
if (interpolated_style_value->is_length())
|
||||
return interpolated_style_value->as_length().length();
|
||||
if (interpolated_style_value->is_percentage())
|
||||
return interpolated_style_value->as_percentage().percentage();
|
||||
if (interpolated_style_value->is_calculated())
|
||||
return LengthPercentage { interpolated_style_value->as_calculated() };
|
||||
VERIFY_NOT_REACHED();
|
||||
return LengthPercentageOrAuto::from_style_value(*interpolated_style_value);
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue