mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 13:02:09 +02:00
When computing the width of a box with `width: auto` in an intrinsic sizing context (min-content or max-content), we previously called calculate_min/max_content_width() for every such box. This was wasteful for boxes that don't establish their own formatting context (e.g. plain divs in a BFC), since their intrinsic width is simply the intrinsic width of their contents, which we're already computing as part of the current layout pass. By only computing intrinsic widths separately for boxes that actually create a new formatting context (BFC, flex, grid, table, etc.), we avoid creating redundant throwaway LayoutState objects and formatting contexts. For deeply nested structures with `width: max-content` on an ancestor, this reduces the number of formatting contexts created from O(n) to O(1), where n is the nesting depth.
6.9 KiB
6.9 KiB