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

LibWeb: Add PercentageOr<Length>::to_px() fast path for absolute lengths

We can avoid round-tripping through a temporary Length in the simple
case here.
This commit is contained in:
Andreas Kling 2024-03-02 11:41:31 +01:00
parent 1e14264d13
commit d8e8293b7e

View file

@ -97,6 +97,12 @@ public:
CSSPixels to_px(Layout::Node const& layout_node, CSSPixels reference_value) const CSSPixels to_px(Layout::Node const& layout_node, CSSPixels reference_value) const
{ {
if constexpr (IsSame<T, Length>) {
if (auto const* length = m_value.template get_pointer<Length>()) {
if (length->is_absolute())
return length->absolute_length_to_px();
}
}
return resolved(layout_node, reference_value).to_px(layout_node); return resolved(layout_node, reference_value).to_px(layout_node);
} }