mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibWeb: Make PercentageOr<T>::contains_percentage() handle more cases
This commit is contained in:
parent
df416bb822
commit
7abb512a86
Notes:
sideshowbarker
2024-07-17 06:32:55 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7abb512a86
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user