LibWeb: Add method to absolutize CalculatedOr

This commit is contained in:
Callum Law 2025-08-04 20:11:12 +12:00 committed by Sam Atkins
commit c8bd58c0ba
Notes: github-actions[bot] 2025-08-06 16:46:01 +00:00

View file

@ -78,6 +78,20 @@ public:
}); });
} }
Self absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
{
return m_value.visit(
[&](T const& value) {
if constexpr (IsSame<T, Length>)
return Self { value.absolutized(viewport_rect, font_metrics, root_font_metrics) };
else
return *static_cast<Self const*>(this);
},
[&](NonnullRefPtr<CalculatedStyleValue const> const& value) {
return Self { value->absolutized(viewport_rect, font_metrics, root_font_metrics)->as_calculated() };
});
}
bool operator==(CalculatedOr<Self, T> const& other) const bool operator==(CalculatedOr<Self, T> const& other) const
{ {
if (is_calculated() || other.is_calculated()) if (is_calculated() || other.is_calculated())