From 7bb721bea2a6deaa7832b7533fc7a07f04e8c160 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 23 Feb 2022 20:25:35 +0000 Subject: [PATCH] LibWeb: Make `display: foo` box constructors take the Element by pointer This means we can instantiate them for pseudo-elements, which don't have an associated Element. They all pass it to their parent as a `Layout::Node*` and handle a lack of `layout_node()` already so this won't affect any functionality. --- Userland/Libraries/LibWeb/DOM/Element.cpp | 8 ++++---- Userland/Libraries/LibWeb/Layout/InlineNode.cpp | 4 ++-- Userland/Libraries/LibWeb/Layout/InlineNode.h | 2 +- Userland/Libraries/LibWeb/Layout/ListItemBox.cpp | 4 ++-- Userland/Libraries/LibWeb/Layout/ListItemBox.h | 2 +- Userland/Libraries/LibWeb/Layout/TableRowGroupBox.cpp | 4 ++-- Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 681e85bc49..4879c19fab 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -205,7 +205,7 @@ RefPtr Element::create_layout_node(NonnullRefPtr Element::create_layout_node(NonnullRefPtr Element::create_layout_node(NonnullRefPtr style) - : Layout::NodeWithStyleAndBoxModelMetrics(document, &element, move(style)) +InlineNode::InlineNode(DOM::Document& document, DOM::Element* element, NonnullRefPtr style) + : Layout::NodeWithStyleAndBoxModelMetrics(document, element, move(style)) { set_inline(true); } diff --git a/Userland/Libraries/LibWeb/Layout/InlineNode.h b/Userland/Libraries/LibWeb/Layout/InlineNode.h index 0890641b1f..330f7caff0 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineNode.h +++ b/Userland/Libraries/LibWeb/Layout/InlineNode.h @@ -12,7 +12,7 @@ namespace Web::Layout { class InlineNode : public NodeWithStyleAndBoxModelMetrics { public: - InlineNode(DOM::Document&, DOM::Element&, NonnullRefPtr); + InlineNode(DOM::Document&, DOM::Element*, NonnullRefPtr); virtual ~InlineNode() override; virtual void paint(PaintContext&, PaintPhase) override; diff --git a/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp b/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp index a830b46c1f..cbad46707b 100644 --- a/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp @@ -10,8 +10,8 @@ namespace Web::Layout { -ListItemBox::ListItemBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr style) - : Layout::BlockContainer(document, &element, move(style)) +ListItemBox::ListItemBox(DOM::Document& document, DOM::Element* element, NonnullRefPtr style) + : Layout::BlockContainer(document, element, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/ListItemBox.h b/Userland/Libraries/LibWeb/Layout/ListItemBox.h index eb08aea4fb..b285e2b0df 100644 --- a/Userland/Libraries/LibWeb/Layout/ListItemBox.h +++ b/Userland/Libraries/LibWeb/Layout/ListItemBox.h @@ -13,7 +13,7 @@ namespace Web::Layout { class ListItemBox final : public BlockContainer { public: - ListItemBox(DOM::Document&, DOM::Element&, NonnullRefPtr); + ListItemBox(DOM::Document&, DOM::Element*, NonnullRefPtr); virtual ~ListItemBox() override; DOM::Element& dom_node() { return static_cast(*BlockContainer::dom_node()); } diff --git a/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.cpp b/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.cpp index 261a200511..990e419341 100644 --- a/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.cpp @@ -11,8 +11,8 @@ namespace Web::Layout { -TableRowGroupBox::TableRowGroupBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr style) - : Layout::BlockContainer(document, &element, move(style)) +TableRowGroupBox::TableRowGroupBox(DOM::Document& document, DOM::Element* element, NonnullRefPtr style) + : Layout::BlockContainer(document, element, move(style)) { } diff --git a/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h b/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h index 977a3992a0..46ac7f4997 100644 --- a/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h +++ b/Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h @@ -12,7 +12,7 @@ namespace Web::Layout { class TableRowGroupBox final : public BlockContainer { public: - TableRowGroupBox(DOM::Document&, DOM::Element&, NonnullRefPtr); + TableRowGroupBox(DOM::Document&, DOM::Element*, NonnullRefPtr); virtual ~TableRowGroupBox() override; size_t column_count() const;