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.
This commit is contained in:
Andreas Kling 2025-02-22 14:59:09 +01:00 committed by Andreas Kling
parent 591f06f887
commit cdd2ccac0b
Notes: github-actions[bot] 2025-02-22 19:03:14 +00:00

View file

@ -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;