mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:37:35 +00:00
LibWeb: Avoid some unnecessary inside layouts during intrinsic sizing
When calculating intrinsic sizes, we don't need to recurse into *every* box and layout its insides. IIUC, we can skip any unconstrained box with definite sizes in both axes. So this patch does exactly that.
This commit is contained in:
parent
3ede8dbffb
commit
83bb16ede3
2 changed files with 16 additions and 1 deletions
|
@ -146,6 +146,20 @@ OwnPtr<FormattingContext> FormattingContext::create_independent_formatting_conte
|
|||
|
||||
OwnPtr<FormattingContext> FormattingContext::layout_inside(Box const& child_box, LayoutMode layout_mode)
|
||||
{
|
||||
{
|
||||
// OPTIMIZATION: If we're doing intrinsic sizing and `child_box` has definite size in both axes,
|
||||
// we don't need to layout its insides. The size is resolvable without learning
|
||||
// the metrics of whatever's inside the box.
|
||||
auto const& used_values = m_state.get(child_box);
|
||||
if (layout_mode == LayoutMode::IntrinsicSizing
|
||||
&& used_values.width_constraint == SizeConstraint::None
|
||||
&& used_values.height_constraint == SizeConstraint::None
|
||||
&& used_values.has_definite_width()
|
||||
&& used_values.has_definite_height()) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (!child_box.can_have_children())
|
||||
return {};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue