Files
rust_browser/tests/goldens/expected/009-margin-padding.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

29 lines
1.1 KiB
Plaintext

LayoutBox node=#1 tag=html box=block
content: (0, 0, 800, 67.2)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
LayoutBox node=#9 tag=body box=block
content: (8, 8, 784, 49.2)
padding: 0 0 0 0
border: 0 0 0 0
margin: 8 8 8 8
LayoutBox node=#11 tag=div box=block
content: (23, 23, 754, 19.2)
padding: 5 5 5 5
border: 0 0 0 0
margin: 10 10 10 10
inline_context: 1 lines, height=19.2, max_width=163.73569
line[0]: rect=(23, 23, 163.73569, 19.2) fragments=5
frag[0]: rect=(23, 24.6, 20.957415, 16) text="Box" start=false end=false
frag[1]: rect=(47.011745, 24.6, 23.765053, 16) text="with" start=false end=false
frag[2]: rect=(73.83112, 24.6, 39.94126, 16) text="margin" start=false end=false
frag[3]: rect=(116.82671, 24.6, 21.07489, 16) text="and" start=false end=false
frag[4]: rect=(140.95595, 24.6, 45.779736, 16) text="padding" start=false end=false
LayoutBox node=#12 tag=anonymous box=anon
content: (0, 0, 163.73569, 16)
padding: 0 0 0 0
border: 0 0 0 0
margin: 0 0 0 0
text: "Box with margin and ..."