Skip to content

Truly independent web browser

LibWeb: Resolve flex item percentages against aspect-ratio heights

Andreas Klinga131f9c6da6a
diff --git a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
index 56a34286713..c92f44857c8 100644
--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
@@ -166,6 +166,7 @@ fn sizing_directives_match_ignoring_unobserved(
table_cell_intrinsic_block_padding,
table_box_content_block_offset_in_wrapper,
adopt_automatic_content_block_size,
+ content_block_size_after_inside_layout,
flex_self_block_size_resolution_space,
float_avoidance_inline_size,
outer_float_intrusion_before_list_item_children,
@@ -178,6 +179,7 @@ fn sizing_directives_match_ignoring_unobserved(
&& table_cell_intrinsic_block_padding == b.table_cell_intrinsic_block_padding
&& table_box_content_block_offset_in_wrapper == b.table_box_content_block_offset_in_wrapper
&& adopt_automatic_content_block_size == b.adopt_automatic_content_block_size
+ && content_block_size_after_inside_layout == b.content_block_size_after_inside_layout
&& float_avoidance_inline_size == b.float_avoidance_inline_size
&& outer_float_intrusion_before_list_item_children == b.outer_float_intrusion_before_list_item_children
&& treat_block_axis_percentage_insets_as_auto_beyond_root
diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
index d6d0fa06832..c8877de5b55 100644
--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
@@ -48,6 +48,9 @@ struct FlexItem<'pass> {
used_flex_basis_is_definite: bool,
main_size_was_resolved_from_aspect_ratio: bool,
cross_size_was_resolved_from_aspect_ratio: bool,
+ // The cross size transferred through the aspect ratio before the automatic minimum size grew it to fit the
+ // content. The content resolves percentages against it.
+ cross_size_transferred_through_aspect_ratio: Option<CssPixels>,
flex_base_size: CssPixels,
hypothetical_main_size: CssPixels,
hypothetical_cross_size: CssPixels,
@@ -80,6 +83,7 @@ impl FlexItem<'_> {
used_flex_basis_is_definite: false,
main_size_was_resolved_from_aspect_ratio: false,
cross_size_was_resolved_from_aspect_ratio: false,
+ cross_size_transferred_through_aspect_ratio: None,
flex_base_size: CssPixels::default(),
hypothetical_main_size: CssPixels::default(),
hypothetical_cross_size: CssPixels::default(),
@@ -1715,18 +1719,20 @@ impl<'pass> FlexFormattingContext<'pass> {
let main_size = self.flex_items[index].main_size.unwrap();
let transferred_cross_size = self.cross_size_from_main_size_and_aspect_ratio(node, main_size);
// https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum
- let clamp_min = self
- .sizing()
- .automatic_minimum_size_from_aspect_ratio(
- node,
- self.cross_sizing_axis(),
- main_size,
- transferred_cross_size,
- self.available_space_for_items.unwrap().space,
- self.item_containing_block_constraints(),
- None,
- )
- .unwrap_or(clamp_min);
+ let automatic_minimum = self.sizing().automatic_minimum_size_from_aspect_ratio(
+ node,
+ self.cross_sizing_axis(),
+ main_size,
+ transferred_cross_size,
+ self.available_space_for_items.unwrap().space,
+ self.item_containing_block_constraints(),
+ None,
+ );
+ let transferred = css_clamp(transferred_cross_size, clamp_min, clamp_max);
+ self.flex_items[index].cross_size_transferred_through_aspect_ratio = automatic_minimum
+ .filter(|&minimum| minimum > transferred)
+ .map(|_| transferred);
+ let clamp_min = automatic_minimum.unwrap_or(clamp_min);
self.flex_items[index].hypothetical_cross_size = css_clamp(transferred_cross_size, clamp_min, clamp_max);
self.flex_items[index].cross_size_was_resolved_from_aspect_ratio = self.has_definite_main_size(index);
return;
@@ -1912,7 +1918,16 @@ impl<'pass> FlexFormattingContext<'pass> {
// The axis in which the preferred size calculation depends on this aspect ratio is called the
// ratio-dependent axis, and the resulting size is definite if its input sizes are also definite.
if self.flex_items[index].cross_size_was_resolved_from_aspect_ratio {
- self.set_cross_size(index, size);
+ // NB: When the automatic minimum size grew the transferred size to fit the content, the content
+ // is laid out against the transferred size, and the item takes its grown size afterwards.
+ let percentage_basis = if self.cross_axis_is_horizontal() {
+ size
+ } else {
+ self.flex_items[index]
+ .cross_size_transferred_through_aspect_ratio
+ .unwrap_or(size)
+ };
+ self.set_cross_size(index, percentage_basis);
self.set_has_definite_cross_size(index);
}
}
@@ -2429,7 +2444,18 @@ impl<'pass> FlexFormattingContext<'pass> {
used.border_bottom.set(style.border_bottom_width());
}
self.set_main_size(index, self.flex_items[index].main_size.unwrap());
- self.set_cross_size(index, self.flex_items[index].cross_size.unwrap());
+ // NB: An item whose transferred cross size grows to fit its content lays out that content against the
+ // transferred size, and grows to the used cross size in its own layout.
+ let cross_size = if self.flex_items[index].cross_size_was_resolved_from_aspect_ratio
+ && !self.cross_axis_is_horizontal()
+ {
+ self.flex_items[index]
+ .cross_size_transferred_through_aspect_ratio
+ .unwrap_or(self.flex_items[index].cross_size.unwrap())
+ } else {
+ self.flex_items[index].cross_size.unwrap()
+ };
+ self.set_cross_size(index, cross_size);
}
}
@@ -2480,6 +2506,15 @@ impl<'pass> FlexFormattingContext<'pass> {
Some(stretched_table_box_block_size.max(sizes.table_box_border_box_block_size));
}
+ if self.flex_items[index].cross_size_was_resolved_from_aspect_ratio
+ && !self.cross_axis_is_horizontal()
+ && self.flex_items[index]
+ .cross_size_transferred_through_aspect_ratio
+ .is_some()
+ {
+ input.sizing.content_block_size_after_inside_layout = self.flex_items[index].cross_size;
+ }
+
self.flex_items[index].content_baselines =
match formatting_context::layout_inside_child(run, None, None, node, LayoutMode::Normal, input, false) {
ChildLayoutOutcome::Created(result) => result.baselines,
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index 1e17df8314c..c12b76d884e 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -1901,6 +1901,9 @@ fn execute_formatting_context_run(
let used = run.records.used_values(run.box_);
used.set_content_block_size(result.automatic_content_block_size);
}
+ if let Some(block_size) = input.sizing.content_block_size_after_inside_layout {
+ run.records.used_values(run.box_).set_content_block_size(block_size);
+ }
}
ParticipationInParentFormattingContext::Root => {}
}
diff --git a/Libraries/LibWeb/Rust/src/layout/geometry.rs b/Libraries/LibWeb/Rust/src/layout/geometry.rs
index 5f535509ead..b98c64b0f34 100644
--- a/Libraries/LibWeb/Rust/src/layout/geometry.rs
+++ b/Libraries/LibWeb/Rust/src/layout/geometry.rs
@@ -132,6 +132,9 @@ pub(crate) struct RootSizingDirectives {
// wrapper) can be placed in wrapper coordinates.
pub(crate) table_box_content_block_offset_in_wrapper: Option<CssPixels>,
pub(crate) adopt_automatic_content_block_size: bool,
+ // Input-only: a flex item lays out its content against the block size transferred through its aspect ratio, then
+ // takes this block size, which the automatic minimum size grew to fit the content.
+ pub(crate) content_block_size_after_inside_layout: Option<CssPixels>,
pub(crate) flex_self_block_size_resolution_space: Option<AvailableSpace>,
pub(crate) float_avoidance_inline_size: Option<CssPixels>,
pub(crate) outer_float_intrusion_before_list_item_children: inline_formatting_context::SpaceUsedByFloats,
diff --git a/Tests/LibWeb/Text/expected/css/aspect-ratio-min-max-transfer-matrix.txt b/Tests/LibWeb/Text/expected/css/aspect-ratio-min-max-transfer-matrix.txt
index 150f0590dda..122ab6444a0 100644
--- a/Tests/LibWeb/Text/expected/css/aspect-ratio-min-max-transfer-matrix.txt
+++ b/Tests/LibWeb/Text/expected/css/aspect-ratio-min-max-transfer-matrix.txt
@@ -2277,13 +2277,13 @@ flex-row block width=auto height=auto empty border-box-min-height: 120x60 child=
flex-row block width=auto height=auto empty border-box-max-width: 10x10 child=0
flex-row block width=auto height=auto tall min-height: 120x60 child=30
flex-row block width=auto height=auto tall min-height-large: 300x150 child=75
-flex-row block width=auto height=auto tall max-height: 10x30 child=15
-flex-row block width=auto height=auto tall min-width: 150x337.5 child=168.75
-flex-row block width=auto height=auto tall max-width: 10x302.5 child=151.25
+flex-row block width=auto height=auto tall max-height: 10x30 child=2.5
+flex-row block width=auto height=auto tall min-width: 150x337.5 child=37.5
+flex-row block width=auto height=auto tall max-width: 10x302.5 child=2.5
flex-row block width=auto height=auto tall min-width-max-height: 150x30 child=15
flex-row block width=auto height=auto tall max-width-min-height: 40x60 child=30
flex-row block width=auto height=auto tall border-box-min-height: 120x60 child=25
-flex-row block width=auto height=auto tall border-box-max-width: 20x310 child=150
+flex-row block width=auto height=auto tall border-box-max-width: 20x310 child=0
flex-row block width=auto height=100% empty min-height: 120x60 child=30
flex-row block width=auto height=100% empty min-height-large: 300x150 child=75
flex-row block width=auto height=100% empty max-height: 0x0 child=0
@@ -2332,12 +2332,12 @@ flex-row block width=80px height=auto empty border-box-max-width: 40x20 child=5
flex-row block width=80px height=auto tall min-height: 80x60 child=30
flex-row block width=80px height=auto tall min-height-large: 80x150 child=75
flex-row block width=80px height=auto tall max-height: 80x30 child=15
-flex-row block width=80px height=auto tall min-width: 150x337.5 child=168.75
-flex-row block width=80px height=auto tall max-width: 40x310 child=155
+flex-row block width=80px height=auto tall min-width: 150x337.5 child=37.5
+flex-row block width=80px height=auto tall max-width: 40x310 child=10
flex-row block width=80px height=auto tall min-width-max-height: 150x30 child=15
flex-row block width=80px height=auto tall max-width-min-height: 40x60 child=30
flex-row block width=80px height=auto tall border-box-min-height: 80x60 child=25
-flex-row block width=80px height=auto tall border-box-max-width: 40x315 child=152.5
+flex-row block width=80px height=auto tall border-box-max-width: 40x315 child=5
flex-row block width=80px height=100% empty min-height: 80x60 child=30
flex-row block width=80px height=100% empty min-height-large: 80x150 child=75
flex-row block width=80px height=100% empty max-height: 80x30 child=15
@@ -2386,12 +2386,12 @@ flex-row block width=50% height=auto empty border-box-max-width: 40x20 child=5
flex-row block width=50% height=auto tall min-height: 100x60 child=30
flex-row block width=50% height=auto tall min-height-large: 100x150 child=75
flex-row block width=50% height=auto tall max-height: 100x30 child=15
-flex-row block width=50% height=auto tall min-width: 150x337.5 child=168.75
-flex-row block width=50% height=auto tall max-width: 40x310 child=155
+flex-row block width=50% height=auto tall min-width: 150x337.5 child=37.5
+flex-row block width=50% height=auto tall max-width: 40x310 child=10
flex-row block width=50% height=auto tall min-width-max-height: 150x30 child=15
flex-row block width=50% height=auto tall max-width-min-height: 40x60 child=30
flex-row block width=50% height=auto tall border-box-min-height: 100x60 child=25
-flex-row block width=50% height=auto tall border-box-max-width: 40x315 child=152.5
+flex-row block width=50% height=auto tall border-box-max-width: 40x315 child=5
flex-row block width=50% height=100% empty min-height: 100x60 child=30
flex-row block width=50% height=100% empty min-height-large: 100x150 child=75
flex-row block width=50% height=100% empty max-height: 100x30 child=15
@@ -2439,13 +2439,13 @@ flex-row flow-root width=auto height=auto empty border-box-min-height: 120x60 ch
flex-row flow-root width=auto height=auto empty border-box-max-width: 10x10 child=0
flex-row flow-root width=auto height=auto tall min-height: 120x60 child=30
flex-row flow-root width=auto height=auto tall min-height-large: 300x150 child=75
-flex-row flow-root width=auto height=auto tall max-height: 10x30 child=15
-flex-row flow-root width=auto height=auto tall min-width: 150x337.5 child=168.75
-flex-row flow-root width=auto height=auto tall max-width: 10x302.5 child=151.25
+flex-row flow-root width=auto height=auto tall max-height: 10x30 child=2.5
+flex-row flow-root width=auto height=auto tall min-width: 150x337.5 child=37.5
+flex-row flow-root width=auto height=auto tall max-width: 10x302.5 child=2.5
flex-row flow-root width=auto height=auto tall min-width-max-height: 150x30 child=15
flex-row flow-root width=auto height=auto tall max-width-min-height: 40x60 child=30
flex-row flow-root width=auto height=auto tall border-box-min-height: 120x60 child=25
-flex-row flow-root width=auto height=auto tall border-box-max-width: 20x310 child=150
+flex-row flow-root width=auto height=auto tall border-box-max-width: 20x310 child=0
flex-row flow-root width=auto height=100% empty min-height: 120x60 child=30
flex-row flow-root width=auto height=100% empty min-height-large: 300x150 child=75
flex-row flow-root width=auto height=100% empty max-height: 0x0 child=0
@@ -2494,12 +2494,12 @@ flex-row flow-root width=80px height=auto empty border-box-max-width: 40x20 chil
flex-row flow-root width=80px height=auto tall min-height: 80x60 child=30
flex-row flow-root width=80px height=auto tall min-height-large: 80x150 child=75
flex-row flow-root width=80px height=auto tall max-height: 80x30 child=15
-flex-row flow-root width=80px height=auto tall min-width: 150x337.5 child=168.75
-flex-row flow-root width=80px height=auto tall max-width: 40x310 child=155
+flex-row flow-root width=80px height=auto tall min-width: 150x337.5 child=37.5
+flex-row flow-root width=80px height=auto tall max-width: 40x310 child=10
flex-row flow-root width=80px height=auto tall min-width-max-height: 150x30 child=15
flex-row flow-root width=80px height=auto tall max-width-min-height: 40x60 child=30
flex-row flow-root width=80px height=auto tall border-box-min-height: 80x60 child=25
-flex-row flow-root width=80px height=auto tall border-box-max-width: 40x315 child=152.5
+flex-row flow-root width=80px height=auto tall border-box-max-width: 40x315 child=5
flex-row flow-root width=80px height=100% empty min-height: 80x60 child=30
flex-row flow-root width=80px height=100% empty min-height-large: 80x150 child=75
flex-row flow-root width=80px height=100% empty max-height: 80x30 child=15
@@ -2548,12 +2548,12 @@ flex-row flow-root width=50% height=auto empty border-box-max-width: 40x20 child
flex-row flow-root width=50% height=auto tall min-height: 100x60 child=30
flex-row flow-root width=50% height=auto tall min-height-large: 100x150 child=75
flex-row flow-root width=50% height=auto tall max-height: 100x30 child=15
-flex-row flow-root width=50% height=auto tall min-width: 150x337.5 child=168.75
-flex-row flow-root width=50% height=auto tall max-width: 40x310 child=155
+flex-row flow-root width=50% height=auto tall min-width: 150x337.5 child=37.5
+flex-row flow-root width=50% height=auto tall max-width: 40x310 child=10
flex-row flow-root width=50% height=auto tall min-width-max-height: 150x30 child=15
flex-row flow-root width=50% height=auto tall max-width-min-height: 40x60 child=30
flex-row flow-root width=50% height=auto tall border-box-min-height: 100x60 child=25
-flex-row flow-root width=50% height=auto tall border-box-max-width: 40x315 child=152.5
+flex-row flow-root width=50% height=auto tall border-box-max-width: 40x315 child=5
flex-row flow-root width=50% height=100% empty min-height: 100x60 child=30
flex-row flow-root width=50% height=100% empty min-height-large: 100x150 child=75
flex-row flow-root width=50% height=100% empty max-height: 100x30 child=15
@@ -2601,13 +2601,13 @@ flex-row inline-block width=auto height=auto empty border-box-min-height: 120x60
flex-row inline-block width=auto height=auto empty border-box-max-width: 10x10 child=0
flex-row inline-block width=auto height=auto tall min-height: 120x60 child=30
flex-row inline-block width=auto height=auto tall min-height-large: 300x150 child=75
-flex-row inline-block width=auto height=auto tall max-height: 10x30 child=15
-flex-row inline-block width=auto height=auto tall min-width: 150x337.5 child=168.75
-flex-row inline-block width=auto height=auto tall max-width: 10x302.5 child=151.25
+flex-row inline-block width=auto height=auto tall max-height: 10x30 child=2.5
+flex-row inline-block width=auto height=auto tall min-width: 150x337.5 child=37.5
+flex-row inline-block width=auto height=auto tall max-width: 10x302.5 child=2.5
flex-row inline-block width=auto height=auto tall min-width-max-height: 150x30 child=15
flex-row inline-block width=auto height=auto tall max-width-min-height: 40x60 child=30
flex-row inline-block width=auto height=auto tall border-box-min-height: 120x60 child=25
-flex-row inline-block width=auto height=auto tall border-box-max-width: 20x310 child=150
+flex-row inline-block width=auto height=auto tall border-box-max-width: 20x310 child=0
flex-row inline-block width=auto height=100% empty min-height: 120x60 child=30
flex-row inline-block width=auto height=100% empty min-height-large: 300x150 child=75
flex-row inline-block width=auto height=100% empty max-height: 0x0 child=0
@@ -2656,12 +2656,12 @@ flex-row inline-block width=80px height=auto empty border-box-max-width: 40x20 c
flex-row inline-block width=80px height=auto tall min-height: 80x60 child=30
flex-row inline-block width=80px height=auto tall min-height-large: 80x150 child=75
flex-row inline-block width=80px height=auto tall max-height: 80x30 child=15
-flex-row inline-block width=80px height=auto tall min-width: 150x337.5 child=168.75
-flex-row inline-block width=80px height=auto tall max-width: 40x310 child=155
+flex-row inline-block width=80px height=auto tall min-width: 150x337.5 child=37.5
+flex-row inline-block width=80px height=auto tall max-width: 40x310 child=10
flex-row inline-block width=80px height=auto tall min-width-max-height: 150x30 child=15
flex-row inline-block width=80px height=auto tall max-width-min-height: 40x60 child=30
flex-row inline-block width=80px height=auto tall border-box-min-height: 80x60 child=25
-flex-row inline-block width=80px height=auto tall border-box-max-width: 40x315 child=152.5
+flex-row inline-block width=80px height=auto tall border-box-max-width: 40x315 child=5
flex-row inline-block width=80px height=100% empty min-height: 80x60 child=30
flex-row inline-block width=80px height=100% empty min-height-large: 80x150 child=75
flex-row inline-block width=80px height=100% empty max-height: 80x30 child=15
@@ -2710,12 +2710,12 @@ flex-row inline-block width=50% height=auto empty border-box-max-width: 40x20 ch
flex-row inline-block width=50% height=auto tall min-height: 100x60 child=30
flex-row inline-block width=50% height=auto tall min-height-large: 100x150 child=75
flex-row inline-block width=50% height=auto tall max-height: 100x30 child=15
-flex-row inline-block width=50% height=auto tall min-width: 150x337.5 child=168.75
-flex-row inline-block width=50% height=auto tall max-width: 40x310 child=155
+flex-row inline-block width=50% height=auto tall min-width: 150x337.5 child=37.5
+flex-row inline-block width=50% height=auto tall max-width: 40x310 child=10
flex-row inline-block width=50% height=auto tall min-width-max-height: 150x30 child=15
flex-row inline-block width=50% height=auto tall max-width-min-height: 40x60 child=30
flex-row inline-block width=50% height=auto tall border-box-min-height: 100x60 child=25
-flex-row inline-block width=50% height=auto tall border-box-max-width: 40x315 child=152.5
+flex-row inline-block width=50% height=auto tall border-box-max-width: 40x315 child=5
flex-row inline-block width=50% height=100% empty min-height: 100x60 child=30
flex-row inline-block width=50% height=100% empty min-height-large: 100x150 child=75
flex-row inline-block width=50% height=100% empty max-height: 100x30 child=15
@@ -2763,13 +2763,13 @@ flex-row float width=auto height=auto empty border-box-min-height: 120x60 child=
flex-row float width=auto height=auto empty border-box-max-width: 10x10 child=0
flex-row float width=auto height=auto tall min-height: 120x60 child=30
flex-row float width=auto height=auto tall min-height-large: 300x150 child=75
-flex-row float width=auto height=auto tall max-height: 10x30 child=15
-flex-row float width=auto height=auto tall min-width: 150x337.5 child=168.75
-flex-row float width=auto height=auto tall max-width: 10x302.5 child=151.25
+flex-row float width=auto height=auto tall max-height: 10x30 child=2.5
+flex-row float width=auto height=auto tall min-width: 150x337.5 child=37.5
+flex-row float width=auto height=auto tall max-width: 10x302.5 child=2.5
flex-row float width=auto height=auto tall min-width-max-height: 150x30 child=15
flex-row float width=auto height=auto tall max-width-min-height: 40x60 child=30
flex-row float width=auto height=auto tall border-box-min-height: 120x60 child=25
-flex-row float width=auto height=auto tall border-box-max-width: 20x310 child=150
+flex-row float width=auto height=auto tall border-box-max-width: 20x310 child=0
flex-row float width=auto height=100% empty min-height: 120x60 child=30
flex-row float width=auto height=100% empty min-height-large: 300x150 child=75
flex-row float width=auto height=100% empty max-height: 0x0 child=0
@@ -2818,12 +2818,12 @@ flex-row float width=80px height=auto empty border-box-max-width: 40x20 child=5
flex-row float width=80px height=auto tall min-height: 80x60 child=30
flex-row float width=80px height=auto tall min-height-large: 80x150 child=75
flex-row float width=80px height=auto tall max-height: 80x30 child=15
-flex-row float width=80px height=auto tall min-width: 150x337.5 child=168.75
-flex-row float width=80px height=auto tall max-width: 40x310 child=155
+flex-row float width=80px height=auto tall min-width: 150x337.5 child=37.5
+flex-row float width=80px height=auto tall max-width: 40x310 child=10
flex-row float width=80px height=auto tall min-width-max-height: 150x30 child=15
flex-row float width=80px height=auto tall max-width-min-height: 40x60 child=30
flex-row float width=80px height=auto tall border-box-min-height: 80x60 child=25
-flex-row float width=80px height=auto tall border-box-max-width: 40x315 child=152.5
+flex-row float width=80px height=auto tall border-box-max-width: 40x315 child=5
flex-row float width=80px height=100% empty min-height: 80x60 child=30
flex-row float width=80px height=100% empty min-height-large: 80x150 child=75
flex-row float width=80px height=100% empty max-height: 80x30 child=15
@@ -2872,12 +2872,12 @@ flex-row float width=50% height=auto empty border-box-max-width: 40x20 child=5
flex-row float width=50% height=auto tall min-height: 100x60 child=30
flex-row float width=50% height=auto tall min-height-large: 100x150 child=75
flex-row float width=50% height=auto tall max-height: 100x30 child=15
-flex-row float width=50% height=auto tall min-width: 150x337.5 child=168.75
-flex-row float width=50% height=auto tall max-width: 40x310 child=155
+flex-row float width=50% height=auto tall min-width: 150x337.5 child=37.5
+flex-row float width=50% height=auto tall max-width: 40x310 child=10
flex-row float width=50% height=auto tall min-width-max-height: 150x30 child=15
flex-row float width=50% height=auto tall max-width-min-height: 40x60 child=30
flex-row float width=50% height=auto tall border-box-min-height: 100x60 child=25
-flex-row float width=50% height=auto tall border-box-max-width: 40x315 child=152.5
+flex-row float width=50% height=auto tall border-box-max-width: 40x315 child=5
flex-row float width=50% height=100% empty min-height: 100x60 child=30
flex-row float width=50% height=100% empty min-height-large: 100x150 child=75
flex-row float width=50% height=100% empty max-height: 100x30 child=15
@@ -2925,13 +2925,13 @@ flex-row flex width=auto height=auto empty border-box-min-height: 120x60 child=2
flex-row flex width=auto height=auto empty border-box-max-width: 10x10 child=0
flex-row flex width=auto height=auto tall min-height: 120x60 child=30
flex-row flex width=auto height=auto tall min-height-large: 300x150 child=75
-flex-row flex width=auto height=auto tall max-height: 10x30 child=15
-flex-row flex width=auto height=auto tall min-width: 150x300 child=150
-flex-row flex width=auto height=auto tall max-width: 10x300 child=150
+flex-row flex width=auto height=auto tall max-height: 10x30 child=2.5
+flex-row flex width=auto height=auto tall min-width: 150x300 child=37.5
+flex-row flex width=auto height=auto tall max-width: 10x300 child=2.5
flex-row flex width=auto height=auto tall min-width-max-height: 150x30 child=15
flex-row flex width=auto height=auto tall max-width-min-height: 40x60 child=30
flex-row flex width=auto height=auto tall border-box-min-height: 120x60 child=25
-flex-row flex width=auto height=auto tall border-box-max-width: 20x310 child=150
+flex-row flex width=auto height=auto tall border-box-max-width: 20x310 child=0
flex-row flex width=auto height=100% empty min-height: 120x60 child=30
flex-row flex width=auto height=100% empty min-height-large: 300x150 child=75
flex-row flex width=auto height=100% empty max-height: 0x0 child=0
@@ -2980,12 +2980,12 @@ flex-row flex width=80px height=auto empty border-box-max-width: 40x20 child=5
flex-row flex width=80px height=auto tall min-height: 80x60 child=30
flex-row flex width=80px height=auto tall min-height-large: 80x150 child=75
flex-row flex width=80px height=auto tall max-height: 80x30 child=15
-flex-row flex width=80px height=auto tall min-width: 150x300 child=150
-flex-row flex width=80px height=auto tall max-width: 40x300 child=150
+flex-row flex width=80px height=auto tall min-width: 150x300 child=37.5
+flex-row flex width=80px height=auto tall max-width: 40x300 child=10
flex-row flex width=80px height=auto tall min-width-max-height: 150x30 child=15
flex-row flex width=80px height=auto tall max-width-min-height: 40x60 child=30
flex-row flex width=80px height=auto tall border-box-min-height: 80x60 child=25
-flex-row flex width=80px height=auto tall border-box-max-width: 40x310 child=150
+flex-row flex width=80px height=auto tall border-box-max-width: 40x310 child=5
flex-row flex width=80px height=100% empty min-height: 80x60 child=30
flex-row flex width=80px height=100% empty min-height-large: 80x150 child=75
flex-row flex width=80px height=100% empty max-height: 80x30 child=15
@@ -3034,12 +3034,12 @@ flex-row flex width=50% height=auto empty border-box-max-width: 40x20 child=5
flex-row flex width=50% height=auto tall min-height: 100x60 child=30
flex-row flex width=50% height=auto tall min-height-large: 100x150 child=75
flex-row flex width=50% height=auto tall max-height: 100x30 child=15
-flex-row flex width=50% height=auto tall min-width: 150x300 child=150
-flex-row flex width=50% height=auto tall max-width: 40x300 child=150
+flex-row flex width=50% height=auto tall min-width: 150x300 child=37.5
+flex-row flex width=50% height=auto tall max-width: 40x300 child=10
flex-row flex width=50% height=auto tall min-width-max-height: 150x30 child=15
flex-row flex width=50% height=auto tall max-width-min-height: 40x60 child=30
flex-row flex width=50% height=auto tall border-box-min-height: 100x60 child=25
-flex-row flex width=50% height=auto tall border-box-max-width: 40x310 child=150
+flex-row flex width=50% height=auto tall border-box-max-width: 40x310 child=5
flex-row flex width=50% height=100% empty min-height: 100x60 child=30
flex-row flex width=50% height=100% empty min-height-large: 100x150 child=75
flex-row flex width=50% height=100% empty max-height: 100x30 child=15
diff --git a/Tests/LibWeb/Text/expected/css/aspect-ratio-percentage-height-matrix.txt b/Tests/LibWeb/Text/expected/css/aspect-ratio-percentage-height-matrix.txt
index 4cb3c43a477..6b1f4d8222a 100644
--- a/Tests/LibWeb/Text/expected/css/aspect-ratio-percentage-height-matrix.txt
+++ b/Tests/LibWeb/Text/expected/css/aspect-ratio-percentage-height-matrix.txt
@@ -1026,10 +1026,10 @@ flex-row block width=auto height=auto empty none: 0x0 child=0
flex-row block width=auto height=auto empty max-height: 0x0 child=0
flex-row block width=auto height=auto empty min-height: 120x60 child=30
flex-row block width=auto height=auto empty padding: 10x10 child=0
-flex-row block width=auto height=auto tall none: 10x302.5 child=151.25
-flex-row block width=auto height=auto tall max-height: 10x30 child=15
+flex-row block width=auto height=auto tall none: 10x302.5 child=2.5
+flex-row block width=auto height=auto tall max-height: 10x30 child=2.5
flex-row block width=auto height=auto tall min-height: 120x60 child=30
-flex-row block width=auto height=auto tall padding: 20x310 child=150
+flex-row block width=auto height=auto tall padding: 20x310 child=0
flex-row block width=80px height=100% empty none: 80x40 child=20
flex-row block width=80px height=100% empty max-height: 80x30 child=15
flex-row block width=80px height=100% empty min-height: 80x60 child=30
@@ -1050,10 +1050,10 @@ flex-row block width=80px height=auto empty none: 80x40 child=20
flex-row block width=80px height=auto empty max-height: 80x30 child=15
flex-row block width=80px height=auto empty min-height: 80x60 child=30
flex-row block width=80px height=auto empty padding: 80x40 child=15
-flex-row block width=80px height=auto tall none: 80x320 child=160
+flex-row block width=80px height=auto tall none: 80x320 child=20
flex-row block width=80px height=auto tall max-height: 80x30 child=15
flex-row block width=80px height=auto tall min-height: 80x60 child=30
-flex-row block width=80px height=auto tall padding: 80x325 child=157.5
+flex-row block width=80px height=auto tall padding: 80x325 child=15
flex-row block width=50% height=100% empty none: 100x50 child=25
flex-row block width=50% height=100% empty max-height: 100x30 child=15
flex-row block width=50% height=100% empty min-height: 100x60 child=30
@@ -1074,10 +1074,10 @@ flex-row block width=50% height=auto empty none: 100x50 child=25
flex-row block width=50% height=auto empty max-height: 100x30 child=15
flex-row block width=50% height=auto empty min-height: 100x60 child=30
flex-row block width=50% height=auto empty padding: 100x50 child=20
-flex-row block width=50% height=auto tall none: 100x325 child=162.5
+flex-row block width=50% height=auto tall none: 100x325 child=25
flex-row block width=50% height=auto tall max-height: 100x30 child=15
flex-row block width=50% height=auto tall min-height: 100x60 child=30
-flex-row block width=50% height=auto tall padding: 100x330 child=160
+flex-row block width=50% height=auto tall padding: 100x330 child=20
flex-row flow-root width=auto height=100% empty none: 0x0 child=0
flex-row flow-root width=auto height=100% empty max-height: 0x0 child=0
flex-row flow-root width=auto height=100% empty min-height: 120x60 child=30
@@ -1098,10 +1098,10 @@ flex-row flow-root width=auto height=auto empty none: 0x0 child=0
flex-row flow-root width=auto height=auto empty max-height: 0x0 child=0
flex-row flow-root width=auto height=auto empty min-height: 120x60 child=30
flex-row flow-root width=auto height=auto empty padding: 10x10 child=0
-flex-row flow-root width=auto height=auto tall none: 10x302.5 child=151.25
-flex-row flow-root width=auto height=auto tall max-height: 10x30 child=15
+flex-row flow-root width=auto height=auto tall none: 10x302.5 child=2.5
+flex-row flow-root width=auto height=auto tall max-height: 10x30 child=2.5
flex-row flow-root width=auto height=auto tall min-height: 120x60 child=30
-flex-row flow-root width=auto height=auto tall padding: 20x310 child=150
+flex-row flow-root width=auto height=auto tall padding: 20x310 child=0
flex-row flow-root width=80px height=100% empty none: 80x40 child=20
flex-row flow-root width=80px height=100% empty max-height: 80x30 child=15
flex-row flow-root width=80px height=100% empty min-height: 80x60 child=30
@@ -1122,10 +1122,10 @@ flex-row flow-root width=80px height=auto empty none: 80x40 child=20
flex-row flow-root width=80px height=auto empty max-height: 80x30 child=15
flex-row flow-root width=80px height=auto empty min-height: 80x60 child=30
flex-row flow-root width=80px height=auto empty padding: 80x40 child=15
-flex-row flow-root width=80px height=auto tall none: 80x320 child=160
+flex-row flow-root width=80px height=auto tall none: 80x320 child=20
flex-row flow-root width=80px height=auto tall max-height: 80x30 child=15
flex-row flow-root width=80px height=auto tall min-height: 80x60 child=30
-flex-row flow-root width=80px height=auto tall padding: 80x325 child=157.5
+flex-row flow-root width=80px height=auto tall padding: 80x325 child=15
flex-row flow-root width=50% height=100% empty none: 100x50 child=25
flex-row flow-root width=50% height=100% empty max-height: 100x30 child=15
flex-row flow-root width=50% height=100% empty min-height: 100x60 child=30
@@ -1146,10 +1146,10 @@ flex-row flow-root width=50% height=auto empty none: 100x50 child=25
flex-row flow-root width=50% height=auto empty max-height: 100x30 child=15
flex-row flow-root width=50% height=auto empty min-height: 100x60 child=30
flex-row flow-root width=50% height=auto empty padding: 100x50 child=20
-flex-row flow-root width=50% height=auto tall none: 100x325 child=162.5
+flex-row flow-root width=50% height=auto tall none: 100x325 child=25
flex-row flow-root width=50% height=auto tall max-height: 100x30 child=15
flex-row flow-root width=50% height=auto tall min-height: 100x60 child=30
-flex-row flow-root width=50% height=auto tall padding: 100x330 child=160
+flex-row flow-root width=50% height=auto tall padding: 100x330 child=20
flex-row inline-block width=auto height=100% empty none: 0x0 child=0
flex-row inline-block width=auto height=100% empty max-height: 0x0 child=0
flex-row inline-block width=auto height=100% empty min-height: 120x60 child=30
@@ -1170,10 +1170,10 @@ flex-row inline-block width=auto height=auto empty none: 0x0 child=0
flex-row inline-block width=auto height=auto empty max-height: 0x0 child=0
flex-row inline-block width=auto height=auto empty min-height: 120x60 child=30
flex-row inline-block width=auto height=auto empty padding: 10x10 child=0
-flex-row inline-block width=auto height=auto tall none: 10x302.5 child=151.25
-flex-row inline-block width=auto height=auto tall max-height: 10x30 child=15
+flex-row inline-block width=auto height=auto tall none: 10x302.5 child=2.5
+flex-row inline-block width=auto height=auto tall max-height: 10x30 child=2.5
flex-row inline-block width=auto height=auto tall min-height: 120x60 child=30
-flex-row inline-block width=auto height=auto tall padding: 20x310 child=150
+flex-row inline-block width=auto height=auto tall padding: 20x310 child=0
flex-row inline-block width=80px height=100% empty none: 80x40 child=20
flex-row inline-block width=80px height=100% empty max-height: 80x30 child=15
flex-row inline-block width=80px height=100% empty min-height: 80x60 child=30
@@ -1194,10 +1194,10 @@ flex-row inline-block width=80px height=auto empty none: 80x40 child=20
flex-row inline-block width=80px height=auto empty max-height: 80x30 child=15
flex-row inline-block width=80px height=auto empty min-height: 80x60 child=30
flex-row inline-block width=80px height=auto empty padding: 80x40 child=15
-flex-row inline-block width=80px height=auto tall none: 80x320 child=160
+flex-row inline-block width=80px height=auto tall none: 80x320 child=20
flex-row inline-block width=80px height=auto tall max-height: 80x30 child=15
flex-row inline-block width=80px height=auto tall min-height: 80x60 child=30
-flex-row inline-block width=80px height=auto tall padding: 80x325 child=157.5
+flex-row inline-block width=80px height=auto tall padding: 80x325 child=15
flex-row inline-block width=50% height=100% empty none: 100x50 child=25
flex-row inline-block width=50% height=100% empty max-height: 100x30 child=15
flex-row inline-block width=50% height=100% empty min-height: 100x60 child=30
@@ -1218,10 +1218,10 @@ flex-row inline-block width=50% height=auto empty none: 100x50 child=25
flex-row inline-block width=50% height=auto empty max-height: 100x30 child=15
flex-row inline-block width=50% height=auto empty min-height: 100x60 child=30
flex-row inline-block width=50% height=auto empty padding: 100x50 child=20
-flex-row inline-block width=50% height=auto tall none: 100x325 child=162.5
+flex-row inline-block width=50% height=auto tall none: 100x325 child=25
flex-row inline-block width=50% height=auto tall max-height: 100x30 child=15
flex-row inline-block width=50% height=auto tall min-height: 100x60 child=30
-flex-row inline-block width=50% height=auto tall padding: 100x330 child=160
+flex-row inline-block width=50% height=auto tall padding: 100x330 child=20
flex-row float width=auto height=100% empty none: 0x0 child=0
flex-row float width=auto height=100% empty max-height: 0x0 child=0
flex-row float width=auto height=100% empty min-height: 120x60 child=30
@@ -1242,10 +1242,10 @@ flex-row float width=auto height=auto empty none: 0x0 child=0
flex-row float width=auto height=auto empty max-height: 0x0 child=0
flex-row float width=auto height=auto empty min-height: 120x60 child=30
flex-row float width=auto height=auto empty padding: 10x10 child=0
-flex-row float width=auto height=auto tall none: 10x302.5 child=151.25
-flex-row float width=auto height=auto tall max-height: 10x30 child=15
+flex-row float width=auto height=auto tall none: 10x302.5 child=2.5
+flex-row float width=auto height=auto tall max-height: 10x30 child=2.5
flex-row float width=auto height=auto tall min-height: 120x60 child=30
-flex-row float width=auto height=auto tall padding: 20x310 child=150
+flex-row float width=auto height=auto tall padding: 20x310 child=0
flex-row float width=80px height=100% empty none: 80x40 child=20
flex-row float width=80px height=100% empty max-height: 80x30 child=15
flex-row float width=80px height=100% empty min-height: 80x60 child=30
@@ -1266,10 +1266,10 @@ flex-row float width=80px height=auto empty none: 80x40 child=20
flex-row float width=80px height=auto empty max-height: 80x30 child=15
flex-row float width=80px height=auto empty min-height: 80x60 child=30
flex-row float width=80px height=auto empty padding: 80x40 child=15
-flex-row float width=80px height=auto tall none: 80x320 child=160
+flex-row float width=80px height=auto tall none: 80x320 child=20
flex-row float width=80px height=auto tall max-height: 80x30 child=15
flex-row float width=80px height=auto tall min-height: 80x60 child=30
-flex-row float width=80px height=auto tall padding: 80x325 child=157.5
+flex-row float width=80px height=auto tall padding: 80x325 child=15
flex-row float width=50% height=100% empty none: 100x50 child=25
flex-row float width=50% height=100% empty max-height: 100x30 child=15
flex-row float width=50% height=100% empty min-height: 100x60 child=30
@@ -1290,10 +1290,10 @@ flex-row float width=50% height=auto empty none: 100x50 child=25
flex-row float width=50% height=auto empty max-height: 100x30 child=15
flex-row float width=50% height=auto empty min-height: 100x60 child=30
flex-row float width=50% height=auto empty padding: 100x50 child=20
-flex-row float width=50% height=auto tall none: 100x325 child=162.5
+flex-row float width=50% height=auto tall none: 100x325 child=25
flex-row float width=50% height=auto tall max-height: 100x30 child=15
flex-row float width=50% height=auto tall min-height: 100x60 child=30
-flex-row float width=50% height=auto tall padding: 100x330 child=160
+flex-row float width=50% height=auto tall padding: 100x330 child=20
flex-row flex width=auto height=100% empty none: 0x0 child=0
flex-row flex width=auto height=100% empty max-height: 0x0 child=0
flex-row flex width=auto height=100% empty min-height: 120x60 child=30
@@ -1314,10 +1314,10 @@ flex-row flex width=auto height=auto empty none: 0x0 child=0
flex-row flex width=auto height=auto empty max-height: 0x0 child=0
flex-row flex width=auto height=auto empty min-height: 120x60 child=30
flex-row flex width=auto height=auto empty padding: 10x10 child=0
-flex-row flex width=auto height=auto tall none: 10x300 child=150
-flex-row flex width=auto height=auto tall max-height: 10x30 child=15
+flex-row flex width=auto height=auto tall none: 10x300 child=2.5
+flex-row flex width=auto height=auto tall max-height: 10x30 child=2.5
flex-row flex width=auto height=auto tall min-height: 120x60 child=30
-flex-row flex width=auto height=auto tall padding: 20x310 child=150
+flex-row flex width=auto height=auto tall padding: 20x310 child=0
flex-row flex width=80px height=100% empty none: 80x40 child=20
flex-row flex width=80px height=100% empty max-height: 80x30 child=15
flex-row flex width=80px height=100% empty min-height: 80x60 child=30
@@ -1338,10 +1338,10 @@ flex-row flex width=80px height=auto empty none: 80x40 child=20
flex-row flex width=80px height=auto empty max-height: 80x30 child=15
flex-row flex width=80px height=auto empty min-height: 80x60 child=30
flex-row flex width=80px height=auto empty padding: 80x40 child=15
-flex-row flex width=80px height=auto tall none: 80x300 child=150
+flex-row flex width=80px height=auto tall none: 80x300 child=20
flex-row flex width=80px height=auto tall max-height: 80x30 child=15
flex-row flex width=80px height=auto tall min-height: 80x60 child=30
-flex-row flex width=80px height=auto tall padding: 80x310 child=150
+flex-row flex width=80px height=auto tall padding: 80x310 child=15
flex-row flex width=50% height=100% empty none: 100x50 child=25
flex-row flex width=50% height=100% empty max-height: 100x30 child=15
flex-row flex width=50% height=100% empty min-height: 100x60 child=30
@@ -1362,10 +1362,10 @@ flex-row flex width=50% height=auto empty none: 100x50 child=25
flex-row flex width=50% height=auto empty max-height: 100x30 child=15
flex-row flex width=50% height=auto empty min-height: 100x60 child=30
flex-row flex width=50% height=auto empty padding: 100x50 child=20
-flex-row flex width=50% height=auto tall none: 100x300 child=150
+flex-row flex width=50% height=auto tall none: 100x300 child=25
flex-row flex width=50% height=auto tall max-height: 100x30 child=15
flex-row flex width=50% height=auto tall min-height: 100x60 child=30
-flex-row flex width=50% height=auto tall padding: 100x310 child=150
+flex-row flex width=50% height=auto tall padding: 100x310 child=20
flex-row grid width=auto height=100% empty none: 0x0 child=0
flex-row grid width=auto height=100% empty max-height: 0x0 child=0
flex-row grid width=auto height=100% empty min-height: 120x60 child=30