LibWeb: Make CSS::PercentageOr<T> non-virtual

This shrinks each instance of PercentageOr by 8 bytes and avoids virtual
dispatch when resolving calc() values. It's a win-win!

Many data structures shrink as a result. An example is ComputedValues
which goes from 3376 bytes to 3024 bytes per instance.
This commit is contained in:
Andreas Kling 2024-08-02 14:28:24 +02:00 committed by Andreas Kling
commit c282138fd0
Notes: github-actions[bot] 2024-08-02 18:38:37 +00:00
10 changed files with 44 additions and 49 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2020-2024, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
* Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
*
@ -391,4 +391,14 @@ Length Length::absolutized(CSSPixelRect const& viewport_rect, FontMetrics const&
return absolutize(viewport_rect, font_metrics, root_font_metrics).value_or(*this);
}
Length Length::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node, Length const& reference_value)
{
return calculated->resolve_length_percentage(layout_node, reference_value).value();
}
Length Length::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node, CSSPixels reference_value)
{
return calculated->resolve_length_percentage(layout_node, reference_value).value();
}
}