LibWeb: Fix double-sized box model metrics on inline replaced elements

We were mistakenly treating inline replaced elements as if they are the
start of a regular display:inline element. This meant that we collected
the horizontal start and end metrics from the box model, and then added
those to the inline-level item produced by InlineLevelIterator.

This effectively meant that <img>, <svg> and other replaced elements got
double-sized values for margin/border/padding on the left and right
sides. (Which manifested as a mysterious margin around the element.)
This commit is contained in:
Andreas Kling 2022-04-08 23:12:04 +02:00
parent 6e70670e0b
commit 45db35ad04
Notes: sideshowbarker 2024-07-17 14:15:45 +09:00

View file

@ -108,7 +108,7 @@ void InlineLevelIterator::compute_next()
void InlineLevelIterator::skip_to_next()
{
if (m_next_node && is<Layout::NodeWithStyleAndBoxModelMetrics>(*m_next_node) && !m_next_node->is_inline_block() && !m_next_node->is_out_of_flow(m_inline_formatting_context))
if (m_next_node && is<Layout::NodeWithStyleAndBoxModelMetrics>(*m_next_node) && !m_next_node->is_inline_block() && !m_next_node->is_out_of_flow(m_inline_formatting_context) && !is<ReplacedBox>(m_next_node))
enter_node_with_box_model_metrics(static_cast<Layout::NodeWithStyleAndBoxModelMetrics const&>(*m_next_node));
m_current_node = m_next_node;