From cdd2ccac0bbedf2bdc90458961995ded33c82c6d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 22 Feb 2025 14:59:09 +0100 Subject: [PATCH] LibWeb: Resolve used vertical margins on inline elements Even though we don't actually make use of these values at the moment, we still want them to be reflected correctly once we start exposing used margin values soon. --- Libraries/LibWeb/Layout/InlineLevelIterator.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Libraries/LibWeb/Layout/InlineLevelIterator.cpp b/Libraries/LibWeb/Layout/InlineLevelIterator.cpp index 63078325a75..4c82fccc067 100644 --- a/Libraries/LibWeb/Layout/InlineLevelIterator.cpp +++ b/Libraries/LibWeb/Layout/InlineLevelIterator.cpp @@ -35,10 +35,17 @@ void InlineLevelIterator::enter_node_with_box_model_metrics(Layout::NodeWithStyl auto& used_values = m_layout_state.get_mutable(node); auto const& computed_values = node.computed_values(); + used_values.margin_top = computed_values.margin().top().to_px(node, m_containing_block_used_values.content_width()); + used_values.margin_bottom = computed_values.margin().bottom().to_px(node, m_containing_block_used_values.content_width()); + used_values.margin_left = computed_values.margin().left().to_px(node, m_containing_block_used_values.content_width()); used_values.border_left = computed_values.border_left().width; used_values.padding_left = computed_values.padding().left().to_px(node, m_containing_block_used_values.content_width()); + used_values.margin_right = computed_values.margin().right().to_px(node, m_containing_block_used_values.content_width()); + used_values.border_right = computed_values.border_right().width; + used_values.padding_right = computed_values.padding().right().to_px(node, m_containing_block_used_values.content_width()); + used_values.border_top = computed_values.border_top().width; used_values.border_bottom = computed_values.border_bottom().width; used_values.padding_bottom = computed_values.padding().bottom().to_px(node, m_containing_block_used_values.content_width()); @@ -61,11 +68,6 @@ void InlineLevelIterator::exit_node_with_box_model_metrics() auto& node = m_box_model_node_stack.last(); auto& used_values = m_layout_state.get_mutable(node); - auto const& computed_values = node->computed_values(); - - used_values.margin_right = computed_values.margin().right().to_px(node, m_containing_block_used_values.content_width()); - used_values.border_right = computed_values.border_right().width; - used_values.padding_right = computed_values.padding().right().to_px(node, m_containing_block_used_values.content_width()); m_extra_trailing_metrics->margin += used_values.margin_right; m_extra_trailing_metrics->border += used_values.border_right;