) [9,166.875 161.90625x39.46875] overflow: [9,9 161.90625x197.34375]
PaintableWithLines (BlockContainer) [9,166.875 56.265625x39.46875]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer | ) [65.265625,166.875 54.546875x39.46875]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer | ) [119.8125,166.875 51.09375x39.46875]
TextPaintable (TextNode<#text>)
+ PaintableWithLines (BlockContainer(anonymous)) [9,9 0x0]
+ PaintableWithLines (BlockContainer(anonymous)) [9,9 0x0]
+ PaintableWithLines (BlockContainer(anonymous)) [9,9 0x0]
PaintableWithLines (BlockContainer(anonymous)) [8,207.34375 784x0]
diff --git a/Tests/LibWeb/Layout/expected/table/inline-table-width.txt b/Tests/LibWeb/Layout/expected/table/inline-table-width.txt
index 5598c011ea..b3a2cd448f 100644
--- a/Tests/LibWeb/Layout/expected/table/inline-table-width.txt
+++ b/Tests/LibWeb/Layout/expected/table/inline-table-width.txt
@@ -1,7 +1,7 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer at (0,0) content-size 800x600 [BFC] children: not-inline
BlockContainer at (8,8) content-size 784x46.9375 children: inline
- line 0 width: 137.984375, height: 46.9375, bottom: 46.9375, baseline: 46.9375
+ line 0 width: 137.984375, height: 46.9375, bottom: 46.9375, baseline: 39
frag 0 from BlockContainer start: 0, length: 0, rect: [9,9 135.984375x44.9375]
BlockContainer at (9,9) content-size 135.984375x44.9375 inline-block [BFC] children: not-inline
TableWrapper <(anonymous)> at (9,9) content-size 135.984375x44.9375 inline-block [BFC] children: not-inline
diff --git a/Tests/LibWeb/Layout/expected/table/nested-table-box-width.txt b/Tests/LibWeb/Layout/expected/table/nested-table-box-width.txt
index 88575ea406..17ec18506a 100644
--- a/Tests/LibWeb/Layout/expected/table/nested-table-box-width.txt
+++ b/Tests/LibWeb/Layout/expected/table/nested-table-box-width.txt
@@ -52,11 +52,11 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
frag 0 from TextNode start: 0, length: 1, rect: [75.5625,81.46875 9.34375x17.46875]
"B"
TextNode <#text>
- BlockContainer <(anonymous)> (not painted) children: inline
+ BlockContainer <(anonymous)> at (58.5625,25) content-size 0x0 children: inline
TextNode <#text>
- BlockContainer <(anonymous)> (not painted) children: inline
+ BlockContainer <(anonymous)> at (58.5625,25) content-size 0x0 children: inline
TextNode <#text>
- BlockContainer <(anonymous)> (not painted) children: inline
+ BlockContainer <(anonymous)> at (58.5625,25) content-size 0x0 children: inline
TextNode <#text>
BlockContainer <(anonymous)> at (58.5625,115.9375) content-size 48.265625x0 children: inline
TextNode <#text>
@@ -95,14 +95,17 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer) [48.5625,15 68.265625x110.9375]
PaintableWithLines (BlockContainer(anonymous)) [58.5625,25 48.265625x0]
PaintableWithLines (TableWrapper(anonymous)) [58.5625,25 48.265625x90.9375]
- PaintableBox (Box) [58.5625,25 48.265625x90.9375]
- PaintableBox (Box) [63.5625,30 34.265625x74.9375] overflow: [63.5625,30 36.265625x78.9375]
+ PaintableBox (Box) [58.5625,25 48.265625x90.9375] overflow: [58.5625,25 43.265625x85.9375]
+ PaintableBox (Box) [63.5625,30 34.265625x74.9375] overflow: [58.5625,25 41.265625x83.9375]
PaintableBox (Box) [65.5625,32 34.265625x37.46875]
PaintableWithLines (BlockContainer) [65.5625,32 34.265625x37.46875]
TextPaintable (TextNode<#text>)
- PaintableBox (Box | ) [65.5625,71.46875 34.265625x37.46875]
+ PaintableBox (Box ) [65.5625,71.46875 34.265625x37.46875] overflow: [58.5625,25 41.265625x83.9375]
PaintableWithLines (BlockContainer) [65.5625,71.46875 34.265625x37.46875]
TextPaintable (TextNode<#text>)
+ PaintableWithLines (BlockContainer(anonymous)) [58.5625,25 0x0]
+ PaintableWithLines (BlockContainer(anonymous)) [58.5625,25 0x0]
+ PaintableWithLines (BlockContainer(anonymous)) [58.5625,25 0x0]
PaintableWithLines (BlockContainer(anonymous)) [58.5625,115.9375 48.265625x0]
PaintableBox (Box | ) [15,71.46875 99.828125x54.46875]
PaintableWithLines (BlockContainer) [15,71.46875 31.5625x54.46875]
diff --git a/Tests/LibWeb/Layout/expected/table/row-span-and-nested-tables.txt b/Tests/LibWeb/Layout/expected/table/row-span-and-nested-tables.txt
index 62aee5219a..347394518f 100644
--- a/Tests/LibWeb/Layout/expected/table/row-span-and-nested-tables.txt
+++ b/Tests/LibWeb/Layout/expected/table/row-span-and-nested-tables.txt
@@ -64,11 +64,11 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
frag 0 from TextNode start: 0, length: 1, rect: [51.5625,88.9375 10.3125x17.46875]
"C"
TextNode <#text>
- BlockContainer <(anonymous)> (not painted) children: inline
+ BlockContainer <(anonymous)> at (42.5625,17) content-size 0x0 children: inline
TextNode <#text>
- BlockContainer <(anonymous)> (not painted) children: inline
+ BlockContainer <(anonymous)> at (42.5625,17) content-size 0x0 children: inline
TextNode <#text>
- BlockContainer <(anonymous)> (not painted) children: inline
+ BlockContainer <(anonymous)> at (42.5625,17) content-size 0x0 children: inline
TextNode <#text>
BlockContainer <(anonymous)> at (42.5625,115.40625) content-size 32.265625x0 children: inline
TextNode <#text>
@@ -107,17 +107,20 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer | ) [36.5625,11 44.265625x110.40625]
PaintableWithLines (BlockContainer(anonymous)) [42.5625,17 32.265625x0]
PaintableWithLines (TableWrapper(anonymous)) [42.5625,17 32.265625x98.40625]
- PaintableBox (Box) [42.5625,17 32.265625x98.40625]
- PaintableBox (Box) [43.5625,18 26.265625x88.40625] overflow: [43.5625,18 28.265625x94.40625]
+ PaintableBox (Box) [42.5625,17 32.265625x98.40625] overflow: [42.5625,17 31.265625x97.40625]
+ PaintableBox (Box) [43.5625,18 26.265625x88.40625] overflow: [42.5625,17 29.265625x95.40625]
PaintableBox (Box) [45.5625,20 26.265625x29.46875]
PaintableWithLines (BlockContainer) [45.5625,20 26.265625x29.46875]
TextPaintable (TextNode<#text>)
PaintableBox (Box | ) [45.5625,51.46875 26.265625x29.46875]
PaintableWithLines (BlockContainer) [45.5625,51.46875 26.265625x29.46875]
TextPaintable (TextNode<#text>)
- PaintableBox (Box | ) [45.5625,82.9375 26.265625x29.46875]
+ PaintableBox (Box ) [45.5625,82.9375 26.265625x29.46875] overflow: [42.5625,17 29.265625x95.40625]
PaintableWithLines (BlockContainer) [45.5625,82.9375 26.265625x29.46875]
TextPaintable (TextNode<#text>)
+ PaintableWithLines (BlockContainer(anonymous)) [42.5625,17 0x0]
+ PaintableWithLines (BlockContainer(anonymous)) [42.5625,17 0x0]
+ PaintableWithLines (BlockContainer(anonymous)) [42.5625,17 0x0]
PaintableWithLines (BlockContainer(anonymous)) [42.5625,115.40625 32.265625x0]
PaintableBox (Box | ) [11,67.203125 67.828125x54.203125]
PaintableWithLines (BlockContainer) [11,67.203125 23.5625x54.1875]
diff --git a/Tests/LibWeb/Layout/input/block-and-inline/button-baseline-align.html b/Tests/LibWeb/Layout/input/block-and-inline/button-baseline-align.html
new file mode 100644
index 0000000000..024c8a541e
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/block-and-inline/button-baseline-align.html
@@ -0,0 +1,23 @@
+
+
+
\ No newline at end of file
diff --git a/Tests/LibWeb/Layout/input/block-and-inline/button-with-block-content-baseline-align.html b/Tests/LibWeb/Layout/input/block-and-inline/button-with-block-content-baseline-align.html
new file mode 100644
index 0000000000..38a4621026
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/block-and-inline/button-with-block-content-baseline-align.html
@@ -0,0 +1,25 @@
+
+
+
\ No newline at end of file
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
index 2ae6c9bdd0..97ee7b6cc6 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
@@ -1676,17 +1676,20 @@ CSSPixelRect FormattingContext::absolute_content_rect(Box const& box) const
Box const* FormattingContext::box_child_to_derive_baseline_from(Box const& box) const
{
+ if (!box.has_children() || box.children_are_inline())
+ return nullptr;
// To find the baseline of a box, we first look for the last in-flow child with at least one line box.
auto const* last_box_child = box.last_child_of_type();
for (Node const* child = last_box_child; child; child = child->previous_sibling()) {
if (!child->is_box())
continue;
auto& child_box = static_cast(*child);
- if (child_box.is_out_of_flow(*this))
- continue;
- if (m_state.get(child_box).line_boxes.is_empty())
- continue;
- return &child_box;
+ if (!child_box.is_out_of_flow(*this) && !m_state.get(child_box).line_boxes.is_empty()) {
+ return &child_box;
+ }
+ auto box_child_to_derive_baseline_from_candidate = box_child_to_derive_baseline_from(child_box);
+ if (box_child_to_derive_baseline_from_candidate)
+ return box_child_to_derive_baseline_from_candidate;
}
// None of the children has a line box.
return nullptr;
@@ -1719,12 +1722,10 @@ CSSPixels FormattingContext::box_baseline(Box const& box) const
if (!box_state.line_boxes.is_empty())
return box_state.margin_box_top() + box_state.offset.y() + box_state.line_boxes.last().baseline();
- if (box.has_children() && !box.children_are_inline()) {
- // If none of the children have a baseline set, the bottom margin edge of the box is used.
- if (auto const* child_box = box_child_to_derive_baseline_from(box)) {
- return box_baseline(*child_box);
- }
+ if (auto const* child_box = box_child_to_derive_baseline_from(box)) {
+ return box_baseline(*child_box);
}
+ // If none of the children have a baseline set, the bottom margin edge of the box is used.
return box_state.margin_box_height();
}
| | | |