.Layout-sidebar) [10,10 222x21.46875]
+ PaintableWithLines (BlockContainer
.d-inline-block) [11,11 102x19.46875]
+ TextPaintable (TextNode<#text>)
+ PaintableWithLines (BlockContainer
.float-left) [11,30.46875 234.71875x220.5625]
+ TextPaintable (TextNode<#text>)
diff --git a/Tests/LibWeb/Layout/input/block-and-inline/float-should-avoid-inline-block.html b/Tests/LibWeb/Layout/input/block-and-inline/float-should-avoid-inline-block.html
new file mode 100644
index 00000000000..74c63a475e1
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/block-and-inline/float-should-avoid-inline-block.html
@@ -0,0 +1,18 @@
+
\ No newline at end of file
diff --git a/Userland/Libraries/LibWeb/Layout/LineBox.cpp b/Userland/Libraries/LibWeb/Layout/LineBox.cpp
index cd707a242a2..5ba5aa99a8d 100644
--- a/Userland/Libraries/LibWeb/Layout/LineBox.cpp
+++ b/Userland/Libraries/LibWeb/Layout/LineBox.cpp
@@ -29,6 +29,7 @@ void LineBox::add_fragment(Node const& layout_node, int start, int length, CSSPi
m_fragments.append(LineBoxFragment { layout_node, start, length, CSSPixelPoint(x_offset, y_offset), CSSPixelSize(content_width, content_height), border_box_top, border_box_bottom });
}
m_width += leading_margin + leading_size + content_width + trailing_size + trailing_margin;
+ m_height = max(m_height, content_height + border_box_top + border_box_bottom);
}
void LineBox::trim_trailing_whitespace()
diff --git a/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp b/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp
index 295147ac634..43e3c22034d 100644
--- a/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp
+++ b/Userland/Libraries/LibWeb/Layout/LineBuilder.cpp
@@ -111,11 +111,11 @@ CSSPixels LineBuilder::y_for_float_to_be_inserted_here(Box const& box)
CSSPixels candidate_y = m_current_y;
- CSSPixels current_line_width = ensure_last_line_box().width();
+ auto const& current_line = ensure_last_line_box();
// If there's already inline content on the current line, check if the new float can fit
// alongside the content. If not, place it on the next line.
- if (current_line_width > 0 && (current_line_width + width) > m_available_width_for_current_line)
- candidate_y += m_context.containing_block().line_height();
+ if (current_line.width() > 0 && (current_line.width() + width) > m_available_width_for_current_line)
+ candidate_y += current_line.height();
// Then, look for the next Y position where we can fit the new float.
// FIXME: This is super dumb, we move 1px downwards per iteration and stop