1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:27:35 +00:00

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
2 changed files with 19 additions and 5 deletions

View file

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

View file

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