mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
LibWeb: Only perform the requested form of intrinsic size calculation
Before, querying any of the four intrinsic sizes would cause us to calculate all of them (the four being min-content width/height, and max-content width/height). Now, the helper functions only calculate the specific intrinsic size requested. It's then cached at the root formatting context level, so that it's never calculated twice within the same layout pass.
This commit is contained in:
parent
496cf39cf5
commit
4f6fc3d3a6
4 changed files with 105 additions and 92 deletions
|
@ -102,10 +102,13 @@ struct FormattingState {
|
|||
// We cache intrinsic sizes once determined, as they will not change over the course of a full layout.
|
||||
// This avoids computing them several times while performing flex layout.
|
||||
struct IntrinsicSizes {
|
||||
Gfx::FloatSize min_content_size;
|
||||
Gfx::FloatSize max_content_size;
|
||||
Optional<float> min_content_width;
|
||||
Optional<float> max_content_width;
|
||||
Optional<float> min_content_height;
|
||||
Optional<float> max_content_height;
|
||||
};
|
||||
HashMap<NodeWithStyleAndBoxModelMetrics const*, IntrinsicSizes> mutable intrinsic_sizes;
|
||||
|
||||
HashMap<NodeWithStyleAndBoxModelMetrics const*, NonnullOwnPtr<IntrinsicSizes>> mutable intrinsic_sizes;
|
||||
|
||||
HashMap<Box const*, float> mutable flex_item_size_cache;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue