diff options
author | Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com> | 2023-05-29 17:15:00 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-29 21:36:17 +0200 |
commit | 787f2d2a10ee475bfb4e53968e06d7324d208d7a (patch) | |
tree | 7d6da1ddf1a7011b21b096653516624ac5aeece2 /Userland/Libraries | |
parent | 3a3a085404a8bbc50eda5b03009361f0893e650a (diff) | |
download | serenity-787f2d2a10ee475bfb4e53968e06d7324d208d7a.zip |
LibWeb: Remove Layout::TableCellBox
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 | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/FormattingContext.cpp | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/TableCellBox.cpp | 38 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/TableCellBox.h | 25 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp | 3 |
7 files changed, 10 insertions, 73 deletions
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 97ae28421e..41ff064808 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -418,7 +418,6 @@ set(SOURCES Layout/SVGGeometryBox.cpp Layout/SVGGraphicsBox.cpp Layout/SVGSVGBox.cpp - Layout/TableCellBox.cpp Layout/TableFormattingContext.cpp Layout/TableWrapper.cpp Layout/TextNode.cpp diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index c14879da4d..8b13baa04c 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -49,7 +49,6 @@ #include <LibWeb/Layout/BlockContainer.h> #include <LibWeb/Layout/InlineNode.h> #include <LibWeb/Layout/ListItemBox.h> -#include <LibWeb/Layout/TableCellBox.h> #include <LibWeb/Layout/TreeBuilder.h> #include <LibWeb/Layout/Viewport.h> #include <LibWeb/Namespace.h> @@ -329,7 +328,7 @@ JS::GCPtr<Layout::Node> Element::create_layout_node_for_display_type(DOM::Docume return document.heap().allocate_without_realm<Layout::ListItemBox>(document, element, move(style)); if (display.is_table_cell()) - return document.heap().allocate_without_realm<Layout::TableCellBox>(document, element, move(style)); + return document.heap().allocate_without_realm<Layout::BlockContainer>(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. diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index 90c6cf171a..2216259ba9 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -13,7 +13,6 @@ #include <LibWeb/Layout/ReplacedBox.h> #include <LibWeb/Layout/SVGFormattingContext.h> #include <LibWeb/Layout/SVGSVGBox.h> -#include <LibWeb/Layout/TableCellBox.h> #include <LibWeb/Layout/TableFormattingContext.h> #include <LibWeb/Layout/Viewport.h> diff --git a/Userland/Libraries/LibWeb/Layout/TableCellBox.cpp b/Userland/Libraries/LibWeb/Layout/TableCellBox.cpp deleted file mode 100644 index 4f29f7be66..0000000000 --- a/Userland/Libraries/LibWeb/Layout/TableCellBox.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include <LibWeb/DOM/Element.h> -#include <LibWeb/Layout/TableCellBox.h> - -namespace Web::Layout { - -TableCellBox::TableCellBox(DOM::Document& document, DOM::Element* element, NonnullRefPtr<CSS::StyleProperties> style) - : Layout::BlockContainer(document, element, move(style)) -{ -} - -TableCellBox::TableCellBox(DOM::Document& document, DOM::Element* element, CSS::ComputedValues computed_values) - : Layout::BlockContainer(document, element, move(computed_values)) -{ -} - -TableCellBox::~TableCellBox() = default; - -size_t TableCellBox::colspan() const -{ - if (!dom_node()) - return 1; - return verify_cast<DOM::Element>(*dom_node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1); -} - -size_t TableCellBox::rowspan() const -{ - if (!dom_node()) - return 1; - return verify_cast<DOM::Element>(*dom_node()).attribute(HTML::AttributeNames::rowspan).to_uint().value_or(1); -} - -} diff --git a/Userland/Libraries/LibWeb/Layout/TableCellBox.h b/Userland/Libraries/LibWeb/Layout/TableCellBox.h deleted file mode 100644 index dc4324aa5f..0000000000 --- a/Userland/Libraries/LibWeb/Layout/TableCellBox.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include <LibWeb/Layout/BlockContainer.h> - -namespace Web::Layout { - -class TableCellBox final : public BlockContainer { - JS_CELL(TableCellBox, BlockContainer); - -public: - TableCellBox(DOM::Document&, DOM::Element*, NonnullRefPtr<CSS::StyleProperties>); - TableCellBox(DOM::Document&, DOM::Element*, CSS::ComputedValues); - virtual ~TableCellBox() override; - - size_t colspan() const; - size_t rowspan() const; -}; - -} diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index 6d857ee081..1a7a82c068 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -6,9 +6,9 @@ #include <LibWeb/DOM/Node.h> #include <LibWeb/HTML/BrowsingContext.h> +#include <LibWeb/HTML/HTMLTableCellElement.h> #include <LibWeb/Layout/Box.h> #include <LibWeb/Layout/InlineFormattingContext.h> -#include <LibWeb/Layout/TableCellBox.h> #include <LibWeb/Layout/TableFormattingContext.h> struct GridPosition { @@ -77,13 +77,17 @@ void TableFormattingContext::calculate_row_column_grid(Box const& box) x_current++; for (auto* child = row.first_child(); child; child = child->next_sibling()) { - if (is<TableCellBox>(*child)) { + if (child->display().is_table_cell()) { Box const* box = static_cast<Box const*>(child); if (x_current == x_width) x_width++; - const size_t colspan = static_cast<TableCellBox const*>(child)->colspan(); - const size_t rowspan = static_cast<TableCellBox const*>(child)->rowspan(); + size_t colspan = 1, rowspan = 1; + if (box->dom_node() && is<HTML::HTMLTableCellElement>(*box->dom_node())) { + auto const& node = static_cast<HTML::HTMLTableCellElement const&>(*box->dom_node()); + colspan = node.col_span(); + rowspan = node.row_span(); + } if (x_width < x_current + colspan) x_width = x_current + colspan; diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index 94383c748c..1844889ffc 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -24,7 +24,6 @@ #include <LibWeb/Layout/ListItemMarkerBox.h> #include <LibWeb/Layout/Node.h> #include <LibWeb/Layout/Progress.h> -#include <LibWeb/Layout/TableCellBox.h> #include <LibWeb/Layout/TableWrapper.h> #include <LibWeb/Layout/TextNode.h> #include <LibWeb/Layout/TreeBuilder.h> @@ -550,7 +549,7 @@ void TreeBuilder::generate_missing_child_wrappers(NodeWithStyle& root) // An anonymous table-cell box must be generated around each sequence of consecutive children of a table-row box which are not table-cell boxes. !Testcase for_each_in_tree_with_internal_display<CSS::Display::Internal::TableRow>(root, [&](auto& parent) { for_each_sequence_of_consecutive_children_matching(parent, is_not_table_cell, [&](auto& sequence, auto nearest_sibling) { - wrap_in_anonymous<TableCellBox>(sequence, nearest_sibling, CSS::Display { CSS::Display::Internal::TableCell }); + wrap_in_anonymous<BlockContainer>(sequence, nearest_sibling, CSS::Display { CSS::Display::Internal::TableCell }); }); }); } |