mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:17:44 +00:00
LibWeb: Remove Layout::TableCellBox
Special box types for inner table boxes might conflict with special types for <button>, <input> or <label>.
This commit is contained in:
parent
3a3a085404
commit
787f2d2a10
28 changed files with 75 additions and 138 deletions
|
@ -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>
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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 });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue