From 1e526af430a5028302688996348f6aff2e4e93d5 Mon Sep 17 00:00:00 2001 From: Andi Gallo Date: Fri, 26 May 2023 13:47:40 +0000 Subject: LibWeb: Fix width calculation for floating replaced elements The path for floating, replaced elements must not fall through to the path taken for floating, non-replaced elements. The former works like inline replaced elements, while the latter uses a completely different algorithm which doesn't account for intrinsic ratio. Falling through overrides the correct value computed by the former. Fixes #19061. --- Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Userland/Libraries/LibWeb/Layout') diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index 51941ab76c..cf50bf9d3f 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -137,10 +137,16 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const& // FIXME: This const_cast is gross. const_cast(replaced).prepare_for_replaced_layout(); compute_width_for_block_level_replaced_element_in_normal_flow(replaced, remaining_available_space); - // NOTE: We don't return here. + if (box.is_floating()) { + // 10.3.6 Floating, replaced elements: + // https://www.w3.org/TR/CSS22/visudet.html#float-replaced-width + return; + } } if (box.is_floating()) { + // 10.3.5 Floating, non-replaced elements: + // https://www.w3.org/TR/CSS22/visudet.html#float-width compute_width_for_floating_box(box, available_space); return; } -- cgit v1.2.3