From 7a7043f821de92a8602ab65b67cc6c522125e356 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 4 Jul 2022 00:42:44 +0200 Subject: LibWeb: Simplify some WeakPtr assignments We can assign a raw pointer directly to a WeakPtr without null-checking it first. --- Userland/Libraries/LibWeb/CSS/CSSRule.cpp | 10 ++-------- Userland/Libraries/LibWeb/DOM/Node.cpp | 5 +---- Userland/Libraries/LibWeb/Page/EventHandler.cpp | 5 +---- 3 files changed, 4 insertions(+), 16 deletions(-) (limited to 'Userland/Libraries') diff --git a/Userland/Libraries/LibWeb/CSS/CSSRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSRule.cpp index aeeec6b7fb..bd1b94493a 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSRule.cpp @@ -25,18 +25,12 @@ void CSSRule::set_css_text(StringView) void CSSRule::set_parent_rule(CSSRule* parent_rule) { - if (parent_rule) - m_parent_rule = parent_rule->make_weak_ptr(); - else - m_parent_rule = nullptr; + m_parent_rule = parent_rule; } void CSSRule::set_parent_style_sheet(CSSStyleSheet* parent_style_sheet) { - if (parent_style_sheet) - m_parent_style_sheet = parent_style_sheet->make_weak_ptr(); - else - m_parent_style_sheet = nullptr; + m_parent_style_sheet = parent_style_sheet; } } diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index d697b57e39..7e68facfd5 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -792,10 +792,7 @@ void Node::removed_last_ref() void Node::set_layout_node(Badge, Layout::Node* layout_node) const { - if (layout_node) - m_layout_node = layout_node->make_weak_ptr(); - else - m_layout_node = nullptr; + m_layout_node = layout_node; } EventTarget* Node::get_parent(Event const&) diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index e153ecb6fa..56acbbf398 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -752,10 +752,7 @@ bool EventHandler::handle_keyup(KeyCode key, unsigned modifiers, u32 code_point) void EventHandler::set_mouse_event_tracking_layout_node(Layout::Node* layout_node) { - if (layout_node) - m_mouse_event_tracking_layout_node = layout_node->make_weak_ptr(); - else - m_mouse_event_tracking_layout_node = nullptr; + m_mouse_event_tracking_layout_node = layout_node; } } -- cgit v1.2.3