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
Notes: sideshowbarker 2024-07-17 11:30:54 +09:00

View File

@ -97,6 +97,12 @@ public:
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);
}