From c8337e9ee8b1a217d75d92fa8c0605bc2f8f045f Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Mon, 9 Jan 2023 07:17:28 +0300 Subject: [PATCH] LibWeb: Remove inheritance of `TableRowGroupBox` from `BlockContainer` Having `TableRowGroupBox` not inherited from `BlockContainer` allows to write more simpler layout code. --- .../Libraries/LibWeb/Layout/TableFormattingContext.cpp | 9 +++------ Userland/Libraries/LibWeb/Layout/TableRowGroupBox.cpp | 2 +- Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h | 6 +++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index bf6b7ad044..0e394c8d02 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -457,19 +457,16 @@ void TableFormattingContext::run(Box const& box, LayoutMode, AvailableSpace cons auto& row_group_box_state = m_state.get_mutable(row_group_box); row_group_box_state.set_content_y(row_group_top_offset); - CSSPixels row_top_offset = 0.0f; row_group_box.template for_each_child_of_type([&](auto& row) { - auto& row_state = m_state.get_mutable(row); - row_state.set_content_y(row_top_offset); + auto const& row_state = m_state.get(row); row_group_height += row_state.border_box_height(); row_group_width = max(row_group_width, row_state.border_box_width()); - row_top_offset += row_state.border_box_height(); }); - row_group_top_offset += row_top_offset; - row_group_box_state.set_content_height(row_group_height); row_group_box_state.set_content_width(row_group_width); + + row_group_top_offset += row_group_height; }); for (auto& cell : m_cells) { diff --git a/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.cpp b/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.cpp index 8f1d2018c3..3e2c3f7a7b 100644 --- a/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { TableRowGroupBox::TableRowGroupBox(DOM::Document& document, DOM::Element* element, NonnullRefPtr style) - : Layout::BlockContainer(document, element, move(style)) + : Layout::Box(document, element, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h b/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h index 46442606da..f9dafdee3b 100644 --- a/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h +++ b/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h @@ -6,12 +6,12 @@ #pragma once -#include +#include namespace Web::Layout { -class TableRowGroupBox final : public BlockContainer { - JS_CELL(TableRowGroupBox, BlockContainer); +class TableRowGroupBox final : public Box { + JS_CELL(TableRowGroupBox, Box); public: TableRowGroupBox(DOM::Document&, DOM::Element*, NonnullRefPtr);