diff --git a/components/layout/flow/mod.rs b/components/layout/flow/mod.rs index 81343d81111..92cabc4b904 100644 --- a/components/layout/flow/mod.rs +++ b/components/layout/flow/mod.rs @@ -2023,8 +2023,10 @@ fn solve_inline_margins_avoiding_floats( placement_rect: LogicalRect, justify_self: AlignFlags, ) -> ((Au, Au), Au) { - let free_space = placement_rect.size.inline - inline_size; - debug_assert!(free_space >= Au::zero()); + // PlacementAmongFloats should guarantee that the inline size of the placement rect + // is at least as big as `inline_size`. However, that may fail when dealing with + // huge sizes that need to be saturated to MAX_AU, so floor by zero. See #37312. + let free_space = Au::zero().max(placement_rect.size.inline - inline_size); let cb_info = &sequential_layout_state.floats.containing_block_info; let start_adjustment = placement_rect.start_corner.inline - cb_info.inline_start; let end_adjustment = cb_info.inline_end - placement_rect.max_inline_position(); diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index 76574878148..0f678875523 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -480,6 +480,13 @@ null, {} ] + ], + "huge-width-after-float.html": [ + "8e4d04399ff1ed4ca934c9a6c79711fcfb881f69", + [ + null, + {} + ] ] }, "floats-saturated-position-crash.html": [ diff --git a/tests/wpt/tests/css/CSS2/floats/crashtests/huge-width-after-float.html b/tests/wpt/tests/css/CSS2/floats/crashtests/huge-width-after-float.html new file mode 100644 index 00000000000..8e4d04399ff --- /dev/null +++ b/tests/wpt/tests/css/CSS2/floats/crashtests/huge-width-after-float.html @@ -0,0 +1,6 @@ + + + + +
+