Files
rust_browser/tests/goldens/expected/158-table-with-caption.layout.txt
Zachary D. Rowitsch f642f4f17c Fix tables with captions not rendering and add caption layout support
Tables with <caption> elements were invisible because normalize_children
treated TableRowGroup/TableRow/TableCell as inline-level, causing them to
be wrapped in anonymous blocks when mixed with the caption (Block). The
table layout algorithm then couldn't find row groups among direct children.

Three fixes:
- Add table-internal types to is_block_level in normalize_children and
  determine_formatting_context so they aren't incorrectly wrapped
- Add table-internal types to render_non_inline_descendants in the
  display list builder so they render when nested in inline contexts
- Implement caption layout in calculate_table_layout: captions are laid
  out as blocks above the table rows, with rows offset accordingly
- Add text-align: center to caption in UA stylesheet per CSS spec

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 00:24:29 -05:00

146 lines
6.2 KiB
Plaintext

LayoutBox node=#2 tag=html box=block
content: (0, 0, 800, 100.8)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
LayoutBox node=#8 tag=body box=block
content: (8, 8, 784, 84.8)
padding: 0 0 0 0
border: 0 0 0 0
margin: 8 8 8 8
LayoutBox node=#10 tag=table box=table
content: (8, 8, 784, 84.8)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
LayoutBox node=#12 tag=caption box=block
content: (8, 8, 784, 19.2)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
inline_context: 1 lines, height=19.2, max_width=68.95741
line[0]: rect=(365.5213, 8, 68.95741, 19.2) fragments=2
frag[0]: rect=(365.5213, 8, 23.024963, 16) text="Test" start=false end=false
frag[1]: rect=(391.6006, 8, 42.87812, 16) text="Caption" start=false end=false
LayoutBox node=#13 tag=anonymous box=anon
content: (0, 0, 68.95742, 16)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
text: "Test Caption"
LayoutBox node=#15 tag=thead box=table-row-group
content: (8, 29.2, 784, 19.2)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
LayoutBox node=#16 tag=tr box=table-row
content: (8, 29.2, 784, 19.2)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
LayoutBox node=#17 tag=th box=table-cell
content: (10, 29.2, 389, 19.2)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
inline_context: 1 lines, height=19.2, max_width=52.499268
line[0]: rect=(10, 29.2, 52.499268, 19.2) fragments=2
frag[0]: rect=(10, 29.2, 42.725403, 16) text="Header" start=false end=false
frag[1]: rect=(55.779736, 29.2, 6.71953, 16) text="1" start=false end=false
LayoutBox node=#18 tag=anonymous box=anon
content: (0, 29.2, 52.499268, 16)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
text: "Header 1"
LayoutBox node=#19 tag=th box=table-cell
content: (401, 29.2, 389, 19.2)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
inline_context: 1 lines, height=19.2, max_width=52.499268
line[0]: rect=(401, 29.2, 52.499268, 19.2) fragments=2
frag[0]: rect=(401, 29.2, 42.725403, 16) text="Header" start=false end=false
frag[1]: rect=(446.77972, 29.2, 6.71953, 16) text="2" start=false end=false
LayoutBox node=#20 tag=anonymous box=anon
content: (0, 29.2, 52.499268, 16)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
text: "Header 2"
LayoutBox node=#22 tag=tbody box=table-row-group
content: (8, 50.4, 784, 40.4)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
LayoutBox node=#24 tag=tr box=table-row
content: (8, 50.4, 784, 19.2)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
LayoutBox node=#25 tag=td box=table-cell
content: (10, 50.4, 389, 19.2)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
inline_context: 1 lines, height=19.2, max_width=30.672543
line[0]: rect=(10, 50.4, 30.672543, 19.2) fragments=2
frag[0]: rect=(10, 50.4, 20.111603, 16) text="Cell" start=false end=false
frag[1]: rect=(33.165936, 50.4, 7.506608, 16) text="A" start=false end=false
LayoutBox node=#26 tag=anonymous box=anon
content: (0, 50.4, 30.672543, 16)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
text: "Cell A"
LayoutBox node=#27 tag=td box=table-cell
content: (401, 50.4, 389, 19.2)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
inline_context: 1 lines, height=19.2, max_width=30.801758
line[0]: rect=(401, 50.4, 30.801758, 19.2) fragments=2
frag[0]: rect=(401, 50.4, 20.111603, 16) text="Cell" start=false end=false
frag[1]: rect=(424.16592, 50.4, 7.6358294, 16) text="B" start=false end=false
LayoutBox node=#28 tag=anonymous box=anon
content: (0, 50.4, 30.801765, 16)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
text: "Cell B"
LayoutBox node=#30 tag=tr box=table-row
content: (8, 71.600006, 784, 19.2)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
LayoutBox node=#31 tag=td box=table-cell
content: (10, 71.600006, 389, 19.2)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
inline_context: 1 lines, height=19.2, max_width=30.590313
line[0]: rect=(10, 71.600006, 30.590313, 19.2) fragments=2
frag[0]: rect=(10, 71.600006, 20.111603, 16) text="Cell" start=false end=false
frag[1]: rect=(33.165936, 71.600006, 7.424376, 16) text="C" start=false end=false
LayoutBox node=#32 tag=anonymous box=anon
content: (0, 71.600006, 30.590311, 16)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
text: "Cell C"
LayoutBox node=#33 tag=td box=table-cell
content: (401, 71.600006, 389, 19.2)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
inline_context: 1 lines, height=19.2, max_width=31.741547
line[0]: rect=(401, 71.600006, 31.741547, 19.2) fragments=2
frag[0]: rect=(401, 71.600006, 20.111603, 16) text="Cell" start=false end=false
frag[1]: rect=(424.16592, 71.600006, 8.5756235, 16) text="D" start=false end=false
LayoutBox node=#34 tag=anonymous box=anon
content: (0, 71.600006, 31.741558, 16)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
text: "Cell D"