mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:47: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:
parent
1e14264d13
commit
d8e8293b7e
1 changed files with 6 additions and 0 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue