) [28,8 100x20]
diff --git a/Tests/LibWeb/Layout/input/flex/no-stretch-fit-width-for-item-that-can-resolve-aspect-ratio-through-height.html b/Tests/LibWeb/Layout/input/flex/no-stretch-fit-width-for-item-that-can-resolve-aspect-ratio-through-height.html
new file mode 100644
index 00000000000..3d76c48e045
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/flex/no-stretch-fit-width-for-item-that-can-resolve-aspect-ratio-through-height.html
@@ -0,0 +1,19 @@
+
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
index b9d92a0987e..aab22b56682 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
@@ -639,10 +639,10 @@ void FlexFormattingContext::determine_flex_base_size_and_hypothetical_main_size(
// AD-HOC: This is not mentioned in the spec, but if the item has an aspect ratio,
// we may need to adjust the main size in these ways:
- // - using stretch-fit main size if the flex basis is indefinite.
+ // - using stretch-fit main size if the flex basis is indefinite and there is no cross size to resolve the ratio against.
// - in response to cross size min/max constraints.
- if (item.box->has_preferred_aspect_ratio()) {
- if (!item.used_flex_basis_is_definite) {
+ if (item.box->has_natural_aspect_ratio()) {
+ if (!item.used_flex_basis_is_definite && !has_definite_cross_size(item)) {
item.flex_base_size = inner_main_size(m_flex_container_state);
}
item.flex_base_size = adjust_main_size_through_aspect_ratio_for_cross_size_min_max_constraints(child_box, item.flex_base_size, computed_cross_min_size(child_box), computed_cross_max_size(child_box));