mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:47:44 +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
|
@ -45,9 +45,23 @@ public:
|
|||
|
||||
virtual void parent_context_did_dimension_child_root_box() { }
|
||||
|
||||
struct MinAndMaxContentSize {
|
||||
float min_content_size { 0 };
|
||||
float max_content_size { 0 };
|
||||
};
|
||||
|
||||
MinAndMaxContentSize calculate_min_and_max_content_width(Layout::Box const&) const;
|
||||
MinAndMaxContentSize calculate_min_and_max_content_height(Layout::Box const&) const;
|
||||
|
||||
float calculate_fit_content_height(Layout::Box const&, Optional<float> available_height) const;
|
||||
float calculate_fit_content_width(Layout::Box const&, Optional<float> available_width) const;
|
||||
|
||||
protected:
|
||||
FormattingContext(Type, FormattingState&, Box const&, FormattingContext* parent = nullptr);
|
||||
|
||||
float calculate_fit_content_size(float min_content_size, float max_content_size, Optional<float> available_space) const;
|
||||
FormattingState::IntrinsicSizes calculate_intrinsic_sizes(Layout::Box const&) const;
|
||||
|
||||
OwnPtr<FormattingContext> layout_inside(Box const&, LayoutMode);
|
||||
void compute_position(Box const&);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue