Per the CSS Flexbox spec, a flex item with visibility: collapse
should occupy zero main-axis size (width in a row flex) but still contribute
its cross-axis size (height) to the line. Chrome was ignoring this and simply
hiding the item while preserving its full size in both axes.
Toggle collapse on the middle item (orange, B) to see the effect. The expected behavior: B should occupy zero width, and the container height should remain 60px (B's cross-size acts as a "strut").
main-axis Collapsed item occupies zero width (in row flex)
cross-axis Container height preserves the collapsed item's height ("strut")
siblings Adjacent items are positioned as if the collapsed item is absent
flex-grow Collapsed items do not participate in flex-grow distribution
main-axis Collapsed item still occupies its full width
siblings Adjacent items are shifted as if item is still fully present
<div style="display: flex;">
<div style="width:60px; height:40px;">A</div>
<div style="width:60px; height:60px;
visibility: collapse;">B</div>
<div style="width:60px; height:40px;">C</div>
</div>
/* Expected: B has 0px width, container is 60px tall */
/* Before fix: B has 60px width, same as hidden */
flex_item.h -- Added is_collapsed flag; size methods return 0 for collapsed items
flex_layout_algorithm.cc -- Detect visibility:collapse; fix gap/margin/spacing calculations
line_flexer.cc -- Freeze collapsed items at zero size during flex resolution
flex_layout_algorithm_test.cc -- 4 new unit tests
pass flexbox_visibility-collapse.html
pass flexbox_visibility-collapse-line-wrapping.html
pass flexbox-collapsed-item-horiz-001.html
remaining 3 tests need full two-pass algorithm (multi-line strut migration)