summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-07-04 00:42:44 +0200
committerAndreas Kling <kling@serenityos.org>2022-07-04 22:30:59 +0200
commit7a7043f821de92a8602ab65b67cc6c522125e356 (patch)
tree4a8f8c9a17c31a63f52dcc44228cbc576b2f3e5e /Userland/Libraries
parentebac8abc04d892b50269e6c51522a0aca2ecf3f7 (diff)
downloadserenity-7a7043f821de92a8602ab65b67cc6c522125e356.zip
LibWeb: Simplify some WeakPtr assignments
We can assign a raw pointer directly to a WeakPtr without null-checking it first.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSRule.cpp10
-rw-r--r--Userland/Libraries/LibWeb/DOM/Node.cpp5
-rw-r--r--Userland/Libraries/LibWeb/Page/EventHandler.cpp5
3 files changed, 4 insertions, 16 deletions
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* 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;
}
}