LibWeb: Move min-height handling for independent FCs to parent context

Previously, GridFormattingContext handled its own min-height constraints
internally, which caused infinite recursion when min-height was an
intrinsic sizing keyword (e.g., min-height: max-content).

This change moves the responsibility to the parent formatting context
(BFC). When any box establishing an independent formatting context has
auto height but non-auto min-height:
1. BFC measures content height using a throwaway LayoutState
2. If content height < min-height, BFC passes min-height as definite
   available height to the child formatting context
3. Child FC runs once with correct constraints, unaware of min-height

Fixes https://github.com/LadybirdBrowser/ladybird/issues/4261 which
is corresponding to stack overflow on https://claude.ai/
This commit is contained in:
Aliaksandr Kalenik
2026-01-05 12:45:08 +01:00
committed by Alexander Kalenik
parent 72083425d0
commit bdf2dbff98
Notes: github-actions[bot] 2026-01-05 15:10:44 +00:00
13 changed files with 164 additions and 29 deletions

View File

@@ -2,26 +2,26 @@ Harness status: OK
Found 27 tests
21 Pass
6 Fail
25 Pass
2 Fail
Pass Property grid-template-rows value 'none'
Fail Property grid-template-rows value '20%'
Pass Property grid-template-rows value '20%'
Pass Property grid-template-rows value 'calc(-0.5em + 10px)'
Pass Property grid-template-rows value 'calc(0.5em + 10px)'
Fail Property grid-template-rows value 'calc(30% + 40px)'
Pass Property grid-template-rows value 'calc(30% + 40px)'
Pass Property grid-template-rows value '5fr'
Pass Property grid-template-rows value 'min-content'
Pass Property grid-template-rows value 'max-content'
Pass Property grid-template-rows value 'auto'
Pass Property grid-template-rows value 'minmax(10px, auto)'
Fail Property grid-template-rows value 'minmax(20%, max-content)'
Pass Property grid-template-rows value 'minmax(20%, max-content)'
Pass Property grid-template-rows value 'minmax(min-content, calc(-0.5em + 10px))'
Pass Property grid-template-rows value 'minmax(auto, 0)'
Pass Property grid-template-rows value 'fit-content(70px)'
Pass Property grid-template-rows value 'fit-content(20%)'
Pass Property grid-template-rows value 'fit-content(calc(-0.5em + 10px))'
Pass Property grid-template-rows value 'repeat(1, 10px)'
Fail Property grid-template-rows value 'repeat(1, [one two] 20%)'
Pass Property grid-template-rows value 'repeat(1, [one two] 20%)'
Pass Property grid-template-rows value 'repeat(2, minmax(10px, auto))'
Pass Property grid-template-rows value 'repeat(2, fit-content(20%) [three four] 30px 40px [five six])'
Pass Property grid-template-rows value 'min-content repeat(5, minmax(10px, auto))'