From bd94f2c4c8178207e5c6648035f45dd6e0f3e1d0 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 13 Mar 2022 00:03:59 +0100 Subject: [PATCH] LibWeb: Add a debug helper to dump current state of an FFC --- .../LibWeb/Layout/FlexFormattingContext.cpp | 12 ++++++++++++ .../Libraries/LibWeb/Layout/FlexFormattingContext.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index 41a00072f0..bf950bc7a1 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -980,6 +980,18 @@ void FlexFormattingContext::distribute_any_remaining_free_space() } } +void FlexFormattingContext::dump_items() const +{ + dbgln("\033[34;1mflex-container\033[0m {}, direction: {}, current-size: {}x{}", flex_container().debug_description(), is_row_layout() ? "row" : "column", m_flex_container_state.content_width, m_flex_container_state.content_height); + for (size_t i = 0; i < m_flex_lines.size(); ++i) { + dbgln("{} flex-line #{}:", flex_container().debug_description(), i); + for (size_t j = 0; j < m_flex_lines[i].items.size(); ++j) { + auto& item = *m_flex_lines[i].items[j]; + dbgln("{} flex-item #{}: {} (main:{}, cross:{})", flex_container().debug_description(), j, item.box.debug_description(), item.main_size, item.cross_size); + } + } +} + void FlexFormattingContext::align_all_flex_items_along_the_cross_axis() { // FIXME: Get the alignment via "align-self" of the item (which accesses "align-items" of the parent if unset) diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h index 86abb9fe56..2fa5b47946 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.h @@ -23,6 +23,8 @@ public: Box const& flex_container() const { return context_box(); } private: + void dump_items() const; + struct DirectionAgnosticMargins { float main_before { 0 }; float main_after { 0 };