1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

LibWeb: Make intrinsic heights dependent on available width

After speaking with fantasai at CSSWG about this, it turns out I had
misunderstood intrinsic heights. I originally believed all intrinsic
sizes had to be computed with no influence from the surrounding context.

As it turns out, intrinsic heights *are* influenced by the available
width, since it's needed to determine where lines break.

The APIs for calculating min-content and max-content heights now take
the available width as inputs. This instantly improves layout in many
cases where we'd previously make things way too wide.
This commit is contained in:
Andreas Kling 2022-10-03 23:37:38 +02:00
parent b4f9db84ca
commit b13a8706e1
5 changed files with 48 additions and 57 deletions

View file

@ -54,11 +54,11 @@ public:
float calculate_min_content_width(Layout::Box const&) const;
float calculate_max_content_width(Layout::Box const&) const;
float calculate_min_content_height(Layout::Box const&) const;
float calculate_max_content_height(Layout::Box const&) const;
float calculate_min_content_height(Layout::Box const&, AvailableSize const& available_width) const;
float calculate_max_content_height(Layout::Box const&, AvailableSize const& available_width) const;
float calculate_fit_content_height(Layout::Box const&, AvailableSize const&) const;
float calculate_fit_content_width(Layout::Box const&, AvailableSize const&) const;
float calculate_fit_content_height(Layout::Box const&, AvailableSpace const&) const;
float calculate_fit_content_width(Layout::Box const&, AvailableSpace const&) const;
virtual float greatest_child_width(Box const&);
@ -99,7 +99,7 @@ protected:
static float tentative_width_for_replaced_element(LayoutState const&, ReplacedBox const&, CSS::Size const& computed_width, AvailableSpace const&);
static float tentative_height_for_replaced_element(LayoutState const&, ReplacedBox const&, CSS::Size const& computed_height, AvailableSpace const&);
float compute_auto_height_for_block_formatting_context_root(BlockContainer const&) const;
float compute_auto_height_for_block_level_element(Box const&) const;
float compute_auto_height_for_block_level_element(Box const&, AvailableSpace const&) const;
ShrinkToFitResult calculate_shrink_to_fit_widths(Box const&);