LibWeb: Make PercentageOr<T>::contains_percentage() handle more cases

This commit is contained in:
Andreas Kling 2022-09-27 18:12:54 +02:00
parent df416bb822
commit 7abb512a86
Notes: sideshowbarker 2024-07-17 06:32:55 +09:00
2 changed files with 19 additions and 5 deletions

View File

@ -43,6 +43,8 @@ private:
float m_value;
};
bool calculated_style_value_contains_percentage(CalculatedStyleValue const&);
template<typename T>
class PercentageOr {
public:
@ -80,11 +82,18 @@ public:
bool contains_percentage() const
{
if (is_percentage())
return true;
if (is_calculated())
return calculated()->contains_percentage();
return false;
return m_value.visit(
[&](T const& t) {
if (t.is_calculated())
return calculated_style_value_contains_percentage(*t.calculated_style_value());
return false;
},
[&](Percentage const&) {
return true;
},
[&](NonnullRefPtr<CalculatedStyleValue> const& calculated) {
return calculated_style_value_contains_percentage(*calculated);
});
}
Percentage const& percentage() const

View File

@ -2272,4 +2272,9 @@ bool CalculatedStyleValue::CalcValue::contains_percentage() const
[](auto const&) { return false; });
}
bool calculated_style_value_contains_percentage(CalculatedStyleValue const& value)
{
return value.contains_percentage();
}
}