1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:17:34 +00:00

LibWeb: Split intrinsic heights cache based on available width

Now that intrinsic heights (correctly) depend on the amount of available
width, we can't just cache the first calculated min-content and
max-content heights and reuse it without thinking.

Instead, we have to cache three pairs:

- min-content & max-content height with definite available width
- min-content & max-content height with min-content available width
- min-content & max-content height with max-content available width

There might be some more elegant way of solving this, but basically this
makes the cache work correctly when someone's containing block is being
sized under a width constraint.
This commit is contained in:
Andreas Kling 2022-10-08 20:27:54 +02:00
parent 4b74f36cd0
commit b945d164e2
2 changed files with 54 additions and 19 deletions

View file

@ -155,8 +155,15 @@ struct LayoutState {
struct IntrinsicSizes {
Optional<float> min_content_width;
Optional<float> max_content_width;
Optional<float> min_content_height;
Optional<float> max_content_height;
// NOTE: Since intrinsic heights depend on the amount of available width, we have to cache
// three separate results, depending on the available width at the time of calculation.
Optional<float> min_content_height_with_definite_available_width;
Optional<float> max_content_height_with_definite_available_width;
Optional<float> min_content_height_with_min_content_available_width;
Optional<float> max_content_height_with_min_content_available_width;
Optional<float> min_content_height_with_max_content_available_width;
Optional<float> max_content_height_with_max_content_available_width;
};
HashMap<NodeWithStyleAndBoxModelMetrics const*, NonnullOwnPtr<IntrinsicSizes>> mutable intrinsic_sizes;