mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:07:45 +00:00
LibWeb: Add functions for calculating intrinsic sizes of a Layout::Box
FormattingContext can now calculate the intrinsic sizes (min-content and max-content in both axes) for a given Layout::Box. This is a rather expensive operation, as it necessitates performing two throwaway layouts of the subtree rooted at the box. Fortunately, we can cache the results of these calculations, as intrinsic sizes don't change based on other context around the box. They are intrinsic after all. :^)
This commit is contained in:
parent
aa969cc591
commit
3f2b17f602
3 changed files with 100 additions and 0 deletions
|
@ -90,6 +90,14 @@ struct FormattingState {
|
|||
NodeState const& get(NodeWithStyleAndBoxModelMetrics const&) const;
|
||||
|
||||
HashMap<NodeWithStyleAndBoxModelMetrics const*, NonnullRefPtr<NodeState>> nodes;
|
||||
|
||||
// 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;
|
||||
};
|
||||
HashMap<NodeWithStyleAndBoxModelMetrics const*, IntrinsicSizes> mutable intrinsic_sizes;
|
||||
};
|
||||
|
||||
Gfx::FloatRect absolute_content_rect(Box const&, FormattingState const&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue