#9763·lynx

[WPT] replaced flex items shrink below the content-based automatic minimum width

Author: zhongyrCreated Sep 21, 2026Updated Sep 21, 2026
Labelsmodule:cssmodule:layoutmodule:starlightstatus:need triagetype:bug

System Info

  • Android 10 emulator (Pixel_1080x1920_AUTO), 1080 × 1920 pixels, density 320 (2× CSS-pixel scale).
  • Reference renderer: Android WebView 91.0.4472.114.
  • Lynx UIApp versionName=2.7.0 is the shell version, not a verified engine version. The APK's exact engine revision and compatibility configuration have not been established.
  • Inspected public source: 6dc0784fde6135466c21f51262a81e42a547f6d9. The flex algorithm, elastic sizing utility and BoxInfo files match the inspected local source byte-for-byte; the default-minimum and width-clamping functions were also checked against this public revision.

Details

Test and property roles

Primary WPT: css/css-flexbox/flex-minimum-width-flex-items-009.html, pinned at 269bca0dd35c303639f3c9cf1d8bcb3d911bdb60.

The sizing core is:

xml
<div class="row">
  <img class="item" src="support/60x60-green.png">
</div>
css
.row { display: flex; width: 10px; }
.item { min-height: 100px; }
/* Bitmap intrinsic size: 60 × 60; no authored min-width or flex override. */

This excerpt explains the sizing assertion; measurements below come from the full WPT adaptation, including its instruction paragraph and red underlay.

Input Role in this case
display:flex, default row direction Makes width the main-axis size and height the cross-axis size.
Container width:10px Creates negative free space and exercises shrinking.
Intrinsic 60×60 bitmap Supplies replaced-element content size and a 1:1 intrinsic ratio.
Image min-height:100px Clamps the content-size suggestion through the intrinsic ratio; the corresponding automatic main-axis minimum must be 100px.
Unspecified min-width, default shrink Exercises the Web content-based automatic minimum rather than an explicit width constraint.

The relevant requirement is Flexbox §4.5, Automatic Minimum Size of Flex Items. A cross-axis minimum is not simply an explicit main-axis minimum, but it must participate in the replaced item's content-size suggestion.

Observed behavior

  • WebView: a 100×100 CSS-pixel green square, physical bounds x=[16,216), y=[102,302). This primary reference satisfies the WPT self-assertion.
  • Lynx: a roughly 10×100 CSS-pixel green strip, physical green bounds x=[16,36), y=[102,301).
  • The complete comparison fails at 1.8796% against a 0.5% limit. The missing 90px of green width is the substantive failure, independently of text rasterization or underlay painting.

The card preserves the flex hierarchy, 10px container width, image min-height and exact bitmap. HTML containers map to views, the image uses auto-size="true" to supply intrinsic bitmap sizing, and setup explicitly restores Web content-box and main-axis alignment defaults. A paragraph-bottom spacing defect was repaired before the terminal run. Instruction bold emphasis is flattened, accounting for a small secondary text difference. No image width, minimum width, aspect ratio or shrink override was added to encode the expected square.

Engine diagnosis

This is a missing Web-compatible automatic-minimum behavior, not a negative flex-shrink parsing bug. The following data flow is confirmed in the inspected source; it is not a device-instrumented call trace.

  1. DefaultLayoutStyle sets kDefaultMinSize = 0.f; SL_DEFAULT_MIN_WIDTH() constructs a length from that value.
  2. BoxInfo::InitializeBoxInfo resolves the style minima into min_size_. The image's cross-axis min-height does not itself create a content-based horizontal minimum here.
  3. FlexLayoutAlgorithm::DetermineFlexBaseSizeAndHypotheticalMainSize computes flex bases and delegates hypothetical-size clamping to ElasticLayoutUtils::ComputeHypotheticalSizes. ResolveFlexibleLengths then uses the elastic shrink calculation.
  4. ResolveOneLine distributes negative free space and clamps the result:
cpp
float adjust_main_size = elastic_infos.direction_selector_.IsHorizontal()
                             ? item.ClampExactWidth(calc_main_size)
                             : item.ClampExactHeight(calc_main_size);
computed_item_sizes[idx] = adjust_main_size;

LayoutObject::ClampExactWidth only applies stored minima/maxima and the padding/border floor:

cpp
width = std::max(width, box_info_.min_size_[kHorizontal]);
width = std::min(width, box_info_.max_size_[kHorizontal]);
return std::max(GetPaddingAndBorderHorizontal(), width);

With a zero horizontal minimum and no padding/border, a 10px shrink result survives. There is no content-derived 100px lower bound for this item in that clamp. This accounts for the observed sizing boundary. The missing operation is calculation and application of the replaced flex item's automatic minimum, including the cross-axis constraint and intrinsic ratio; changing the shrink distribution formula alone would not supply it.

Related regression coverage and oracle limits

At the same WPT pin, the accompanying cases provide distinct branches:

Case suffix Input WebView / Lynx Diff
010 200×200 image, max-height:100px 100×100 / approximately 10×10 2.0436%
011 300×150 image, height:50px, zero-width flex row Image completes a 100×100 square / only the fixed upper 100×50 block remains 1.0433%
012 Same ratio, height:2000px; max-height:50px Complete square / only the upper block remains 1.0433%

Case 013 is not a conforming-oracle example: WebView 91 also fails its stretched-size assertion, painting a 300×50 lower image instead of 100×50; Lynx loses the lower image. Its 3.0209% environment difference must not be presented as distance from normative geometry. Revalidate that branch with a conforming WebView before using it as a reference for a fix.

Expected correction and acceptance criteria

  • In a Web-compatible flex sizing mode, compute the replaced item's content-based automatic main-axis minimum, accounting for applicable specified/transferred suggestions and definite cross-axis min/max constraints.
  • Apply that bound during hypothetical-size calculation and min/max violation handling before final shrink/freeze decisions.
  • Make 009 produce the 100×100 square without an authored min-width or disabled shrink; cover 010–012 as complementary branches.
  • Preserve intentionally shrinkable behavior for an explicit min-width:0 and the applicable scroll-container exceptions. Test row/column symmetry and compatibility configurations.
  • Confirm the deployed engine/configuration before choosing whether this is introduced as a compatibility-mode change.

Reproduce link

  • Pinned primary WPT source and its intrinsic bitmap.
  • Adaptation/evidence revision in the lynx-wpt working repository: 5b220c4c9b4ca32b1e6c0e470be0c82db536558d (local commit; no MR has been created for this batch). Paths: tests/css-flexbox/flex-minimum-width-flex-items-009/{index.ttml,index.ttss,evidence/}, docs/diagnostics/flex-minimum-width-flex-items-009-20260921.md, and docs/evidence/css-flexbox-cross-size-009-013-20260921-summary.tsv. These are evidence provenance, not publicly accessible reproduction links; the pinned WPT and excerpt above supply the public reproduction input.

Reproduce Steps

  1. Render the pinned original 009 source in a browser/WebView. Keep its local support/60x60-green.png resource available. Confirm a 100×100 green square.
  2. Render the equivalent Lynx hierarchy with a row flex view of width 10px and an image using that exact bitmap, auto-size="true", and min-height:100px. Restore setup-only Web box sizing/alignment, but do not add a main-axis minimum or disable shrinking.
  3. Compare image width: the affected Lynx environment produces approximately 10px instead of 100px.
  4. Repeat with the full adapted WPT card to retain the original self-assertion and surroundings.

The primary terminal run exited 1 with exactly one matching result, original-test WebView reference, independently audited meaningful PNGs, cleaned runner artifacts and a released execution lock. Case-local expected/actual/diff PNGs are Git LFS-managed; the evidence gate verified all five summary rows and 15 PNGs. No WPT match-reference content was read.

Duplicate check

Searched open and closed issues for WPT, the exact flex-minimum family, min-width, automatic minimum, transferred, min-content and flex shrink. No equivalent report was found at filing time. #8979 concerns premature wrapped-item stretch, #9549 concerns percentage-maxima refresh after a legitimate definite-size transition, and #8350 concerns negative shrink-factor parsing; none reports this missing content-based automatic minimum.