Coverage Report

Created: 2025-03-04 07:22

/src/serenity/AK/WeakPtr.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <AK/Weakable.h>
10
11
namespace AK {
12
13
template<typename T>
14
class [[nodiscard]] WeakPtr {
15
    template<typename U>
16
    friend class Weakable;
17
18
public:
19
27.6k
    WeakPtr() = default;
Unexecuted instantiation: AK::WeakPtr<Core::EventReceiver>::WeakPtr()
AK::WeakPtr<JS::Shape>::WeakPtr()
Line
Count
Source
19
9.22k
    WeakPtr() = default;
AK::WeakPtr<JS::Object>::WeakPtr()
Line
Count
Source
19
9.22k
    WeakPtr() = default;
AK::WeakPtr<JS::PrototypeChainValidity>::WeakPtr()
Line
Count
Source
19
9.22k
    WeakPtr() = default;
Unexecuted instantiation: AK::WeakPtr<PDF::OutlineItem>::WeakPtr()
Unexecuted instantiation: AK::WeakPtr<PDF::Document>::WeakPtr()
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Document>::WeakPtr()
Unexecuted instantiation: AK::WeakPtr<Web::HTML::BrowsingContext>::WeakPtr()
Unexecuted instantiation: AK::WeakPtr<Web::HTML::Navigable>::WeakPtr()
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLFormElement>::WeakPtr()
Unexecuted instantiation: AK::WeakPtr<Web::DOM::EventTarget>::WeakPtr()
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLElement>::WeakPtr()
20
21
    template<SameAs<OptionalNone> V>
22
    WeakPtr(V) { }
23
24
    template<SameAs<OptionalNone> V>
25
    WeakPtr& operator=(V)
26
    {
27
        clear();
28
        return *this;
29
    }
30
31
    template<typename U>
32
    WeakPtr(WeakPtr<U> const& other)
33
    requires(IsBaseOf<T, U>)
34
        : m_link(other.m_link)
35
    {
36
    }
37
38
    template<typename U>
39
    WeakPtr(WeakPtr<U>&& other)
40
    requires(IsBaseOf<T, U>)
41
0
        : m_link(other.take_link())
42
0
    {
43
0
    }
44
45
    template<typename U>
46
    WeakPtr& operator=(WeakPtr<U>&& other)
47
    requires(IsBaseOf<T, U>)
48
0
    {
49
0
        m_link = other.take_link();
50
0
        return *this;
51
0
    }
Unexecuted instantiation: _ZN2AK7WeakPtrIN3Web4HTML11HTMLElementEEaSINS2_16HTMLInputElementEEERS4_ONS0_IT_EEQ8IsBaseOfIS8_TL0__E
Unexecuted instantiation: _ZN2AK7WeakPtrIN3Web4HTML11HTMLElementEEaSINS2_17HTMLSelectElementEEERS4_ONS0_IT_EEQ8IsBaseOfIS8_TL0__E
52
53
    template<typename U>
54
    WeakPtr& operator=(WeakPtr<U> const& other)
55
    requires(IsBaseOf<T, U>)
56
    {
57
        if ((void const*)this != (void const*)&other)
58
            m_link = other.m_link;
59
        return *this;
60
    }
61
62
    WeakPtr& operator=(nullptr_t)
63
0
    {
64
0
        clear();
65
0
        return *this;
66
0
    }
67
68
    template<typename U>
69
    WeakPtr(U const& object)
70
    requires(IsBaseOf<T, U>)
71
0
        : m_link(object.template make_weak_ptr<U>().take_link())
72
0
    {
73
0
    }
Unexecuted instantiation: _ZN2AK7WeakPtrIN4Core13EventReceiverEEC2IS2_EERKT_Q8IsBaseOfIS5_TL0__E
Unexecuted instantiation: _ZN2AK7WeakPtrIKN3Web3CSS10FontLoaderEEC2IS3_EERKT_Q8IsBaseOfIS7_TL0__E
Unexecuted instantiation: _ZN2AK7WeakPtrIN3Web3CSS14MediaQueryListEEC2IS3_EERKT_Q8IsBaseOfIS6_TL0__E
74
75
    template<typename U>
76
    WeakPtr(U const* object)
77
    requires(IsBaseOf<T, U>)
78
19.5k
    {
79
19.5k
        if (object)
80
19.5k
            m_link = object->template make_weak_ptr<U>().take_link();
81
19.5k
    }
_ZN2AK7WeakPtrIN2JS5ShapeEEC2IS2_EEPKT_Q8IsBaseOfIS5_TL0__E
Line
Count
Source
78
19.5k
    {
79
19.5k
        if (object)
80
19.5k
            m_link = object->template make_weak_ptr<U>().take_link();
81
19.5k
    }
_ZN2AK7WeakPtrIN3PDF8DocumentEEC2IS2_EEPKT_Q8IsBaseOfIS5_TL0__E
Line
Count
Source
78
28
    {
79
28
        if (object)
80
14
            m_link = object->template make_weak_ptr<U>().take_link();
81
28
    }
Unexecuted instantiation: _ZN2AK7WeakPtrIN3Web3DOM8DocumentEEC2IS3_EEPKT_Q8IsBaseOfIS6_TL0__E
82
83
    template<typename U>
84
    WeakPtr(RefPtr<U> const& object)
85
    requires(IsBaseOf<T, U>)
86
    {
87
        if (object)
88
            m_link = object->template make_weak_ptr<U>().take_link();
89
    }
90
91
    template<typename U>
92
    WeakPtr(NonnullRefPtr<U> const& object)
93
    requires(IsBaseOf<T, U>)
94
    {
95
        m_link = object->template make_weak_ptr<U>().take_link();
96
    }
97
98
    template<typename U>
99
    WeakPtr& operator=(U const& object)
100
    requires(IsBaseOf<T, U>)
101
1
    {
102
1
        m_link = object.template make_weak_ptr<U>().take_link();
103
1
        return *this;
104
1
    }
Unexecuted instantiation: _ZN2AK7WeakPtrIN4Core13EventReceiverEEaSIS2_EERS3_RKT_Q8IsBaseOfIS6_TL0__E
_ZN2AK7WeakPtrIN2JS5ShapeEEaSIS2_EERS3_RKT_Q8IsBaseOfIS6_TL0__E
Line
Count
Source
101
1
    {
102
1
        m_link = object.template make_weak_ptr<U>().take_link();
103
1
        return *this;
104
1
    }
Unexecuted instantiation: _ZN2AK7WeakPtrIN2JS6ObjectEEaSIS2_EERS3_RKT_Q8IsBaseOfIS6_TL0__E
Unexecuted instantiation: _ZN2AK7WeakPtrIN2JS22PrototypeChainValidityEEaSIS2_EERS3_RKT_Q8IsBaseOfIS6_TL0__E
Unexecuted instantiation: _ZN2AK7WeakPtrIN3Web3DOM8DocumentEEaSIS3_EERS4_RKT_Q8IsBaseOfIS7_TL0__E
Unexecuted instantiation: _ZN2AK7WeakPtrIN3Web4HTML9NavigableEEaSIS3_EERS4_RKT_Q8IsBaseOfIS7_TL0__E
105
106
    template<typename U>
107
    WeakPtr& operator=(U const* object)
108
    requires(IsBaseOf<T, U>)
109
0
    {
110
0
        if (object)
111
0
            m_link = object->template make_weak_ptr<U>().take_link();
112
0
        else
113
0
            m_link = nullptr;
114
0
        return *this;
115
0
    }
Unexecuted instantiation: _ZN2AK7WeakPtrIN2JS5ShapeEEaSIS2_EERS3_PKT_Q8IsBaseOfIS6_TL0__E
Unexecuted instantiation: _ZN2AK7WeakPtrIN3Web3DOM8DocumentEEaSIS3_EERS4_PKT_Q8IsBaseOfIS7_TL0__E
Unexecuted instantiation: _ZN2AK7WeakPtrIN3Web4HTML15BrowsingContextEEaSIS3_EERS4_PKT_Q8IsBaseOfIS7_TL0__E
Unexecuted instantiation: _ZN2AK7WeakPtrIN3Web4HTML9NavigableEEaSIS3_EERS4_PKT_Q8IsBaseOfIS7_TL0__E
Unexecuted instantiation: _ZN2AK7WeakPtrIN3Web4HTML15HTMLFormElementEEaSIS3_EERS4_PKT_Q8IsBaseOfIS7_TL0__E
Unexecuted instantiation: _ZN2AK7WeakPtrIN3Web3DOM11EventTargetEEaSINS2_4NodeEEERS4_PKT_Q8IsBaseOfIS8_TL0__E
116
117
    template<typename U>
118
    WeakPtr& operator=(RefPtr<U> const& object)
119
    requires(IsBaseOf<T, U>)
120
    {
121
        if (object)
122
            m_link = object->template make_weak_ptr<U>().take_link();
123
        else
124
            m_link = nullptr;
125
        return *this;
126
    }
127
128
    template<typename U>
129
    WeakPtr& operator=(NonnullRefPtr<U> const& object)
130
    requires(IsBaseOf<T, U>)
131
0
    {
132
0
        m_link = object->template make_weak_ptr<U>().take_link();
133
0
        return *this;
134
0
    }
135
136
    [[nodiscard]] RefPtr<T> strong_ref() const
137
0
    {
138
0
        return RefPtr<T> { ptr() };
139
0
    }
Unexecuted instantiation: AK::WeakPtr<Core::EventReceiver>::strong_ref() const
Unexecuted instantiation: AK::WeakPtr<Wasm::Module const>::strong_ref() const
140
141
56.4k
    T* ptr() const { return unsafe_ptr(); }
Unexecuted instantiation: AK::WeakPtr<Core::EventReceiver>::ptr() const
AK::WeakPtr<JS::Shape>::ptr() const
Line
Count
Source
141
56.4k
    T* ptr() const { return unsafe_ptr(); }
Unexecuted instantiation: AK::WeakPtr<Web::HTML::BrowsingContext>::ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::CSS::FontLoader const>::ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::CSS::MediaQueryList>::ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::HTML::Navigable>::ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Document>::ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLFormElement>::ptr() const
Unexecuted instantiation: AK::WeakPtr<JS::Cell>::ptr() const
Unexecuted instantiation: AK::WeakPtr<Wasm::Module const>::ptr() const
142
11
    T* operator->() const { return unsafe_ptr(); }
Unexecuted instantiation: AK::WeakPtr<JS::PrototypeChainValidity>::operator->() const
Unexecuted instantiation: AK::WeakPtr<JS::Object>::operator->() const
AK::WeakPtr<PDF::Document>::operator->() const
Line
Count
Source
142
11
    T* operator->() const { return unsafe_ptr(); }
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Node>::operator->() const
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Document>::operator->() const
Unexecuted instantiation: AK::WeakPtr<Web::HTML::BrowsingContext>::operator->() const
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLFormElement>::operator->() const
Unexecuted instantiation: AK::WeakPtr<Web::ResourceClient>::operator->() const
143
8
    operator T*() const { return unsafe_ptr(); }
AK::WeakPtr<JS::Shape>::operator JS::Shape*() const
Line
Count
Source
143
8
    operator T*() const { return unsafe_ptr(); }
Unexecuted instantiation: AK::WeakPtr<PDF::Document>::operator PDF::Document*() const
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLFormElement>::operator Web::HTML::HTMLFormElement*() const
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Element>::operator Web::DOM::Element*() const
Unexecuted instantiation: AK::WeakPtr<Web::HTML::BrowsingContext>::operator Web::HTML::BrowsingContext*() const
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Document>::operator Web::DOM::Document*() const
Unexecuted instantiation: AK::WeakPtr<Web::ResourceClient>::operator Web::ResourceClient*() const
Unexecuted instantiation: AK::WeakPtr<Web::DOM::EventTarget>::operator Web::DOM::EventTarget*() const
Unexecuted instantiation: AK::WeakPtr<Web::HTML::Navigable>::operator Web::HTML::Navigable*() const
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLElement>::operator Web::HTML::HTMLElement*() const
Unexecuted instantiation: AK::WeakPtr<Web::WebSockets::WebSocket>::operator Web::WebSockets::WebSocket*() const
144
145
    [[nodiscard]] T* unsafe_ptr() const
146
56.5k
    {
147
56.5k
        if (m_link)
148
56.5k
            return m_link->template unsafe_ptr<T>();
149
8
        return nullptr;
150
56.5k
    }
Unexecuted instantiation: AK::WeakPtr<Core::EventReceiver>::unsafe_ptr() const
AK::WeakPtr<JS::Shape>::unsafe_ptr() const
Line
Count
Source
146
56.5k
    {
147
56.5k
        if (m_link)
148
56.4k
            return m_link->template unsafe_ptr<T>();
149
8
        return nullptr;
150
56.5k
    }
Unexecuted instantiation: AK::WeakPtr<JS::PrototypeChainValidity>::unsafe_ptr() const
Unexecuted instantiation: AK::WeakPtr<JS::Object>::unsafe_ptr() const
AK::WeakPtr<PDF::Document>::unsafe_ptr() const
Line
Count
Source
146
11
    {
147
11
        if (m_link)
148
11
            return m_link->template unsafe_ptr<T>();
149
0
        return nullptr;
150
11
    }
Unexecuted instantiation: AK::WeakPtr<Web::HTML::BrowsingContext>::unsafe_ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Node>::unsafe_ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLFormElement>::unsafe_ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::CSS::FontLoader const>::unsafe_ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Element>::unsafe_ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Document>::unsafe_ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::CSS::MediaQueryList>::unsafe_ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::HTML::Navigable>::unsafe_ptr() const
Unexecuted instantiation: AK::WeakPtr<JS::Cell>::unsafe_ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::ResourceClient>::unsafe_ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::DOM::EventTarget>::unsafe_ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLElement>::unsafe_ptr() const
Unexecuted instantiation: AK::WeakPtr<Wasm::Module const>::unsafe_ptr() const
Unexecuted instantiation: AK::WeakPtr<Web::WebSockets::WebSocket>::unsafe_ptr() const
151
152
    [[nodiscard]] NonnullRefPtr<T> value() const
153
    {
154
        VERIFY(has_value());
155
        return *unsafe_ptr();
156
    }
157
158
56.4k
    operator bool() const { return m_link ? !m_link->is_null() : false; }
Unexecuted instantiation: AK::WeakPtr<JS::Object>::operator bool() const
Unexecuted instantiation: AK::WeakPtr<JS::PrototypeChainValidity>::operator bool() const
AK::WeakPtr<JS::Shape>::operator bool() const
Line
Count
Source
158
56.4k
    operator bool() const { return m_link ? !m_link->is_null() : false; }
Unexecuted instantiation: AK::WeakPtr<Web::CSS::ImageStyleValue>::operator bool() const
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Document>::operator bool() const
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLFormElement>::operator bool() const
Unexecuted instantiation: AK::WeakPtr<JS::Cell>::operator bool() const
Unexecuted instantiation: AK::WeakPtr<Web::ResourceClient>::operator bool() const
Unexecuted instantiation: AK::WeakPtr<Web::HTML::Navigable>::operator bool() const
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLElement>::operator bool() const
Unexecuted instantiation: AK::WeakPtr<Web::WebSockets::WebSocket>::operator bool() const
159
160
0
    [[nodiscard]] bool is_null() const { return !m_link || m_link->is_null(); }
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Node>::is_null() const
Unexecuted instantiation: AK::WeakPtr<Web::CSS::MediaQueryList>::is_null() const
161
    [[nodiscard]] bool has_value() const { return !is_null(); }
162
163
0
    void clear() { m_link = nullptr; }
Unexecuted instantiation: AK::WeakPtr<Web::HTML::BrowsingContext>::clear()
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLElement>::clear()
164
165
19.5k
    [[nodiscard]] RefPtr<WeakLink> take_link() { return move(m_link); }
Unexecuted instantiation: AK::WeakPtr<Core::EventReceiver>::take_link()
AK::WeakPtr<JS::Shape>::take_link()
Line
Count
Source
165
19.5k
    [[nodiscard]] RefPtr<WeakLink> take_link() { return move(m_link); }
Unexecuted instantiation: AK::WeakPtr<JS::Object>::take_link()
Unexecuted instantiation: AK::WeakPtr<JS::PrototypeChainValidity>::take_link()
AK::WeakPtr<PDF::Document>::take_link()
Line
Count
Source
165
14
    [[nodiscard]] RefPtr<WeakLink> take_link() { return move(m_link); }
Unexecuted instantiation: AK::WeakPtr<PDF::OutlineItem>::take_link()
Unexecuted instantiation: AK::WeakPtr<Web::CSS::FontLoader>::take_link()
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Document>::take_link()
Unexecuted instantiation: AK::WeakPtr<Web::CSS::MediaQueryList>::take_link()
Unexecuted instantiation: AK::WeakPtr<Web::HTML::BrowsingContext>::take_link()
Unexecuted instantiation: AK::WeakPtr<Web::HTML::Navigable>::take_link()
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLFormElement>::take_link()
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Node>::take_link()
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLInputElement>::take_link()
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLSelectElement>::take_link()
Unexecuted instantiation: AK::WeakPtr<Wasm::Module>::take_link()
166
167
private:
168
    WeakPtr(RefPtr<WeakLink> const& link)
169
19.5k
        : m_link(link)
170
19.5k
    {
171
19.5k
    }
Unexecuted instantiation: AK::WeakPtr<Core::EventReceiver>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
AK::WeakPtr<JS::Shape>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Line
Count
Source
169
19.5k
        : m_link(link)
170
19.5k
    {
171
19.5k
    }
Unexecuted instantiation: AK::WeakPtr<JS::Object>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<JS::PrototypeChainValidity>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
AK::WeakPtr<PDF::Document>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Line
Count
Source
169
14
        : m_link(link)
170
14
    {
171
14
    }
Unexecuted instantiation: AK::WeakPtr<PDF::OutlineItem>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Element>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<Web::CSS::FontLoader>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Document>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<Web::CSS::ImageStyleValue>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<Web::CSS::MediaQueryList>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<Web::HTML::BrowsingContext>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<Web::HTML::Navigable>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<Web::DOM::Node>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLFormElement>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLInputElement>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<Web::HTML::HTMLSelectElement>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<JS::Cell>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<Web::ResourceClient>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<Web::WebSockets::WebSocket>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
Unexecuted instantiation: AK::WeakPtr<Wasm::Module>::WeakPtr(AK::RefPtr<AK::WeakLink> const&)
172
173
    RefPtr<WeakLink> m_link;
174
};
175
176
template<typename T>
177
template<typename U>
178
inline ErrorOr<WeakPtr<U>> Weakable<T>::try_make_weak_ptr() const
179
19.5k
{
180
19.5k
    if (!m_link)
181
19.5k
        m_link = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) WeakLink(const_cast<T&>(static_cast<T const&>(*this)))));
182
183
19.5k
    return WeakPtr<U>(m_link);
184
19.5k
}
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Core::EventReceiver>, AK::Error> AK::Weakable<Core::EventReceiver>::try_make_weak_ptr<Core::EventReceiver>() const
AK::ErrorOr<AK::WeakPtr<JS::Shape>, AK::Error> AK::Weakable<JS::Cell>::try_make_weak_ptr<JS::Shape>() const
Line
Count
Source
179
19.5k
{
180
19.5k
    if (!m_link)
181
19.5k
        m_link = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) WeakLink(const_cast<T&>(static_cast<T const&>(*this)))));
182
183
19.5k
    return WeakPtr<U>(m_link);
184
19.5k
}
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<JS::Object>, AK::Error> AK::Weakable<JS::Cell>::try_make_weak_ptr<JS::Object>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<JS::PrototypeChainValidity>, AK::Error> AK::Weakable<JS::Cell>::try_make_weak_ptr<JS::PrototypeChainValidity>() const
AK::ErrorOr<AK::WeakPtr<PDF::Document>, AK::Error> AK::Weakable<PDF::Document>::try_make_weak_ptr<PDF::Document>() const
Line
Count
Source
179
14
{
180
14
    if (!m_link)
181
14
        m_link = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) WeakLink(const_cast<T&>(static_cast<T const&>(*this)))));
182
183
14
    return WeakPtr<U>(m_link);
184
14
}
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<PDF::OutlineItem>, AK::Error> AK::Weakable<PDF::OutlineItem>::try_make_weak_ptr<PDF::OutlineItem>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Web::DOM::Element>, AK::Error> AK::Weakable<JS::Cell>::try_make_weak_ptr<Web::DOM::Element>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Web::CSS::FontLoader>, AK::Error> AK::Weakable<Web::ResourceClient>::try_make_weak_ptr<Web::CSS::FontLoader>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Web::DOM::Document>, AK::Error> AK::Weakable<JS::Cell>::try_make_weak_ptr<Web::DOM::Document>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Web::CSS::ImageStyleValue>, AK::Error> AK::Weakable<Web::CSS::ImageStyleValue>::try_make_weak_ptr<Web::CSS::ImageStyleValue>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Web::CSS::MediaQueryList>, AK::Error> AK::Weakable<JS::Cell>::try_make_weak_ptr<Web::CSS::MediaQueryList>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Web::HTML::BrowsingContext>, AK::Error> AK::Weakable<JS::Cell>::try_make_weak_ptr<Web::HTML::BrowsingContext>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Web::HTML::Navigable>, AK::Error> AK::Weakable<JS::Cell>::try_make_weak_ptr<Web::HTML::Navigable>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Web::DOM::Node>, AK::Error> AK::Weakable<JS::Cell>::try_make_weak_ptr<Web::DOM::Node>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Web::HTML::HTMLFormElement>, AK::Error> AK::Weakable<JS::Cell>::try_make_weak_ptr<Web::HTML::HTMLFormElement>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Web::HTML::HTMLInputElement>, AK::Error> AK::Weakable<JS::Cell>::try_make_weak_ptr<Web::HTML::HTMLInputElement>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Web::HTML::HTMLSelectElement>, AK::Error> AK::Weakable<JS::Cell>::try_make_weak_ptr<Web::HTML::HTMLSelectElement>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<JS::Cell>, AK::Error> AK::Weakable<JS::Cell>::try_make_weak_ptr<JS::Cell>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Web::ResourceClient>, AK::Error> AK::Weakable<Web::ResourceClient>::try_make_weak_ptr<Web::ResourceClient>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Wasm::Module>, AK::Error> AK::Weakable<Wasm::Module>::try_make_weak_ptr<Wasm::Module>() const
Unexecuted instantiation: AK::ErrorOr<AK::WeakPtr<Web::WebSockets::WebSocket>, AK::Error> AK::Weakable<JS::Cell>::try_make_weak_ptr<Web::WebSockets::WebSocket>() const
185
186
template<typename T>
187
struct Formatter<WeakPtr<T>> : Formatter<T const*> {
188
    ErrorOr<void> format(FormatBuilder& builder, WeakPtr<T> const& value)
189
    {
190
        return Formatter<T const*>::format(builder, value.ptr());
191
    }
192
};
193
194
template<typename T>
195
ErrorOr<WeakPtr<T>> try_make_weak_ptr_if_nonnull(T const* ptr)
196
0
{
197
0
    if (ptr) {
198
0
        return ptr->template try_make_weak_ptr<T>();
199
0
    }
200
0
    return WeakPtr<T> {};
201
0
}
202
203
template<typename T>
204
WeakPtr<T> make_weak_ptr_if_nonnull(T const* ptr)
205
0
{
206
0
    return MUST(try_make_weak_ptr_if_nonnull(ptr));
207
0
}
208
209
}
210
211
#if USING_AK_GLOBALLY
212
using AK::WeakPtr;
213
#endif