Files
Zachary D. Rowitsch 487fa4e347 Fix display-list duplication of inline-block atoms (F-011)
On the CNN homepage ~19% of paint items were exact duplicates: story-card
headlines painted 2x and badges up to 6x at identical coordinates. Root cause
was a direct inline-block child of an element establishing an inline formatting
context (IFC) being handled by two independent paint paths, plus a positioned-
auto descendant being painted both in place and after step-6 hoisting.

Three coordinated fixes in the display-list builder, each independently
necessary (verified by toggling on the real CNN page):

1. Exclude direct inline-block children of an IFC element from
   `normal_flow_children`. They are atomic inline-level boxes painted once as a
   self-contained unit by `render_non_inline_descendants`; including them in
   normal flow painted them again via the phased step-3/step-5 passes and walked
   them a second time during step-6 collection.

2. Deduplicate the step-6 positioned-descendant list by node id. A positioned-
   auto descendant could be collected by both the normal-flow loop and the
   has_ifc pass (overlapping subtrees), rendering its whole subtree twice.

3. Track an `in_atomic_inline_block` flag: while painting an inline-block atom's
   Full render, suppress the in-place render of positioned-auto descendants —
   they are hoisted to the owning stacking context's CSS 2.1 Appendix E step-6
   and painted there exactly once. The flag is reset on entering any stacking
   context so hoisted/own positioned descendants still paint in place.

Result on the saved CNN page: 2394 -> 1944 paint items; the badge SolidRect,
"CNN INVESTIGATES", and the lead headline now each appear exactly once.

A previously known_fail WPT reftest (flexbox margin-left: auto with inline-block
items in a position:relative flex container) now passes and is promoted.

Regression tests: test_relative_headline_in_inline_block_painted_once and
test_positioned_auto_in_inline_block_painted_once in display_list — both fail
before the fix and pass after.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 11:20:52 -04:00
..
2026-01-31 16:20:53 -05:00