diff options
author | Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com> | 2023-05-29 15:54:22 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-29 21:36:17 +0200 |
commit | 578a937f94a3cccc86b5b16b0a855ab4e2f8d74c (patch) | |
tree | 20f8155d5c4a7afb1ec71798e7999181cf8238ff /Userland/Libraries | |
parent | af004ff0ef162a1752db2a1be0b939da4c24f3b1 (diff) | |
download | serenity-578a937f94a3cccc86b5b16b0a855ab4e2f8d74c.zip |
LibWeb: Remove Layout::TableRowGroupBox
Special box types for inner table boxes might conflict with special
types for <button>, <input> or <label>.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Element.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp | 20 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/TableRowGroupBox.cpp | 21 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h | 21 |
5 files changed, 18 insertions, 51 deletions
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index de3ba9a909..0fceac04a6 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -421,7 +421,6 @@ set(SOURCES Layout/TableCellBox.cpp Layout/TableFormattingContext.cpp Layout/TableRowBox.cpp - Layout/TableRowGroupBox.cpp Layout/TableWrapper.cpp Layout/TextNode.cpp Layout/TreeBuilder.cpp diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 5dd627e7f9..f733fe462f 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -51,7 +51,6 @@ #include <LibWeb/Layout/ListItemBox.h> #include <LibWeb/Layout/TableCellBox.h> #include <LibWeb/Layout/TableRowBox.h> -#include <LibWeb/Layout/TableRowGroupBox.h> #include <LibWeb/Layout/TreeBuilder.h> #include <LibWeb/Layout/Viewport.h> #include <LibWeb/Namespace.h> @@ -324,7 +323,7 @@ JS::GCPtr<Layout::Node> Element::create_layout_node(NonnullRefPtr<CSS::StyleProp JS::GCPtr<Layout::Node> Element::create_layout_node_for_display_type(DOM::Document& document, CSS::Display const& display, NonnullRefPtr<CSS::StyleProperties> style, Element* element) { - if (display.is_table_inside()) + if (display.is_table_inside() || display.is_table_row_group() || display.is_table_header_group() || display.is_table_footer_group()) return document.heap().allocate_without_realm<Layout::Box>(document, element, move(style)); if (display.is_list_item()) @@ -336,9 +335,6 @@ JS::GCPtr<Layout::Node> Element::create_layout_node_for_display_type(DOM::Docume if (display.is_table_cell()) return document.heap().allocate_without_realm<Layout::TableCellBox>(document, element, move(style)); - if (display.is_table_row_group() || display.is_table_header_group() || display.is_table_footer_group()) - return document.heap().allocate_without_realm<Layout::TableRowGroupBox>(document, element, move(style)); - if (display.is_table_column() || display.is_table_column_group() || display.is_table_caption()) { // FIXME: This is just an incorrect placeholder until we improve table layout support. return document.heap().allocate_without_realm<Layout::BlockContainer>(document, element, move(style)); diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index 3dbba9e0e1..f029c5dd61 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -11,7 +11,6 @@ #include <LibWeb/Layout/TableCellBox.h> #include <LibWeb/Layout/TableFormattingContext.h> #include <LibWeb/Layout/TableRowBox.h> -#include <LibWeb/Layout/TableRowGroupBox.h> struct GridPosition { size_t x; @@ -42,6 +41,21 @@ TableFormattingContext::TableFormattingContext(LayoutState& state, Box const& ro TableFormattingContext::~TableFormattingContext() = default; +static inline bool is_table_row_group(Box const& box) +{ + auto const& display = box.display(); + return display.is_table_row_group() || display.is_table_header_group() || display.is_table_footer_group(); +} + +template<typename Matcher, typename Callback> +static void for_each_child_box_matching(Box const& parent, Matcher matcher, Callback callback) +{ + parent.for_each_child_of_type<Box>([&](Box const& child_box) { + if (matcher(child_box)) + callback(child_box); + }); +} + void TableFormattingContext::calculate_row_column_grid(Box const& box) { // Implements https://html.spec.whatwg.org/multipage/tables.html#forming-a-table @@ -85,7 +99,7 @@ void TableFormattingContext::calculate_row_column_grid(Box const& box) y_current++; }; - box.template for_each_child_of_type<TableRowGroupBox>([&](auto& row_group_box) { + for_each_child_box_matching(box, is_table_row_group, [&](auto& row_group_box) { row_group_box.template for_each_child_of_type<TableRowBox>([&](auto& row) { process_row(row); return IterationDecision::Continue; @@ -613,7 +627,7 @@ void TableFormattingContext::position_row_boxes(CSSPixels& total_content_height) CSSPixels row_group_top_offset = table_state.border_top + table_state.padding_top; CSSPixels row_group_left_offset = table_state.border_left + table_state.padding_left; - table_box().for_each_child_of_type<TableRowGroupBox>([&](auto& row_group_box) { + for_each_child_box_matching(table_box(), is_table_row_group, [&](auto& row_group_box) { CSSPixels row_group_height = 0.0f; CSSPixels row_group_width = 0.0f; diff --git a/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.cpp b/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.cpp deleted file mode 100644 index 3e2c3f7a7b..0000000000 --- a/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include <LibWeb/DOM/Element.h> -#include <LibWeb/Layout/TableCellBox.h> -#include <LibWeb/Layout/TableRowBox.h> -#include <LibWeb/Layout/TableRowGroupBox.h> - -namespace Web::Layout { - -TableRowGroupBox::TableRowGroupBox(DOM::Document& document, DOM::Element* element, NonnullRefPtr<CSS::StyleProperties> style) - : Layout::Box(document, element, move(style)) -{ -} - -TableRowGroupBox::~TableRowGroupBox() = default; - -} diff --git a/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h b/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h deleted file mode 100644 index f9dafdee3b..0000000000 --- a/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include <LibWeb/Layout/Box.h> - -namespace Web::Layout { - -class TableRowGroupBox final : public Box { - JS_CELL(TableRowGroupBox, Box); - -public: - TableRowGroupBox(DOM::Document&, DOM::Element*, NonnullRefPtr<CSS::StyleProperties>); - virtual ~TableRowGroupBox() override; -}; - -} |