mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 02:08:12 +03:00
LibWeb: Calculate calc() lengths in to_px()
to_px() has the layout node available, so let's use it.
This commit is contained in:
parent
67066c5140
commit
6df3f9920d
Notes:
sideshowbarker
2024-07-17 18:34:30 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/6df3f9920d Pull-request: https://github.com/SerenityOS/serenity/pull/12628
@ -93,6 +93,9 @@ float Length::relative_length_to_px(Gfx::IntRect const& viewport_rect, Gfx::Font
|
||||
|
||||
float Length::to_px(Layout::Node const& layout_node) const
|
||||
{
|
||||
if (is_calculated())
|
||||
return m_calculated_style->resolve_length(layout_node)->to_px(layout_node);
|
||||
|
||||
if (!layout_node.document().browsing_context())
|
||||
return 0;
|
||||
auto viewport_rect = layout_node.document().browsing_context()->viewport_rect();
|
||||
|
@ -86,6 +86,8 @@ public:
|
||||
return 0;
|
||||
if (is_relative())
|
||||
return relative_length_to_px(viewport_rect, font_metrics, root_font_size);
|
||||
if (is_calculated())
|
||||
VERIFY_NOT_REACHED(); // We can't resolve a calculated length from here. :^(
|
||||
return absolute_length_to_px();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user