mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-11 03:56:16 +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
Notes:
sideshowbarker
2024-07-17 11:30:54 +09:00
Author: https://github.com/awesomekling
Commit: d8e8293b7e
Pull-request: https://github.com/SerenityOS/serenity/pull/23423
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