From 72d5394b8cd5fbb15d14149ce42a6bcbb4e67b04 Mon Sep 17 00:00:00 2001 From: Tobias Christiansen Date: Sat, 29 May 2021 23:03:05 +0200 Subject: [PATCH] LibWeb: Flex-items aren't affected by float nor clear There are a few other things to notice, but they don't seem to be implemented yet. --- Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp | 5 +++-- Userland/Libraries/LibWeb/Layout/Node.cpp | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index f7a21b01b49..53fa1151238 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -506,9 +506,10 @@ void BlockFormattingContext::place_block_level_non_replaced_element_in_normal_fl } }; - if (computed_values.clear() == CSS::Clear::Left || computed_values.clear() == CSS::Clear::Both) + // Flex-items don't float and also don't clear. + if ((computed_values.clear() == CSS::Clear::Left || computed_values.clear() == CSS::Clear::Both) && !child_box.is_flex_item()) clear_floating_boxes(m_left_floating_boxes); - if (computed_values.clear() == CSS::Clear::Right || computed_values.clear() == CSS::Clear::Both) + if ((computed_values.clear() == CSS::Clear::Right || computed_values.clear() == CSS::Clear::Both) && !child_box.is_flex_item()) clear_floating_boxes(m_right_floating_boxes); child_box.set_offset(x, y); diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 81be66ef25d..0c15350a1d4 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -169,6 +169,9 @@ bool Node::is_floating() const { if (!has_style()) return false; + // flex-items don't float. + if (is_flex_item()) + return false; return computed_values().float_() != CSS::Float::None; }