Files
rust_browser/tests/goldens/expected/043-heading-levels.layout.txt
Zachary D. Rowitsch 20e241bd03
All checks were successful
ci / fast (linux) (push) Successful in 6m52s
Implement margin collapsing through empty elements (CSS 2.1 §8.3.1)
Self-collapsing elements (zero height, no padding/border, no BFC, no line
boxes) now have their top and bottom margins collapse together, and child
margins propagate through parents with auto height and no bottom
padding/border. This replaces the pairwise collapse_margins() function
with a MarginSet accumulator that tracks max positive and min negative
margins separately, correctly resolving chains of 4+ margins.

Key changes:
- Add is_self_collapsing() post-layout predicate and gather_all_margins()
- Add gather_margin_bottom() for bottom margin propagation with a guard
  against propagation when max-height constrains the parent
- Replace prev_margin_bottom with MarginSet-based pending_margins in the
  sibling layout loop
- Handle clearance + self-collapsing interaction correctly

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 01:04:53 -05:00

101 lines
4.2 KiB
Plaintext

LayoutBox node=#1 tag=html box=block
content: (0, 0, 800, 326.85443)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
LayoutBox node=#3 tag=body box=block
content: (8, 8, 784, 293.87683)
padding: 0 0 0 0
border: 0 0 0 0
margin: 8 8 8 8
LayoutBox node=#5 tag=h1 box=block
content: (8, 29.44, 784, 38.4)
padding: 0 0 0 0
border: 0 0 0 0
margin: 21.44 0 21.44 0
inline_context: 1 lines, height=38.4, max_width=117.61528
line[0]: rect=(8, 29.44, 117.61528, 38.4) fragments=2
frag[0]: rect=(8, 32.64, 98.06755, 32) text="Heading" start=false end=false
frag[1]: rect=(112.176216, 32.64, 13.43906, 32) text="1" start=false end=false
LayoutBox node=#6 tag=anonymous box=anon
content: (0, 0, 117.61528, 32)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
text: "Heading 1"
LayoutBox node=#8 tag=h2 box=block
content: (8, 89.28001, 784, 28.800003)
padding: 0 0 0 0
border: 0 0 0 0
margin: 19.92 0 19.92 0
inline_context: 1 lines, height=28.800003, max_width=88.21145
line[0]: rect=(8, 89.28001, 88.21145, 28.800001) fragments=2
frag[0]: rect=(8, 91.68001, 73.55066, 24) text="Heading" start=false end=false
frag[1]: rect=(86.13216, 91.68001, 10.079295, 24) text="2" start=false end=false
LayoutBox node=#9 tag=anonymous box=anon
content: (0, 0, 88.21145, 24)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
text: "Heading 2"
LayoutBox node=#11 tag=h3 box=block
content: (8, 138.00002, 784, 22.464005)
padding: 0 0 0 0
border: 0 0 0 0
margin: 18.72 0 18.72 0
inline_context: 1 lines, height=22.464005, max_width=68.80493
line[0]: rect=(8, 138.00002, 68.80493, 22.464003) fragments=2
frag[0]: rect=(8, 139.87201, 57.369514, 18.72) text="Heading" start=false end=false
frag[1]: rect=(68.943085, 139.87201, 7.86185, 18.72) text="3" start=false end=false
LayoutBox node=#12 tag=anonymous box=anon
content: (0, 0, 68.80493, 18.72)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
text: "Heading 3"
LayoutBox node=#14 tag=h4 box=block
content: (8, 181.74402, 784, 19.199997)
padding: 0 0 0 0
border: 0 0 0 0
margin: 21.28 0 21.28 0
inline_context: 1 lines, height=19.199997, max_width=58.80764
line[0]: rect=(8, 181.74402, 58.80764, 19.2) fragments=2
frag[0]: rect=(8, 183.34402, 49.033775, 16) text="Heading" start=false end=false
frag[1]: rect=(60.088108, 183.34402, 6.71953, 16) text="4" start=false end=false
LayoutBox node=#15 tag=anonymous box=anon
content: (0, 0, 58.80764, 16)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
text: "Heading 4"
LayoutBox node=#17 tag=h5 box=block
content: (8, 223.12161, 784, 15.936005)
padding: 0 0 0 0
border: 0 0 0 0
margin: 22.177599 0 22.177599 0
inline_context: 1 lines, height=15.936005, max_width=48.810337
line[0]: rect=(8, 223.12161, 48.810337, 15.936) fragments=2
frag[0]: rect=(8, 224.44962, 40.698032, 13.28) text="Heading" start=false end=false
frag[1]: rect=(51.233128, 224.44962, 5.57721, 13.28) text="5" start=false end=false
LayoutBox node=#18 tag=anonymous box=anon
content: (0, 0, 48.810337, 13.28)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
text: "Heading 5"
LayoutBox node=#20 tag=h6 box=block
content: (8, 264.03522, 784, 12.864014)
padding: 0 0 0 0
border: 0 0 0 0
margin: 24.9776 0 24.9776 0
inline_context: 1 lines, height=12.864014, max_width=39.401115
line[0]: rect=(8, 264.03522, 39.401115, 12.864001) fragments=2
frag[0]: rect=(8, 265.1072, 32.852627, 10.72) text="Heading" start=false end=false
frag[1]: rect=(42.89903, 265.1072, 4.502085, 10.72) text="6" start=false end=false
LayoutBox node=#21 tag=anonymous box=anon
content: (0, 0, 39.401115, 10.72)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
text: "Heading 6"