diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index 1a2abdaa4d..6c00fa4a9c 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -135,11 +135,11 @@ RefPtr Element::create_layout_node() if (display == CSS::Display::ListItem) return adopt(*new Layout::ListItemBox(document(), *this, move(style))); if (display == CSS::Display::Table) - return adopt(*new Layout::TableBox(document(), *this, move(style))); + return adopt(*new Layout::TableBox(document(), this, move(style))); if (display == CSS::Display::TableRow) - return adopt(*new Layout::TableRowBox(document(), *this, move(style))); + return adopt(*new Layout::TableRowBox(document(), this, move(style))); if (display == CSS::Display::TableCell) - return adopt(*new Layout::TableCellBox(document(), *this, move(style))); + return adopt(*new Layout::TableCellBox(document(), this, move(style))); if (display == CSS::Display::TableRowGroup || display == CSS::Display::TableHeaderGroup || display == CSS::Display::TableFooterGroup) return adopt(*new Layout::TableRowGroupBox(document(), *this, move(style))); if (display == CSS::Display::InlineBlock) { diff --git a/Libraries/LibWeb/Layout/TableBox.cpp b/Libraries/LibWeb/Layout/TableBox.cpp index 139a2d7011..66fdfb8bd3 100644 --- a/Libraries/LibWeb/Layout/TableBox.cpp +++ b/Libraries/LibWeb/Layout/TableBox.cpp @@ -29,8 +29,13 @@ namespace Web::Layout { -TableBox::TableBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr style) - : Layout::BlockBox(document, &element, move(style)) +TableBox::TableBox(DOM::Document& document, DOM::Element* element, NonnullRefPtr style) + : Layout::BlockBox(document, element, move(style)) +{ +} + +TableBox::TableBox(DOM::Document& document, DOM::Element* element, CSS::ComputedValues computed_values) + : Layout::BlockBox(document, element, move(computed_values)) { } diff --git a/Libraries/LibWeb/Layout/TableBox.h b/Libraries/LibWeb/Layout/TableBox.h index 0c34c6a61c..b98a5664ec 100644 --- a/Libraries/LibWeb/Layout/TableBox.h +++ b/Libraries/LibWeb/Layout/TableBox.h @@ -32,7 +32,8 @@ namespace Web::Layout { class TableBox final : public Layout::BlockBox { public: - TableBox(DOM::Document&, DOM::Element&, NonnullRefPtr); + TableBox(DOM::Document&, DOM::Element*, NonnullRefPtr); + TableBox(DOM::Document&, DOM::Element*, CSS::ComputedValues); virtual ~TableBox() override; }; diff --git a/Libraries/LibWeb/Layout/TableCellBox.cpp b/Libraries/LibWeb/Layout/TableCellBox.cpp index b5edb41121..197fe59b87 100644 --- a/Libraries/LibWeb/Layout/TableCellBox.cpp +++ b/Libraries/LibWeb/Layout/TableCellBox.cpp @@ -30,8 +30,13 @@ namespace Web::Layout { -TableCellBox::TableCellBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr style) - : Layout::BlockBox(document, &element, move(style)) +TableCellBox::TableCellBox(DOM::Document& document, DOM::Element* element, NonnullRefPtr style) + : Layout::BlockBox(document, element, move(style)) +{ +} + +TableCellBox::TableCellBox(DOM::Document& document, DOM::Element* element, CSS::ComputedValues computed_values) + : Layout::BlockBox(document, element, move(computed_values)) { } @@ -41,7 +46,8 @@ TableCellBox::~TableCellBox() size_t TableCellBox::colspan() const { - ASSERT(dom_node()); + if (!dom_node()) + return 0; return downcast(*dom_node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1); } diff --git a/Libraries/LibWeb/Layout/TableCellBox.h b/Libraries/LibWeb/Layout/TableCellBox.h index b1a8bb0160..aaff38a521 100644 --- a/Libraries/LibWeb/Layout/TableCellBox.h +++ b/Libraries/LibWeb/Layout/TableCellBox.h @@ -32,7 +32,8 @@ namespace Web::Layout { class TableCellBox final : public BlockBox { public: - TableCellBox(DOM::Document&, DOM::Element&, NonnullRefPtr); + TableCellBox(DOM::Document&, DOM::Element*, NonnullRefPtr); + TableCellBox(DOM::Document&, DOM::Element*, CSS::ComputedValues); virtual ~TableCellBox() override; TableCellBox* next_cell() { return next_sibling_of_type(); } diff --git a/Libraries/LibWeb/Layout/TableRowBox.cpp b/Libraries/LibWeb/Layout/TableRowBox.cpp index 0bed4d507b..b3033adb1c 100644 --- a/Libraries/LibWeb/Layout/TableRowBox.cpp +++ b/Libraries/LibWeb/Layout/TableRowBox.cpp @@ -29,8 +29,13 @@ namespace Web::Layout { -TableRowBox::TableRowBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr style) - : Box(document, &element, move(style)) +TableRowBox::TableRowBox(DOM::Document& document, DOM::Element* element, NonnullRefPtr style) + : Box(document, element, move(style)) +{ +} + +TableRowBox::TableRowBox(DOM::Document& document, DOM::Element* element, CSS::ComputedValues computed_values) + : Box(document, element, move(computed_values)) { } diff --git a/Libraries/LibWeb/Layout/TableRowBox.h b/Libraries/LibWeb/Layout/TableRowBox.h index 0a63f44efc..34fb035097 100644 --- a/Libraries/LibWeb/Layout/TableRowBox.h +++ b/Libraries/LibWeb/Layout/TableRowBox.h @@ -32,7 +32,8 @@ namespace Web::Layout { class TableRowBox final : public Box { public: - TableRowBox(DOM::Document&, DOM::Element&, NonnullRefPtr); + TableRowBox(DOM::Document&, DOM::Element*, NonnullRefPtr); + TableRowBox(DOM::Document&, DOM::Element*, CSS::ComputedValues); virtual ~TableRowBox() override; };