diff --git a/Userland/Libraries/LibWeb/CSS/PercentageOr.h b/Userland/Libraries/LibWeb/CSS/PercentageOr.h index a790cb7b10..ed575b28df 100644 --- a/Userland/Libraries/LibWeb/CSS/PercentageOr.h +++ b/Userland/Libraries/LibWeb/CSS/PercentageOr.h @@ -88,6 +88,11 @@ public: VERIFY_NOT_REACHED(); } + CSSPixels to_px(Layout::Node const& layout_node, CSSPixels reference_value) const + { + return resolved(layout_node, Length::make_px(reference_value)).to_px(layout_node); + } + T resolved(Layout::Node const& layout_node, T const& reference_value) const { return m_value.visit( diff --git a/Userland/Libraries/LibWeb/CSS/Size.cpp b/Userland/Libraries/LibWeb/CSS/Size.cpp index 0513d254ff..5df737b3be 100644 --- a/Userland/Libraries/LibWeb/CSS/Size.cpp +++ b/Userland/Libraries/LibWeb/CSS/Size.cpp @@ -14,6 +14,11 @@ Size::Size(Type type, LengthPercentage length_percentage) { } +CSSPixels Size::to_px(Layout::Node const& node, CSSPixels reference_value) const +{ + return m_length_percentage.resolved(node, CSS::Length::make_px(reference_value)).to_px(node); +} + CSS::Length Size::resolved(Layout::Node const& node, Length const& reference_value) const { return m_length_percentage.resolved(node, reference_value); diff --git a/Userland/Libraries/LibWeb/CSS/Size.h b/Userland/Libraries/LibWeb/CSS/Size.h index 77aaf2da59..ff12a824b1 100644 --- a/Userland/Libraries/LibWeb/CSS/Size.h +++ b/Userland/Libraries/LibWeb/CSS/Size.h @@ -47,6 +47,8 @@ public: // FIXME: This is a stopgap API that will go away once all layout code is aware of CSS::Size. CSS::Length resolved(Layout::Node const&, Length const& reference_value) const; + [[nodiscard]] CSSPixels to_px(Layout::Node const&, CSSPixels reference_value) const; + bool contains_percentage() const; CalculatedStyleValue const& calculated() const