1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

LibWeb: Split intrinsic heights cache by definite available widths

As it turns out, we sometimes query the intrinsic height of a box before
having fully resolved and/or constrained its containing block. Because
of this, we may enter intrinsic sizing with different amounts of
available width for the same box.

To accommodate this scenario, we now allow caching of multiple intrinsic
heights, separated by the amount of available width provided as input.
This commit is contained in:
Andreas Kling 2022-10-15 13:46:15 +02:00
parent 869b322a8f
commit b289f97a65
2 changed files with 5 additions and 5 deletions

View file

@ -1183,7 +1183,7 @@ float FormattingContext::calculate_min_content_height(Layout::Box const& box, Av
auto& root_state = m_state.m_root;
auto& cache = *root_state.intrinsic_sizes.ensure(&box, [] { return adopt_own(*new LayoutState::IntrinsicSizes); });
if (available_width.is_definite()) {
cache_slot = &cache.min_content_height_with_definite_available_width;
cache_slot = &cache.min_content_height_with_definite_available_width.ensure(available_width.to_px());
} else if (available_width.is_min_content()) {
cache_slot = &cache.min_content_height_with_min_content_available_width;
} else if (available_width.is_max_content()) {
@ -1228,7 +1228,7 @@ float FormattingContext::calculate_max_content_height(Layout::Box const& box, Av
auto& root_state = m_state.m_root;
auto& cache = *root_state.intrinsic_sizes.ensure(&box, [] { return adopt_own(*new LayoutState::IntrinsicSizes); });
if (available_width.is_definite()) {
cache_slot = &cache.max_content_height_with_definite_available_width;
cache_slot = &cache.max_content_height_with_definite_available_width.ensure(available_width.to_px());
} else if (available_width.is_min_content()) {
cache_slot = &cache.max_content_height_with_min_content_available_width;
} else if (available_width.is_max_content()) {