summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-04-23 16:46:57 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-23 16:46:57 +0200
commitb91c49364df1683c7fe1191eb02b8d9c331874f6 (patch)
treea9ea5ff8e4cc8cfcfe75c279551be35793d0ffb3
parentb3db01e20eeae632cc75df9af8666772bda67091 (diff)
downloadserenity-b91c49364df1683c7fe1191eb02b8d9c331874f6.zip
AK: Rename adopt() to adopt_ref()
This makes it more symmetrical with adopt_own() (which is used to create a NonnullOwnPtr from the result of a naked new.)
-rw-r--r--AK/ByteBuffer.h6
-rw-r--r--AK/MappedFile.cpp2
-rw-r--r--AK/NonnullRefPtr.h4
-rw-r--r--AK/StringImpl.cpp2
-rw-r--r--AK/TestSuite.h28
-rw-r--r--AK/Tests/TestIntrusiveList.cpp8
-rw-r--r--AK/Tests/TestNonnullRefPtr.cpp10
-rw-r--r--AK/Tests/TestRefPtr.cpp18
-rw-r--r--AK/Tests/TestWeakPtr.cpp4
-rw-r--r--AK/WeakPtr.h2
-rw-r--r--AK/Weakable.h2
-rw-r--r--Documentation/SmartPointers.md4
-rw-r--r--Kernel/Devices/Device.h2
-rw-r--r--Kernel/Devices/HID/I8042Controller.cpp2
-rw-r--r--Kernel/Devices/HID/PS2KeyboardDevice.cpp2
-rw-r--r--Kernel/Devices/HID/PS2MouseDevice.cpp2
-rw-r--r--Kernel/Devices/HID/VMWareMouseDevice.cpp2
-rw-r--r--Kernel/FileSystem/AnonymousFile.h2
-rw-r--r--Kernel/FileSystem/Custody.h2
-rw-r--r--Kernel/FileSystem/DevFS.cpp10
-rw-r--r--Kernel/FileSystem/DevPtsFS.cpp6
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.cpp4
-rw-r--r--Kernel/FileSystem/FIFO.cpp2
-rw-r--r--Kernel/FileSystem/FileDescription.cpp4
-rw-r--r--Kernel/FileSystem/InodeFile.h2
-rw-r--r--Kernel/FileSystem/InodeWatcher.cpp2
-rw-r--r--Kernel/FileSystem/Plan9FileSystem.cpp6
-rw-r--r--Kernel/FileSystem/ProcFS.cpp8
-rw-r--r--Kernel/FileSystem/ProcFS.h2
-rw-r--r--Kernel/FileSystem/TmpFS.cpp4
-rw-r--r--Kernel/Interrupts/InterruptManagement.cpp6
-rw-r--r--Kernel/KBuffer.h4
-rw-r--r--Kernel/Net/E1000NetworkAdapter.cpp2
-rw-r--r--Kernel/Net/IPv4Socket.cpp2
-rw-r--r--Kernel/Net/LocalSocket.cpp2
-rw-r--r--Kernel/Net/NE2000NetworkAdapter.cpp2
-rw-r--r--Kernel/Net/RTL8139NetworkAdapter.cpp2
-rw-r--r--Kernel/Net/TCPSocket.cpp2
-rw-r--r--Kernel/Net/UDPSocket.cpp2
-rw-r--r--Kernel/Process.cpp4
-rw-r--r--Kernel/ProcessGroup.cpp2
-rw-r--r--Kernel/Storage/AHCIController.cpp2
-rw-r--r--Kernel/Storage/AHCIPort.cpp4
-rw-r--r--Kernel/Storage/AHCIPortHandler.cpp2
-rw-r--r--Kernel/Storage/BMIDEChannel.cpp4
-rw-r--r--Kernel/Storage/IDEChannel.cpp4
-rw-r--r--Kernel/Storage/IDEController.cpp2
-rw-r--r--Kernel/Storage/PATADiskDevice.cpp2
-rw-r--r--Kernel/Storage/Partition/DiskPartition.cpp2
-rw-r--r--Kernel/Storage/RamdiskController.cpp2
-rw-r--r--Kernel/Storage/RamdiskDevice.cpp2
-rw-r--r--Kernel/Storage/SATADiskDevice.cpp2
-rw-r--r--Kernel/Syscalls/fork.cpp2
-rw-r--r--Kernel/Syscalls/futex.cpp2
-rw-r--r--Kernel/TTY/MasterPTY.cpp2
-rw-r--r--Kernel/TTY/PTYMultiplexer.cpp2
-rw-r--r--Kernel/Thread.cpp2
-rw-r--r--Kernel/Time/APICTimer.cpp2
-rw-r--r--Kernel/Time/HPETComparator.cpp2
-rw-r--r--Kernel/Time/PIT.cpp2
-rw-r--r--Kernel/Time/RTC.cpp2
-rw-r--r--Kernel/TimerQueue.cpp4
-rw-r--r--Kernel/VM/AnonymousVMObject.cpp12
-rw-r--r--Kernel/VM/ContiguousVMObject.cpp2
-rw-r--r--Kernel/VM/PageDirectory.h4
-rw-r--r--Kernel/VM/PhysicalPage.cpp2
-rw-r--r--Kernel/VM/PhysicalRegion.cpp2
-rw-r--r--Kernel/VM/PrivateInodeVMObject.cpp4
-rw-r--r--Kernel/VM/SharedInodeVMObject.cpp4
-rw-r--r--Kernel/VirtIO/VirtIO.cpp4
-rw-r--r--Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp2
-rw-r--r--Userland/Applications/Browser/ConsoleWidget.cpp2
-rw-r--r--Userland/Applications/Calendar/AddEventDialog.h2
-rw-r--r--Userland/Applications/FileManager/DirectoryView.cpp2
-rw-r--r--Userland/Applications/FontEditor/FontEditor.cpp2
-rw-r--r--Userland/Applications/FontEditor/UndoGlyph.h2
-rw-r--r--Userland/Applications/Help/ManualModel.h2
-rw-r--r--Userland/Applications/IRCClient/IRCChannel.cpp2
-rw-r--r--Userland/Applications/IRCClient/IRCChannelMemberListModel.h2
-rw-r--r--Userland/Applications/IRCClient/IRCLogBuffer.cpp6
-rw-r--r--Userland/Applications/IRCClient/IRCQuery.cpp2
-rw-r--r--Userland/Applications/IRCClient/IRCWindowListModel.h2
-rw-r--r--Userland/Applications/KeyboardSettings/CharacterMapFileListModel.h2
-rw-r--r--Userland/Applications/PixelPaint/Image.cpp2
-rw-r--r--Userland/Applications/PixelPaint/Layer.cpp4
-rw-r--r--Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp2
-rw-r--r--Userland/Applications/SpaceAnalyzer/main.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/HelpWindow.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/HelpWindow.h2
-rw-r--r--Userland/Applications/Spreadsheet/Spreadsheet.cpp4
-rw-r--r--Userland/Applications/Spreadsheet/SpreadsheetModel.h2
-rw-r--r--Userland/Applications/SystemMonitor/DevicesModel.cpp2
-rw-r--r--Userland/Applications/SystemMonitor/ProcessModel.h2
-rw-r--r--Userland/Applications/SystemMonitor/ProcessStateWidget.cpp2
-rw-r--r--Userland/Applications/ThemeEditor/main.cpp2
-rw-r--r--Userland/Demos/WidgetGallery/GalleryModels.h4
-rw-r--r--Userland/DevTools/HackStudio/ClassViewWidget.cpp2
-rw-r--r--Userland/DevTools/HackStudio/CodeDocument.cpp4
-rw-r--r--Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp2
-rw-r--r--Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h2
-rw-r--r--Userland/DevTools/HackStudio/Debugger/RegistersModel.h4
-rw-r--r--Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp2
-rw-r--r--Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h2
-rw-r--r--Userland/DevTools/HackStudio/FindInFilesWidget.cpp2
-rw-r--r--Userland/DevTools/HackStudio/Git/GitFilesModel.cpp2
-rw-r--r--Userland/DevTools/HackStudio/Git/GitRepo.cpp4
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp4
-rw-r--r--Userland/DevTools/HackStudio/Locator.cpp2
-rw-r--r--Userland/DevTools/HackStudio/ProjectFile.h2
-rw-r--r--Userland/DevTools/HackStudio/ProjectTemplate.cpp2
-rw-r--r--Userland/DevTools/HackStudio/WidgetTreeModel.h2
-rw-r--r--Userland/DevTools/Inspector/RemoteObjectGraphModel.h2
-rw-r--r--Userland/DevTools/Inspector/RemoteObjectPropertyModel.h2
-rw-r--r--Userland/DevTools/Profiler/DisassemblyModel.h2
-rw-r--r--Userland/DevTools/Profiler/IndividualSampleModel.h2
-rw-r--r--Userland/DevTools/Profiler/Profile.h2
-rw-r--r--Userland/DevTools/Profiler/ProfileModel.h2
-rw-r--r--Userland/DevTools/Profiler/SamplesModel.h2
-rw-r--r--Userland/Libraries/LibAudio/Buffer.h4
-rw-r--r--Userland/Libraries/LibAudio/Loader.h4
-rw-r--r--Userland/Libraries/LibCore/AnonymousBuffer.cpp2
-rw-r--r--Userland/Libraries/LibCore/ConfigFile.cpp8
-rw-r--r--Userland/Libraries/LibCore/EventLoop.cpp2
-rw-r--r--Userland/Libraries/LibCore/FileWatcher.cpp2
-rw-r--r--Userland/Libraries/LibCore/Object.h2
-rw-r--r--Userland/Libraries/LibCore/Timer.h4
-rw-r--r--Userland/Libraries/LibCpp/Parser.h6
-rw-r--r--Userland/Libraries/LibDesktop/AppFile.cpp2
-rw-r--r--Userland/Libraries/LibDesktop/Launcher.cpp2
-rw-r--r--Userland/Libraries/LibELF/DynamicLoader.cpp2
-rw-r--r--Userland/Libraries/LibELF/DynamicObject.cpp2
-rw-r--r--Userland/Libraries/LibGUI/Action.cpp16
-rw-r--r--Userland/Libraries/LibGUI/AutocompleteProvider.cpp2
-rw-r--r--Userland/Libraries/LibGUI/DisplayLink.cpp2
-rw-r--r--Userland/Libraries/LibGUI/FileSystemModel.h2
-rw-r--r--Userland/Libraries/LibGUI/FilteringProxyModel.h2
-rw-r--r--Userland/Libraries/LibGUI/FontPicker.cpp2
-rw-r--r--Userland/Libraries/LibGUI/Icon.h2
-rw-r--r--Userland/Libraries/LibGUI/ItemListModel.h4
-rw-r--r--Userland/Libraries/LibGUI/JsonArrayModel.h2
-rw-r--r--Userland/Libraries/LibGUI/RunningProcessesModel.cpp2
-rw-r--r--Userland/Libraries/LibGUI/SortingProxyModel.h2
-rw-r--r--Userland/Libraries/LibGUI/TextDocument.cpp2
-rw-r--r--Userland/Libraries/LibGemini/Document.cpp2
-rw-r--r--Userland/Libraries/LibGemini/GeminiResponse.h2
-rw-r--r--Userland/Libraries/LibGfx/Bitmap.cpp8
-rw-r--r--Userland/Libraries/LibGfx/BitmapFont.cpp6
-rw-r--r--Userland/Libraries/LibGfx/CharacterBitmap.cpp2
-rw-r--r--Userland/Libraries/LibGfx/FontDatabase.cpp2
-rw-r--r--Userland/Libraries/LibGfx/ImageDecoder.h4
-rw-r--r--Userland/Libraries/LibGfx/Palette.cpp4
-rw-r--r--Userland/Libraries/LibGfx/Path.h2
-rw-r--r--Userland/Libraries/LibGfx/Typeface.cpp2
-rw-r--r--Userland/Libraries/LibHTTP/HttpResponse.h2
-rw-r--r--Userland/Libraries/LibJS/AST.h2
-rw-r--r--Userland/Libraries/LibJS/Heap/Handle.h2
-rw-r--r--Userland/Libraries/LibJS/Parser.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/VM.cpp2
-rw-r--r--Userland/Libraries/LibPCIDB/Database.cpp2
-rw-r--r--Userland/Libraries/LibProtocol/Download.h2
-rw-r--r--Userland/Libraries/LibSQL/AST.h2
-rw-r--r--Userland/Libraries/LibTTF/Font.cpp2
-rw-r--r--Userland/Libraries/LibThread/BackgroundAction.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSImportRule.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h4
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSStyleRule.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/Screen.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleProperties.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleProperties.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleSheetList.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleValue.h14
-rw-r--r--Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp4
-rw-r--r--Userland/Libraries/LibWeb/DOM/DOMException.h4
-rw-r--r--Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp4
-rw-r--r--Userland/Libraries/LibWeb/DOM/DOMImplementation.h2
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp14
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.h2
-rw-r--r--Userland/Libraries/LibWeb/DOM/Element.cpp22
-rw-r--r--Userland/Libraries/LibWeb/DOM/ElementFactory.cpp146
-rw-r--r--Userland/Libraries/LibWeb/DOM/Event.h2
-rw-r--r--Userland/Libraries/LibWeb/DOM/HTMLCollection.h2
-rw-r--r--Userland/Libraries/LibWeb/DOM/Node.cpp10
-rw-r--r--Userland/Libraries/LibWeb/DOM/Range.cpp8
-rw-r--r--Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp2
-rw-r--r--Userland/Libraries/LibWeb/DOM/Text.cpp2
-rw-r--r--Userland/Libraries/LibWeb/DOM/Timer.cpp4
-rw-r--r--Userland/Libraries/LibWeb/DOM/Window.cpp2
-rw-r--r--Userland/Libraries/LibWeb/DOMTreeModel.h2
-rw-r--r--Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h2
-rw-r--r--Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp4
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp12
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/ImageData.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp16
-rw-r--r--Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Layout/ListItemBox.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Layout/Node.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp4
-rw-r--r--Userland/Libraries/LibWeb/LayoutTreeModel.h2
-rw-r--r--Userland/Libraries/LibWeb/Loader/FrameLoader.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Loader/Resource.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Page/Frame.h4
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/StylePropertiesModel.h2
-rw-r--r--Userland/Libraries/LibWeb/UIEvents/MouseEvent.h2
-rw-r--r--Userland/Libraries/LibWeb/XHR/ProgressEvent.h2
-rw-r--r--Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h2
-rw-r--r--Userland/Libraries/LibWebSocket/WebSocket.cpp2
-rw-r--r--Userland/Services/AudioServer/Mixer.cpp2
-rw-r--r--Userland/Services/EchoServer/Client.h2
-rw-r--r--Userland/Services/TelnetServer/Client.h2
-rw-r--r--Userland/Services/WindowServer/Cursor.cpp4
-rw-r--r--Userland/Services/WindowServer/Menubar.h2
-rw-r--r--Userland/Shell/AST.cpp8
-rw-r--r--Userland/Shell/AST.h12
-rw-r--r--Userland/Shell/Builtin.cpp2
-rw-r--r--Userland/Shell/Job.h2
-rw-r--r--Userland/Shell/Parser.cpp2
-rw-r--r--Userland/Shell/Shell.cpp14
-rw-r--r--Userland/Shell/main.cpp2
228 files changed, 461 insertions, 461 deletions
diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h
index bd85e08c48..38e1e377f9 100644
--- a/AK/ByteBuffer.h
+++ b/AK/ByteBuffer.h
@@ -292,12 +292,12 @@ inline void ByteBufferImpl::zero_fill()
inline NonnullRefPtr<ByteBufferImpl> ByteBufferImpl::create_uninitialized(size_t size)
{
- return ::adopt(*new ByteBufferImpl(size));
+ return ::adopt_ref(*new ByteBufferImpl(size));
}
inline NonnullRefPtr<ByteBufferImpl> ByteBufferImpl::create_zeroed(size_t size)
{
- auto buffer = ::adopt(*new ByteBufferImpl(size));
+ auto buffer = ::adopt_ref(*new ByteBufferImpl(size));
if (size != 0)
__builtin_memset(buffer->data(), 0, size);
return buffer;
@@ -305,7 +305,7 @@ inline NonnullRefPtr<ByteBufferImpl> ByteBufferImpl::create_zeroed(size_t size)
inline NonnullRefPtr<ByteBufferImpl> ByteBufferImpl::copy(const void* data, size_t size)
{
- return ::adopt(*new ByteBufferImpl(data, size));
+ return ::adopt_ref(*new ByteBufferImpl(data, size));
}
}
diff --git a/AK/MappedFile.cpp b/AK/MappedFile.cpp
index 284f981461..9c3199d0fe 100644
--- a/AK/MappedFile.cpp
+++ b/AK/MappedFile.cpp
@@ -37,7 +37,7 @@ Result<NonnullRefPtr<MappedFile>, OSError> MappedFile::map(const String& path)
if (ptr == MAP_FAILED)
return OSError(errno);
- return adopt(*new MappedFile(ptr, size));
+ return adopt_ref(*new MappedFile(ptr, size));
}
MappedFile::MappedFile(void* ptr, size_t size)
diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h
index b64ea0e3c6..b4ea20b451 100644
--- a/AK/NonnullRefPtr.h
+++ b/AK/NonnullRefPtr.h
@@ -314,7 +314,7 @@ private:
};
template<typename T>
-inline NonnullRefPtr<T> adopt(T& object)
+inline NonnullRefPtr<T> adopt_ref(T& object)
{
return NonnullRefPtr<T>(NonnullRefPtr<T>::Adopt, object);
}
@@ -335,5 +335,5 @@ inline void swap(NonnullRefPtr<T>& a, NonnullRefPtr<U>& b)
}
-using AK::adopt;
+using AK::adopt_ref;
using AK::NonnullRefPtr;
diff --git a/AK/StringImpl.cpp b/AK/StringImpl.cpp
index f29c5c3579..ea7c4f5255 100644
--- a/AK/StringImpl.cpp
+++ b/AK/StringImpl.cpp
@@ -71,7 +71,7 @@ NonnullRefPtr<StringImpl> StringImpl::create_uninitialized(size_t length, char*&
VERIFY(length);
void* slot = kmalloc(allocation_size_for_stringimpl(length));
VERIFY(slot);
- auto new_stringimpl = adopt(*new (slot) StringImpl(ConstructWithInlineBuffer, length));
+ auto new_stringimpl = adopt_ref(*new (slot) StringImpl(ConstructWithInlineBuffer, length));
buffer = const_cast<char*>(new_stringimpl->characters());
buffer[length] = '\0';
return new_stringimpl;
diff --git a/AK/TestSuite.h b/AK/TestSuite.h
index b8f252a142..45799bd102 100644
--- a/AK/TestSuite.h
+++ b/AK/TestSuite.h
@@ -239,25 +239,25 @@ using AK::TestSuite;
#define __TESTCASE_FUNC(x) __test_##x
#define __TESTCASE_TYPE(x) __TestCase_##x
-#define TEST_CASE(x) \
- static void __TESTCASE_FUNC(x)(); \
- struct __TESTCASE_TYPE(x) { \
- __TESTCASE_TYPE(x) \
- () { TestSuite::the().add_case(adopt(*new TestCase(#x, __TESTCASE_FUNC(x), false))); } \
- }; \
- static struct __TESTCASE_TYPE(x) __TESTCASE_TYPE(x); \
+#define TEST_CASE(x) \
+ static void __TESTCASE_FUNC(x)(); \
+ struct __TESTCASE_TYPE(x) { \
+ __TESTCASE_TYPE(x) \
+ () { TestSuite::the().add_case(adopt_ref(*new TestCase(#x, __TESTCASE_FUNC(x), false))); } \
+ }; \
+ static struct __TESTCASE_TYPE(x) __TESTCASE_TYPE(x); \
static void __TESTCASE_FUNC(x)()
#define __BENCHMARK_FUNC(x) __benchmark_##x
#define __BENCHMARK_TYPE(x) __BenchmarkCase_##x
-#define BENCHMARK_CASE(x) \
- static void __BENCHMARK_FUNC(x)(); \
- struct __BENCHMARK_TYPE(x) { \
- __BENCHMARK_TYPE(x) \
- () { TestSuite::the().add_case(adopt(*new TestCase(#x, __BENCHMARK_FUNC(x), true))); } \
- }; \
- static struct __BENCHMARK_TYPE(x) __BENCHMARK_TYPE(x); \
+#define BENCHMARK_CASE(x) \
+ static void __BENCHMARK_FUNC(x)(); \
+ struct __BENCHMARK_TYPE(x) { \
+ __BENCHMARK_TYPE(x) \
+ () { TestSuite::the().add_case(adopt_ref(*new TestCase(#x, __BENCHMARK_FUNC(x), true))); } \
+ }; \
+ static struct __BENCHMARK_TYPE(x) __BENCHMARK_TYPE(x); \
static void __BENCHMARK_FUNC(x)()
#define TEST_MAIN(x) \
diff --git a/AK/Tests/TestIntrusiveList.cpp b/AK/Tests/TestIntrusiveList.cpp
index ee9af5a276..3e3012bc20 100644
--- a/AK/Tests/TestIntrusiveList.cpp
+++ b/AK/Tests/TestIntrusiveList.cpp
@@ -60,7 +60,7 @@ using IntrusiveRefPtrList = IntrusiveList<IntrusiveRefPtrItem, RefPtr<IntrusiveR
TEST_CASE(intrusive_ref_ptr_no_ref_leaks)
{
- auto item = adopt(*new IntrusiveRefPtrItem());
+ auto item = adopt_ref(*new IntrusiveRefPtrItem());
EXPECT_EQ(1u, item->ref_count());
IntrusiveRefPtrList ref_list;
@@ -73,7 +73,7 @@ TEST_CASE(intrusive_ref_ptr_no_ref_leaks)
TEST_CASE(intrusive_ref_ptr_clear)
{
- auto item = adopt(*new IntrusiveRefPtrItem());
+ auto item = adopt_ref(*new IntrusiveRefPtrItem());
EXPECT_EQ(1u, item->ref_count());
IntrusiveRefPtrList ref_list;
@@ -86,7 +86,7 @@ TEST_CASE(intrusive_ref_ptr_clear)
TEST_CASE(intrusive_ref_ptr_destructor)
{
- auto item = adopt(*new IntrusiveRefPtrItem());
+ auto item = adopt_ref(*new IntrusiveRefPtrItem());
EXPECT_EQ(1u, item->ref_count());
{
@@ -107,7 +107,7 @@ using IntrusiveNonnullRefPtrList = IntrusiveList<IntrusiveNonnullRefPtrItem, Non
TEST_CASE(intrusive_nonnull_ref_ptr_intrusive)
{
- auto item = adopt(*new IntrusiveNonnullRefPtrItem());
+ auto item = adopt_ref(*new IntrusiveNonnullRefPtrItem());
EXPECT_EQ(1u, item->ref_count());
IntrusiveNonnullRefPtrList nonnull_ref_list;
diff --git a/AK/Tests/TestNonnullRefPtr.cpp b/AK/Tests/TestNonnullRefPtr.cpp
index 99421223ef..19d43fc2e2 100644
--- a/AK/Tests/TestNonnullRefPtr.cpp
+++ b/AK/Tests/TestNonnullRefPtr.cpp
@@ -15,7 +15,7 @@ struct Object : public RefCounted<Object> {
TEST_CASE(basics)
{
- auto object = adopt(*new Object);
+ auto object = adopt_ref(*new Object);
EXPECT(object.ptr() != nullptr);
EXPECT_EQ(object->ref_count(), 1u);
object->ref();
@@ -33,7 +33,7 @@ TEST_CASE(basics)
TEST_CASE(assign_reference)
{
- auto object = adopt(*new Object);
+ auto object = adopt_ref(*new Object);
EXPECT_EQ(object->ref_count(), 1u);
object = *object;
EXPECT_EQ(object->ref_count(), 1u);
@@ -45,8 +45,8 @@ TEST_CASE(assign_owner_of_self)
RefPtr<Object> parent;
};
- auto parent = adopt(*new Object);
- auto child = adopt(*new Object);
+ auto parent = adopt_ref(*new Object);
+ auto child = adopt_ref(*new Object);
child->parent = move(parent);
child = *child->parent;
@@ -55,7 +55,7 @@ TEST_CASE(assign_owner_of_self)
TEST_CASE(swap_with_self)
{
- auto object = adopt(*new Object);
+ auto object = adopt_ref(*new Object);
swap(object, object);
EXPECT_EQ(object->ref_count(), 1u);
}
diff --git a/AK/Tests/TestRefPtr.cpp b/AK/Tests/TestRefPtr.cpp
index 4d7d0c28b0..f8461183f8 100644
--- a/AK/Tests/TestRefPtr.cpp
+++ b/AK/Tests/TestRefPtr.cpp
@@ -27,7 +27,7 @@ size_t SelfAwareObject::num_destroyed = 0;
TEST_CASE(basics)
{
- RefPtr<Object> object = adopt(*new Object);
+ RefPtr<Object> object = adopt_ref(*new Object);
EXPECT(object.ptr() != nullptr);
EXPECT_EQ(object->ref_count(), 1u);
object->ref();
@@ -45,7 +45,7 @@ TEST_CASE(basics)
TEST_CASE(assign_reference)
{
- RefPtr<Object> object = adopt(*new Object);
+ RefPtr<Object> object = adopt_ref(*new Object);
EXPECT_EQ(object->ref_count(), 1u);
object = *object;
EXPECT_EQ(object->ref_count(), 1u);
@@ -53,7 +53,7 @@ TEST_CASE(assign_reference)
TEST_CASE(assign_ptr)
{
- RefPtr<Object> object = adopt(*new Object);
+ RefPtr<Object> object = adopt_ref(*new Object);
EXPECT_EQ(object->ref_count(), 1u);
object = object.ptr();
EXPECT_EQ(object->ref_count(), 1u);
@@ -61,7 +61,7 @@ TEST_CASE(assign_ptr)
TEST_CASE(copy_move_ref)
{
- RefPtr<Object2> object = adopt(*new Object2);
+ RefPtr<Object2> object = adopt_ref(*new Object2);
EXPECT_EQ(object->ref_count(), 1u);
{
auto object2 = object;
@@ -84,8 +84,8 @@ TEST_CASE(copy_move_ref)
TEST_CASE(swap)
{
- RefPtr<Object> object_a = adopt(*new Object);
- RefPtr<Object> object_b = adopt(*new Object);
+ RefPtr<Object> object_a = adopt_ref(*new Object);
+ RefPtr<Object> object_b = adopt_ref(*new Object);
auto* ptr_a = object_a.ptr();
auto* ptr_b = object_b.ptr();
swap(object_a, object_b);
@@ -97,7 +97,7 @@ TEST_CASE(swap)
TEST_CASE(assign_moved_self)
{
- RefPtr<Object> object = adopt(*new Object);
+ RefPtr<Object> object = adopt_ref(*new Object);
EXPECT_EQ(object->ref_count(), 1u);
#ifdef __clang__
# pragma clang diagnostic push
@@ -112,7 +112,7 @@ TEST_CASE(assign_moved_self)
TEST_CASE(assign_copy_self)
{
- RefPtr<Object> object = adopt(*new Object);
+ RefPtr<Object> object = adopt_ref(*new Object);
EXPECT_EQ(object->ref_count(), 1u);
#ifdef __clang__
@@ -129,7 +129,7 @@ TEST_CASE(assign_copy_self)
TEST_CASE(self_observers)
{
- RefPtr<SelfAwareObject> object = adopt(*new SelfAwareObject);
+ RefPtr<SelfAwareObject> object = adopt_ref(*new SelfAwareObject);
EXPECT_EQ(object->ref_count(), 1u);
EXPECT_EQ(object->m_has_one_ref_left, false);
EXPECT_EQ(SelfAwareObject::num_destroyed, 0u);
diff --git a/AK/Tests/TestWeakPtr.cpp b/AK/Tests/TestWeakPtr.cpp
index a993355bf6..63651204b1 100644
--- a/AK/Tests/TestWeakPtr.cpp
+++ b/AK/Tests/TestWeakPtr.cpp
@@ -34,7 +34,7 @@ TEST_CASE(basic_weak)
WeakPtr<SimpleWeakable> weak2;
{
- auto simple = adopt(*new SimpleWeakable);
+ auto simple = adopt_ref(*new SimpleWeakable);
weak1 = simple;
weak2 = simple;
EXPECT_EQ(weak1.is_null(), false);
@@ -54,7 +54,7 @@ TEST_CASE(weakptr_move)
WeakPtr<SimpleWeakable> weak2;
{
- auto simple = adopt(*new SimpleWeakable);
+ auto simple = adopt_ref(*new SimpleWeakable);
weak1 = simple;
weak2 = move(weak1);
EXPECT_EQ(weak1.is_null(), true);
diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h
index b164fb864a..b89dc480f2 100644
--- a/AK/WeakPtr.h
+++ b/AK/WeakPtr.h
@@ -198,7 +198,7 @@ inline WeakPtr<U> Weakable<T>::make_weak_ptr() const
// There is a small chance that we create a new WeakLink and throw
// it away because another thread beat us to it. But the window is
// pretty small and the overhead isn't terrible.
- m_link.assign_if_null(adopt(*new WeakLink(const_cast<T&>(static_cast<const T&>(*this)))));
+ m_link.assign_if_null(adopt_ref(*new WeakLink(const_cast<T&>(static_cast<const T&>(*this)))));
}
WeakPtr<U> weak_ptr(m_link);
diff --git a/AK/Weakable.h b/AK/Weakable.h
index 4b23f44f80..4ad2a516af 100644
--- a/AK/Weakable.h
+++ b/AK/Weakable.h
@@ -43,7 +43,7 @@ public:
if (!(m_consumers.fetch_add(1u << 1, AK::MemoryOrder::memory_order_acquire) & 1u)) {
T* ptr = (T*)m_ptr.load(AK::MemoryOrder::memory_order_acquire);
if (ptr && ptr->try_ref())
- ref = adopt(*ptr);
+ ref = adopt_ref(*ptr);
}
m_consumers.fetch_sub(1u << 1, AK::MemoryOrder::memory_order_release);
}
diff --git a/Documentation/SmartPointers.md b/Documentation/SmartPointers.md
index 339a3e335b..a6d456e02b 100644
--- a/Documentation/SmartPointers.md
+++ b/Documentation/SmartPointers.md
@@ -42,14 +42,14 @@ Objects can only be held by `RefPtr` if they meet certain criteria. Specifically
To make a class `T` reference-counted, you can simply make it inherit from `RefCounted<T>`. This will add all the necessary pieces to `T`.
-**Note:** When constructing an object that derives from `RefCounted`, the reference count starts out at 1 (since 0 would mean that the object has no owners and should be deleted.) The object must therefore be "adopted" by someone who takes responsibility of that 1. This is done through the global `adopt()` function:
+**Note:** When constructing an object that derives from `RefCounted`, the reference count starts out at 1 (since 0 would mean that the object has no owners and should be deleted.) The object must therefore be "adopted" by someone who takes responsibility of that 1. This is done through the global `adopt_ref()` function:
```cpp
class Bar : public RefCounted<Bar> {
...
};
-RefPtr<Bar> our_object = adopt(*new Bar);
+RefPtr<Bar> our_object = adopt_ref(*new Bar);
RefPtr<Bar> another_owner = our_object;
```
diff --git a/Kernel/Devices/Device.h b/Kernel/Devices/Device.h
index 98e3cfe1fa..1bc751d820 100644
--- a/Kernel/Devices/Device.h
+++ b/Kernel/Devices/Device.h
@@ -51,7 +51,7 @@ public:
template<typename AsyncRequestType, typename... Args>
NonnullRefPtr<AsyncRequestType> make_request(Args&&... args)
{
- auto request = adopt(*new AsyncRequestType(*this, forward<Args>(args)...));
+ auto request = adopt_ref(*new AsyncRequestType(*this, forward<Args>(args)...));
ScopedSpinLock lock(m_requests_lock);
bool was_empty = m_requests.is_empty();
m_requests.append(request);
diff --git a/Kernel/Devices/HID/I8042Controller.cpp b/Kernel/Devices/HID/I8042Controller.cpp
index 9479373f81..c48df8690a 100644
--- a/Kernel/Devices/HID/I8042Controller.cpp
+++ b/Kernel/Devices/HID/I8042Controller.cpp
@@ -14,7 +14,7 @@ namespace Kernel {
UNMAP_AFTER_INIT NonnullRefPtr<I8042Controller> I8042Controller::initialize()
{
- return adopt(*new I8042Controller());
+ return adopt_ref(*new I8042Controller());
}
RefPtr<MouseDevice> I8042Controller::mouse() const
diff --git a/Kernel/Devices/HID/PS2KeyboardDevice.cpp b/Kernel/Devices/HID/PS2KeyboardDevice.cpp
index b61ad69382..9dfe2a772d 100644
--- a/Kernel/Devices/HID/PS2KeyboardDevice.cpp
+++ b/Kernel/Devices/HID/PS2KeyboardDevice.cpp
@@ -85,7 +85,7 @@ void PS2KeyboardDevice::handle_irq(const RegisterState&)
UNMAP_AFTER_INIT RefPtr<PS2KeyboardDevice> PS2KeyboardDevice::try_to_initialize(const I8042Controller& ps2_controller)
{
- auto device = adopt(*new PS2KeyboardDevice(ps2_controller));
+ auto device = adopt_ref(*new PS2KeyboardDevice(ps2_controller));
if (device->initialize())
return device;
return nullptr;
diff --git a/Kernel/Devices/HID/PS2MouseDevice.cpp b/Kernel/Devices/HID/PS2MouseDevice.cpp
index ef1086d6cb..f4947ea209 100644
--- a/Kernel/Devices/HID/PS2MouseDevice.cpp
+++ b/Kernel/Devices/HID/PS2MouseDevice.cpp
@@ -176,7 +176,7 @@ void PS2MouseDevice::set_sample_rate(u8 rate)
UNMAP_AFTER_INIT RefPtr<PS2MouseDevice> PS2MouseDevice::try_to_initialize(const I8042Controller& ps2_controller)
{
- auto device = adopt(*new PS2MouseDevice(ps2_controller));
+ auto device = adopt_ref(*new PS2MouseDevice(ps2_controller));
if (device->initialize())
return device;
return nullptr;
diff --git a/Kernel/Devices/HID/VMWareMouseDevice.cpp b/Kernel/Devices/HID/VMWareMouseDevice.cpp
index 32f498e492..2c54a285cb 100644
--- a/Kernel/Devices/HID/VMWareMouseDevice.cpp
+++ b/Kernel/Devices/HID/VMWareMouseDevice.cpp
@@ -15,7 +15,7 @@ UNMAP_AFTER_INIT RefPtr<VMWareMouseDevice> VMWareMouseDevice::try_to_initialize(
return {};
if (!VMWareBackdoor::the()->vmmouse_is_absolute())
return {};
- auto device = adopt(*new VMWareMouseDevice(ps2_controller));
+ auto device = adopt_ref(*new VMWareMouseDevice(ps2_controller));
if (device->initialize())
return device;
return {};
diff --git a/Kernel/FileSystem/AnonymousFile.h b/Kernel/FileSystem/AnonymousFile.h
index ca3c162bfd..470d5cdf4a 100644
--- a/Kernel/FileSystem/AnonymousFile.h
+++ b/Kernel/FileSystem/AnonymousFile.h
@@ -14,7 +14,7 @@ class AnonymousFile final : public File {
public:
static NonnullRefPtr<AnonymousFile> create(NonnullRefPtr<AnonymousVMObject> vmobject)
{
- return adopt(*new AnonymousFile(move(vmobject)));
+ return adopt_ref(*new AnonymousFile(move(vmobject)));
}
virtual ~AnonymousFile() override;
diff --git a/Kernel/FileSystem/Custody.h b/Kernel/FileSystem/Custody.h
index 9c747f767e..3c18ff692c 100644
--- a/Kernel/FileSystem/Custody.h
+++ b/Kernel/FileSystem/Custody.h
@@ -21,7 +21,7 @@ class Custody : public RefCounted<Custody> {
public:
static NonnullRefPtr<Custody> create(Custody* parent, const StringView& name, Inode& inode, int mount_flags)
{
- return adopt(*new Custody(parent, name, inode, mount_flags));
+ return adopt_ref(*new Custody(parent, name, inode, mount_flags));
}
~Custody();
diff --git a/Kernel/FileSystem/DevFS.cpp b/Kernel/FileSystem/DevFS.cpp
index feaf586d9c..e1503698e8 100644
--- a/Kernel/FileSystem/DevFS.cpp
+++ b/Kernel/FileSystem/DevFS.cpp
@@ -14,11 +14,11 @@ namespace Kernel {
NonnullRefPtr<DevFS> DevFS::create()
{
- return adopt(*new DevFS);
+ return adopt_ref(*new DevFS);
}
DevFS::DevFS()
- : m_root_inode(adopt(*new DevFSRootDirectoryInode(*this)))
+ : m_root_inode(adopt_ref(*new DevFSRootDirectoryInode(*this)))
{
LOCKER(m_lock);
Device::for_each([&](Device& device) {
@@ -32,7 +32,7 @@ DevFS::DevFS()
void DevFS::notify_new_device(Device& device)
{
LOCKER(m_lock);
- auto new_device_inode = adopt(*new DevFSDeviceInode(*this, device));
+ auto new_device_inode = adopt_ref(*new DevFSDeviceInode(*this, device));
m_nodes.append(new_device_inode);
m_root_inode->m_devices.append(new_device_inode);
}
@@ -274,7 +274,7 @@ KResultOr<NonnullRefPtr<Inode>> DevFSRootDirectoryInode::create_child(const Stri
}
if (name != "pts")
return EROFS;
- auto new_directory_inode = adopt(*new DevFSPtsDirectoryInode(m_parent_fs));
+ auto new_directory_inode = adopt_ref(*new DevFSPtsDirectoryInode(m_parent_fs));
m_subfolders.append(new_directory_inode);
m_parent_fs.m_nodes.append(new_directory_inode);
return KResult(KSuccess);
@@ -284,7 +284,7 @@ KResultOr<NonnullRefPtr<Inode>> DevFSRootDirectoryInode::create_child(const Stri
if (link.name() == name)
return EEXIST;
}
- auto new_link_inode = adopt(*new DevFSLinkInode(m_parent_fs, name));
+ auto new_link_inode = adopt_ref(*new DevFSLinkInode(m_parent_fs, name));
m_links.append(new_link_inode);
m_parent_fs.m_nodes.append(new_link_inode);
return new_link_inode;
diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp
index 5f2df3ab8b..1546b3cd3a 100644
--- a/Kernel/FileSystem/DevPtsFS.cpp
+++ b/Kernel/FileSystem/DevPtsFS.cpp
@@ -15,7 +15,7 @@ namespace Kernel {
NonnullRefPtr<DevPtsFS> DevPtsFS::create()
{
- return adopt(*new DevPtsFS);
+ return adopt_ref(*new DevPtsFS);
}
DevPtsFS::DevPtsFS()
@@ -30,7 +30,7 @@ static AK::Singleton<HashTable<unsigned>> s_ptys;
bool DevPtsFS::initialize()
{
- m_root_inode = adopt(*new DevPtsFSInode(*this, 1, nullptr));
+ m_root_inode = adopt_ref(*new DevPtsFSInode(*this, 1, nullptr));
m_root_inode->m_metadata.inode = { fsid(), 1 };
m_root_inode->m_metadata.mode = 0040555;
m_root_inode->m_metadata.uid = 0;
@@ -66,7 +66,7 @@ RefPtr<Inode> DevPtsFS::get_inode(InodeIdentifier inode_id) const
auto* device = Device::get_device(201, pty_index);
VERIFY(device);
- auto inode = adopt(*new DevPtsFSInode(const_cast<DevPtsFS&>(*this), inode_id.index(), static_cast<SlavePTY*>(device)));
+ auto inode = adopt_ref(*new DevPtsFSInode(const_cast<DevPtsFS&>(*this), inode_id.index(), static_cast<SlavePTY*>(device)));
inode->m_metadata.inode = inode_id;
inode->m_metadata.size = 0;
inode->m_metadata.uid = device->uid();
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp
index 745c746a37..1c1eaf5358 100644
--- a/Kernel/FileSystem/Ext2FileSystem.cpp
+++ b/Kernel/FileSystem/Ext2FileSystem.cpp
@@ -55,7 +55,7 @@ static unsigned divide_rounded_up(unsigned a, unsigned b)
NonnullRefPtr<Ext2FS> Ext2FS::create(FileDescription& file_description)
{
- return adopt(*new Ext2FS(file_description));
+ return adopt_ref(*new Ext2FS(file_description));
}
Ext2FS::Ext2FS(FileDescription& file_description)
@@ -797,7 +797,7 @@ RefPtr<Inode> Ext2FS::get_inode(InodeIdentifier inode) const
if (!find_block_containing_inode(inode.index(), block_index, offset))
return {};
- auto new_inode = adopt(*new Ext2FSInode(const_cast<Ext2FS&>(*this), inode.index()));
+ auto new_inode = adopt_ref(*new Ext2FSInode(const_cast<Ext2FS&>(*this), inode.index()));
auto buffer = UserOrKernelBuffer::for_kernel_buffer(reinterpret_cast<u8*>(&new_inode->m_raw_inode));
if (auto result = read_block(block_index, &buffer, sizeof(ext2_inode), offset); result.is_error()) {
// FIXME: Propagate the actual error.
diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp
index 0b5e115494..a190c07f87 100644
--- a/Kernel/FileSystem/FIFO.cpp
+++ b/Kernel/FileSystem/FIFO.cpp
@@ -27,7 +27,7 @@ static int s_next_fifo_id = 1;
NonnullRefPtr<FIFO> FIFO::create(uid_t uid)
{
- return adopt(*new FIFO(uid));
+ return adopt_ref(*new FIFO(uid));
}
KResultOr<NonnullRefPtr<FileDescription>> FIFO::open_direction(FIFO::Direction direction)
diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp
index bfc3db6fd3..70a6be8ead 100644
--- a/Kernel/FileSystem/FileDescription.cpp
+++ b/Kernel/FileSystem/FileDescription.cpp
@@ -25,7 +25,7 @@ namespace Kernel {
KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(Custody& custody)
{
- auto description = adopt(*new FileDescription(InodeFile::create(custody.inode())));
+ auto description = adopt_ref(*new FileDescription(InodeFile::create(custody.inode())));
description->m_custody = custody;
auto result = description->attach();
if (result.is_error()) {
@@ -37,7 +37,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(Custody& custo
KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(File& file)
{
- auto description = adopt(*new FileDescription(file));
+ auto description = adopt_ref(*new FileDescription(file));
auto result = description->attach();
if (result.is_error()) {
dbgln_if(FILEDESCRIPTION_DEBUG, "Failed to create file description for file: {}", result);
diff --git a/Kernel/FileSystem/InodeFile.h b/Kernel/FileSystem/InodeFile.h
index c3937243b9..ddf4d22bb1 100644
--- a/Kernel/FileSystem/InodeFile.h
+++ b/Kernel/FileSystem/InodeFile.h
@@ -16,7 +16,7 @@ class InodeFile final : public File {
public:
static NonnullRefPtr<InodeFile> create(NonnullRefPtr<Inode>&& inode)
{
- return adopt(*new InodeFile(move(inode)));
+ return adopt_ref(*new InodeFile(move(inode)));
}
virtual ~InodeFile() override;
diff --git a/Kernel/FileSystem/InodeWatcher.cpp b/Kernel/FileSystem/InodeWatcher.cpp
index 8e2d7de3af..20baf7d448 100644
--- a/Kernel/FileSystem/InodeWatcher.cpp
+++ b/Kernel/FileSystem/InodeWatcher.cpp
@@ -12,7 +12,7 @@ namespace Kernel {
NonnullRefPtr<InodeWatcher> InodeWatcher::create(Inode& inode)
{
- return adopt(*new InodeWatcher(inode));
+ return adopt_ref(*new InodeWatcher(inode));
}
InodeWatcher::InodeWatcher(Inode& inode)
diff --git a/Kernel/FileSystem/Plan9FileSystem.cpp b/Kernel/FileSystem/Plan9FileSystem.cpp
index 519024c505..d28915515f 100644
--- a/Kernel/FileSystem/Plan9FileSystem.cpp
+++ b/Kernel/FileSystem/Plan9FileSystem.cpp
@@ -11,7 +11,7 @@ namespace Kernel {
NonnullRefPtr<Plan9FS> Plan9FS::create(FileDescription& file_description)
{
- return adopt(*new Plan9FS(file_description));
+ return adopt_ref(*new Plan9FS(file_description));
}
Plan9FS::Plan9FS(FileDescription& file_description)
@@ -597,7 +597,7 @@ KResult Plan9FS::post_message_and_wait_for_a_reply(Message& message)
{
auto request_type = message.type();
auto tag = message.tag();
- auto completion = adopt(*new ReceiveCompletion(tag));
+ auto completion = adopt_ref(*new ReceiveCompletion(tag));
auto result = post_message(message, completion);
if (result.is_error())
return result;
@@ -680,7 +680,7 @@ Plan9FSInode::Plan9FSInode(Plan9FS& fs, u32 fid)
NonnullRefPtr<Plan9FSInode> Plan9FSInode::create(Plan9FS& fs, u32 fid)
{
- return adopt(*new Plan9FSInode(fs, fid));
+ return adopt_ref(*new Plan9FSInode(fs, fid));
}
Plan9FSInode::~Plan9FSInode()
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp
index 8b96f459fe..63a505ad94 100644
--- a/Kernel/FileSystem/ProcFS.cpp
+++ b/Kernel/FileSystem/ProcFS.cpp
@@ -237,7 +237,7 @@ struct ProcFSInodeData : public FileDescriptionData {
NonnullRefPtr<ProcFS> ProcFS::create()
{
- return adopt(*new ProcFS);
+ return adopt_ref(*new ProcFS);
}
ProcFS::~ProcFS()
@@ -1018,10 +1018,10 @@ RefPtr<Inode> ProcFS::get_inode(InodeIdentifier inode_id) const
// and if that fails we cannot return this instance anymore and just
// create a new one.
if (it->value->try_ref())
- return adopt(*it->value);
+ return adopt_ref(*it->value);
// We couldn't ref it, so just create a new one and replace the entry
}
- auto inode = adopt(*new ProcFSInode(const_cast<ProcFS&>(*this), inode_id.index()));
+ auto inode = adopt_ref(*new ProcFSInode(const_cast<ProcFS&>(*this), inode_id.index()));
auto result = m_inodes.set(inode_id.index().value(), inode.ptr());
VERIFY(result == ((it == m_inodes.end()) ? AK::HashSetResult::InsertedNewEntry : AK::HashSetResult::ReplacedExistingEntry));
return inode;
@@ -1677,7 +1677,7 @@ KResult ProcFSInode::chmod(mode_t)
ProcFS::ProcFS()
{
- m_root_inode = adopt(*new ProcFSInode(*this, 1));
+ m_root_inode = adopt_ref(*new ProcFSInode(*this, 1));
m_entries.resize(FI_MaxStaticFileIndex);
m_entries[FI_Root_df] = { "df", FI_Root_df, false, procfs$df };
m_entries[FI_Root_all] = { "all", FI_Root_all, false, procfs$all };
diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h
index b0b9e4b6fa..1b8b1b833b 100644
--- a/Kernel/FileSystem/ProcFS.h
+++ b/Kernel/FileSystem/ProcFS.h
@@ -132,7 +132,7 @@ private:
ProcFSProxyInode(ProcFS&, FileDescription&);
static NonnullRefPtr<ProcFSProxyInode> create(ProcFS& fs, FileDescription& fd)
{
- return adopt(*new ProcFSProxyInode(fs, fd));
+ return adopt_ref(*new ProcFSProxyInode(fs, fd));
}
NonnullRefPtr<FileDescription> m_fd;
diff --git a/Kernel/FileSystem/TmpFS.cpp b/Kernel/FileSystem/TmpFS.cpp
index 7a56b234eb..bc0d874140 100644
--- a/Kernel/FileSystem/TmpFS.cpp
+++ b/Kernel/FileSystem/TmpFS.cpp
@@ -13,7 +13,7 @@ namespace Kernel {
NonnullRefPtr<TmpFS> TmpFS::create()
{
- return adopt(*new TmpFS);
+ return adopt_ref(*new TmpFS);
}
TmpFS::TmpFS()
@@ -86,7 +86,7 @@ TmpFSInode::~TmpFSInode()
NonnullRefPtr<TmpFSInode> TmpFSInode::create(TmpFS& fs, InodeMetadata metadata, InodeIdentifier parent)
{
- auto inode = adopt(*new TmpFSInode(fs, metadata, parent));
+ auto inode = adopt_ref(*new TmpFSInode(fs, metadata, parent));
fs.register_inode(inode);
return inode;
}
diff --git a/Kernel/Interrupts/InterruptManagement.cpp b/Kernel/Interrupts/InterruptManagement.cpp
index 6bcb03a997..2a3a94d4dc 100644
--- a/Kernel/Interrupts/InterruptManagement.cpp
+++ b/Kernel/Interrupts/InterruptManagement.cpp
@@ -125,7 +125,7 @@ UNMAP_AFTER_INIT void InterruptManagement::switch_to_pic_mode()
dmesgln("Interrupts: Switch to Legacy PIC mode");
InterruptDisabler disabler;
m_smp_enabled = false;
- m_interrupt_controllers[0] = adopt(*new PIC());
+ m_interrupt_controllers[0] = adopt_ref(*new PIC());
SpuriousInterruptHandler::initialize(7);
SpuriousInterruptHandler::initialize(15);
for (auto& irq_controller : m_interrupt_controllers) {
@@ -183,7 +183,7 @@ UNMAP_AFTER_INIT void InterruptManagement::locate_apic_data()
int irq_controller_count = 0;
if (madt->flags & PCAT_COMPAT_FLAG) {
- m_interrupt_controllers[0] = adopt(*new PIC());
+ m_interrupt_controllers[0] = adopt_ref(*new PIC());
irq_controller_count++;
}
size_t entry_index = 0;
@@ -195,7 +195,7 @@ UNMAP_AFTER_INIT void InterruptManagement::locate_apic_data()
auto* ioapic_entry = (const ACPI::Structures::MADTEntries::IOAPIC*)madt_entry;
dbgln("IOAPIC found @ MADT entry {}, MMIO Registers @ {}", entry_index, PhysicalAddress(ioapic_entry->ioapic_address));
m_interrupt_controllers.resize(1 + irq_controller_count);
- m_interrupt_controllers[irq_controller_count] = adopt(*new IOAPIC(PhysicalAddress(ioapic_entry->ioapic_address), ioapic_entry->gsi_base));
+ m_interrupt_controllers[irq_controller_count] = adopt_ref(*new IOAPIC(PhysicalAddress(ioapic_entry->ioapic_address), ioapic_entry->gsi_base));
irq_controller_count++;
}
if (madt_entry->type == (u8)ACPI::Structures::MADTEntryType::InterruptSourceOverride) {
diff --git a/Kernel/KBuffer.h b/Kernel/KBuffer.h
index 7d02e9792d..fc76fee6aa 100644
--- a/Kernel/KBuffer.h
+++ b/Kernel/KBuffer.h
@@ -32,7 +32,7 @@ public:
auto region = MM.allocate_kernel_region(page_round_up(size), name, access, strategy);
if (!region)
return nullptr;
- return adopt(*new KBufferImpl(region.release_nonnull(), size, strategy));
+ return adopt_ref(*new KBufferImpl(region.release_nonnull(), size, strategy));
}
static RefPtr<KBufferImpl> try_create_with_bytes(ReadonlyBytes bytes, Region::Access access, const char* name = "KBuffer", AllocationStrategy strategy = AllocationStrategy::Reserve)
@@ -41,7 +41,7 @@ public:
if (!region)
return nullptr;
memcpy(region->vaddr().as_ptr(), bytes.data(), bytes.size());
- return adopt(*new KBufferImpl(region.release_nonnull(), bytes.size(), strategy));
+ return adopt_ref(*new KBufferImpl(region.release_nonnull(), bytes.size(), strategy));
}
static RefPtr<KBufferImpl> create_with_size(size_t size, Region::Access access, const char* name, AllocationStrategy strategy = AllocationStrategy::Reserve)
diff --git a/Kernel/Net/E1000NetworkAdapter.cpp b/Kernel/Net/E1000NetworkAdapter.cpp
index 99119f5d9b..241c6436d2 100644
--- a/Kernel/Net/E1000NetworkAdapter.cpp
+++ b/Kernel/Net/E1000NetworkAdapter.cpp
@@ -165,7 +165,7 @@ UNMAP_AFTER_INIT void E1000NetworkAdapter::detect()
if (!is_valid_device_id(id.device_id))
return;
u8 irq = PCI::get_interrupt_line(address);
- [[maybe_unused]] auto& unused = adopt(*new E1000NetworkAdapter(address, irq)).leak_ref();
+ [[maybe_unused]] auto& unused = adopt_ref(*new E1000NetworkAdapter(address, irq)).leak_ref();
});
}
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp
index e49c6c1a28..3063ec1e3e 100644
--- a/Kernel/Net/IPv4Socket.cpp
+++ b/Kernel/Net/IPv4Socket.cpp
@@ -41,7 +41,7 @@ KResultOr<NonnullRefPtr<Socket>> IPv4Socket::create(int type, int protocol)
if (type == SOCK_DGRAM)
return UDPSocket::create(protocol);
if (type == SOCK_RAW)
- return adopt(*new IPv4Socket(type, protocol));
+ return adopt_ref(*new IPv4Socket(type, protocol));
return EINVAL;
}
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp
index 4d4ac372b6..6a73450b92 100644
--- a/Kernel/Net/LocalSocket.cpp
+++ b/Kernel/Net/LocalSocket.cpp
@@ -33,7 +33,7 @@ void LocalSocket::for_each(Function<void(const LocalSocket&)> callback)
KResultOr<NonnullRefPtr<Socket>> LocalSocket::create(int type)
{
- return adopt(*new LocalSocket(type));
+ return adopt_ref(*new LocalSocket(type));
}
LocalSocket::LocalSocket(int type)
diff --git a/Kernel/Net/NE2000NetworkAdapter.cpp b/Kernel/Net/NE2000NetworkAdapter.cpp
index 0954f0da69..384a5987f8 100644
--- a/Kernel/Net/NE2000NetworkAdapter.cpp
+++ b/Kernel/Net/NE2000NetworkAdapter.cpp
@@ -158,7 +158,7 @@ UNMAP_AFTER_INIT void NE2000NetworkAdapter::detect()
if (!ne2k_ids.span().contains_slow(id))
return;
u8 irq = PCI::get_interrupt_line(address);
- [[maybe_unused]] auto& unused = adopt(*new NE2000NetworkAdapter(address, irq)).leak_ref();
+ [[maybe_unused]] auto& unused = adopt_ref(*new NE2000NetworkAdapter(address, irq)).leak_ref();
});
}
diff --git a/Kernel/Net/RTL8139NetworkAdapter.cpp b/Kernel/Net/RTL8139NetworkAdapter.cpp
index 0228447ac1..2a193cec8d 100644
--- a/Kernel/Net/RTL8139NetworkAdapter.cpp
+++ b/Kernel/Net/RTL8139NetworkAdapter.cpp
@@ -114,7 +114,7 @@ UNMAP_AFTER_INIT void RTL8139NetworkAdapter::detect()
if (id != rtl8139_id)
return;
u8 irq = PCI::get_interrupt_line(address);
- [[maybe_unused]] auto& unused = adopt(*new RTL8139NetworkAdapter(address, irq)).leak_ref();
+ [[maybe_unused]] auto& unused = adopt_ref(*new RTL8139NetworkAdapter(address, irq)).leak_ref();
});
}
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp
index 94f4a30def..d7608cd5f5 100644
--- a/Kernel/Net/TCPSocket.cpp
+++ b/Kernel/Net/TCPSocket.cpp
@@ -139,7 +139,7 @@ TCPSocket::~TCPSocket()
NonnullRefPtr<TCPSocket> TCPSocket::create(int protocol)
{
- return adopt(*new TCPSocket(protocol));
+ return adopt_ref(*new TCPSocket(protocol));
}
KResultOr<size_t> TCPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, [[maybe_unused]] int flags)
diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp
index 06ea0b6b80..309823d626 100644
--- a/Kernel/Net/UDPSocket.cpp
+++ b/Kernel/Net/UDPSocket.cpp
@@ -56,7 +56,7 @@ UDPSocket::~UDPSocket()
NonnullRefPtr<UDPSocket> UDPSocket::create(int protocol)
{
- return adopt(*new UDPSocket(protocol));
+ return adopt_ref(*new UDPSocket(protocol));
}
KResultOr<size_t> UDPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, [[maybe_unused]] int flags)
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index e451ff8969..259f931d11 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -143,7 +143,7 @@ RefPtr<Process> Process::create_user_process(RefPtr<Thread>& first_thread, const
if (!cwd)
cwd = VFS::the().root_custody();
- auto process = adopt(*new Process(first_thread, parts.take_last(), uid, gid, parent_pid, false, move(cwd), nullptr, tty));
+ auto process = adopt_ref(*new Process(first_thread, parts.take_last(), uid, gid, parent_pid, false, move(cwd), nullptr, tty));
if (!first_thread)
return {};
process->m_fds.resize(m_max_open_file_descriptors);
@@ -171,7 +171,7 @@ RefPtr<Process> Process::create_user_process(RefPtr<Thread>& first_thread, const
RefPtr<Process> Process::create_kernel_process(RefPtr<Thread>& first_thread, String&& name, void (*entry)(void*), void* entry_data, u32 affinity)
{
- auto process = adopt(*new Process(first_thread, move(name), (uid_t)0, (gid_t)0, ProcessID(0), true));
+ auto process = adopt_ref(*new Process(first_thread, move(name), (uid_t)0, (gid_t)0, ProcessID(0), true));
if (!first_thread)
return {};
first_thread->tss().eip = (FlatPtr)entry;
diff --git a/Kernel/ProcessGroup.cpp b/Kernel/ProcessGroup.cpp
index 9039ab4251..938b41152f 100644
--- a/Kernel/ProcessGroup.cpp
+++ b/Kernel/ProcessGroup.cpp
@@ -19,7 +19,7 @@ ProcessGroup::~ProcessGroup()
NonnullRefPtr<ProcessGroup> ProcessGroup::create(ProcessGroupID pgid)
{
- auto process_group = adopt(*new ProcessGroup(pgid));
+ auto process_group = adopt_ref(*new ProcessGroup(pgid));
{
ScopedSpinLock lock(g_process_groups_lock);
g_process_groups->prepend(process_group);
diff --git a/Kernel/Storage/AHCIController.cpp b/Kernel/Storage/AHCIController.cpp
index 084963f650..50413ca6c4 100644
--- a/Kernel/Storage/AHCIController.cpp
+++ b/Kernel/Storage/AHCIController.cpp
@@ -17,7 +17,7 @@ namespace Kernel {
NonnullRefPtr<AHCIController> AHCIController::initialize(PCI::Address address)
{
- return adopt(*new AHCIController(address));
+ return adopt_ref(*new AHCIController(address));
}
bool AHCIController::reset()
diff --git a/Kernel/Storage/AHCIPort.cpp b/Kernel/Storage/AHCIPort.cpp
index e4080aad26..30e31a64c0 100644
--- a/Kernel/Storage/AHCIPort.cpp
+++ b/Kernel/Storage/AHCIPort.cpp
@@ -18,7 +18,7 @@ namespace Kernel {
NonnullRefPtr<AHCIPort::ScatterList> AHCIPort::ScatterList::create(AsyncBlockDeviceRequest& request, NonnullRefPtrVector<PhysicalPage> allocated_pages, size_t device_block_size)
{
- return adopt(*new ScatterList(request, allocated_pages, device_block_size));
+ return adopt_ref(*new ScatterList(request, allocated_pages, device_block_size));
}
AHCIPort::ScatterList::ScatterList(AsyncBlockDeviceRequest& request, NonnullRefPtrVector<PhysicalPage> allocated_pages, size_t device_block_size)
@@ -29,7 +29,7 @@ AHCIPort::ScatterList::ScatterList(AsyncBlockDeviceRequest& request, NonnullRefP
NonnullRefPtr<AHCIPort> AHCIPort::create(const AHCIPortHandler& handler, volatile AHCI::PortRegisters& registers, u32 port_index)
{
- return adopt(*new AHCIPort(handler, registers, port_index));
+ return adopt_ref(*new AHCIPort(handler, registers, port_index));
}
AHCIPort::AHCIPort(const AHCIPortHandler& handler, volatile AHCI::PortRegisters& registers, u32 port_index)
diff --git a/Kernel/Storage/AHCIPortHandler.cpp b/Kernel/Storage/AHCIPortHandler.cpp
index f3dc941cd9..51ceb329e4 100644
--- a/Kernel/Storage/AHCIPortHandler.cpp
+++ b/Kernel/Storage/AHCIPortHandler.cpp
@@ -11,7 +11,7 @@ namespace Kernel {
NonnullRefPtr<AHCIPortHandler> AHCIPortHandler::create(AHCIController& controller, u8 irq, AHCI::MaskedBitField taken_ports)
{
- return adopt(*new AHCIPortHandler(controller, irq, taken_ports));
+ return adopt_ref(*new AHCIPortHandler(controller, irq, taken_ports));
}
AHCIPortHandler::AHCIPortHandler(AHCIController& controller, u8 irq, AHCI::MaskedBitField taken_ports)
diff --git a/Kernel/Storage/BMIDEChannel.cpp b/Kernel/Storage/BMIDEChannel.cpp
index 04fd190d68..62c3654700 100644
--- a/Kernel/Storage/BMIDEChannel.cpp
+++ b/Kernel/Storage/BMIDEChannel.cpp
@@ -13,12 +13,12 @@ namespace Kernel {
UNMAP_AFTER_INIT NonnullRefPtr<BMIDEChannel> BMIDEChannel::create(const IDEController& ide_controller, IDEChannel::IOAddressGroup io_group, IDEChannel::ChannelType type)
{
- return adopt(*new BMIDEChannel(ide_controller, io_group, type));
+ return adopt_ref(*new BMIDEChannel(ide_controller, io_group, type));
}
UNMAP_AFTER_INIT NonnullRefPtr<BMIDEChannel> BMIDEChannel::create(const IDEController& ide_controller, u8 irq, IDEChannel::IOAddressGroup io_group, IDEChannel::ChannelType type)
{
- return adopt(*new BMIDEChannel(ide_controller, irq, io_group, type));
+ return adopt_ref(*new BMIDEChannel(ide_controller, irq, io_group, type));
}
UNMAP_AFTER_INIT BMIDEChannel::BMIDEChannel(const IDEController& controller, IDEChannel::IOAddressGroup io_group, IDEChannel::ChannelType type)
diff --git a/Kernel/Storage/IDEChannel.cpp b/Kernel/Storage/IDEChannel.cpp
index ad9eb13ee1..7c592007b5 100644
--- a/Kernel/Storage/IDEChannel.cpp
+++ b/Kernel/Storage/IDEChannel.cpp
@@ -26,12 +26,12 @@ namespace Kernel {
UNMAP_AFTER_INIT NonnullRefPtr<IDEChannel> IDEChannel::create(const IDEController& controller, IOAddressGroup io_group, ChannelType type)
{
- return adopt(*new IDEChannel(controller, io_group, type));
+ return adopt_ref(*new IDEChannel(controller, io_group, type));
}
UNMAP_AFTER_INIT NonnullRefPtr<IDEChannel> IDEChannel::create(const IDEController& controller, u8 irq, IOAddressGroup io_group, ChannelType type)
{
- return adopt(*new IDEChannel(controller, irq, io_group, type));
+ return adopt_ref(*new IDEChannel(controller, irq, io_group, type));
}
RefPtr<StorageDevice> IDEChannel::master_device() const
diff --git a/Kernel/Storage/IDEController.cpp b/Kernel/Storage/IDEController.cpp
index 6111607dd7..274efc4b88 100644
--- a/Kernel/Storage/IDEController.cpp
+++ b/Kernel/Storage/IDEController.cpp
@@ -16,7 +16,7 @@ namespace Kernel {
UNMAP_AFTER_INIT NonnullRefPtr<IDEController> IDEController::initialize(PCI::Address address, bool force_pio)
{
- return adopt(*new IDEController(address, force_pio));
+ return adopt_ref(*new IDEController(address, force_pio));
}
bool IDEController::reset()
diff --git a/Kernel/Storage/PATADiskDevice.cpp b/Kernel/Storage/PATADiskDevice.cpp
index 896367091f..294c1cf30f 100644
--- a/Kernel/Storage/PATADiskDevice.cpp
+++ b/Kernel/Storage/PATADiskDevice.cpp
@@ -15,7 +15,7 @@ namespace Kernel {
UNMAP_AFTER_INIT NonnullRefPtr<PATADiskDevice> PATADiskDevice::create(const IDEController& controller, IDEChannel& channel, DriveType type, InterfaceType interface_type, u16 capabilities, u64 max_addressable_block)
{
- return adopt(*new PATADiskDevice(controller, channel, type, interface_type, capabilities, max_addressable_block));
+ return adopt_ref(*new PATADiskDevice(controller, channel, type, interface_type, capabilities, max_addressable_block));
}
UNMAP_AFTER_INIT PATADiskDevice::PATADiskDevice(const IDEController& controller, IDEChannel& channel, DriveType type, InterfaceType interface_type, u16 capabilities, u64 max_addressable_block)
diff --git a/Kernel/Storage/Partition/DiskPartition.cpp b/Kernel/Storage/Partition/DiskPartition.cpp
index 4e908a2c3c..9d4dfbc1f4 100644
--- a/Kernel/Storage/Partition/DiskPartition.cpp
+++ b/Kernel/Storage/Partition/DiskPartition.cpp
@@ -12,7 +12,7 @@ namespace Kernel {
NonnullRefPtr<DiskPartition> DiskPartition::create(BlockDevice& device, unsigned minor_number, DiskPartitionMetadata metadata)
{
- return adopt(*new DiskPartition(device, minor_number, metadata));
+ return adopt_ref(*new DiskPartition(device, minor_number, metadata));
}
DiskPartition::DiskPartition(BlockDevice& device, unsigned minor_number, DiskPartitionMetadata metadata)
diff --git a/Kernel/Storage/RamdiskController.cpp b/Kernel/Storage/RamdiskController.cpp
index ff3de9c09e..2c0e04c035 100644
--- a/Kernel/Storage/RamdiskController.cpp
+++ b/Kernel/Storage/RamdiskController.cpp
@@ -13,7 +13,7 @@ namespace Kernel {
NonnullRefPtr<RamdiskController> RamdiskController::initialize()
{
- return adopt(*new RamdiskController());
+ return adopt_ref(*new RamdiskController());
}
bool RamdiskController::reset()
diff --git a/Kernel/Storage/RamdiskDevice.cpp b/Kernel/Storage/RamdiskDevice.cpp
index 0e7d90a1fa..87fd37144e 100644
--- a/Kernel/Storage/RamdiskDevice.cpp
+++ b/Kernel/Storage/RamdiskDevice.cpp
@@ -14,7 +14,7 @@ namespace Kernel {
NonnullRefPtr<RamdiskDevice> RamdiskDevice::create(const RamdiskController& controller, NonnullOwnPtr<Region>&& region, int major, int minor)
{
- return adopt(*new RamdiskDevice(controller, move(region), major, minor));
+ return adopt_ref(*new RamdiskDevice(controller, move(region), major, minor));
}
RamdiskDevice::RamdiskDevice(const RamdiskController& controller, NonnullOwnPtr<Region>&& region, int major, int minor)
diff --git a/Kernel/Storage/SATADiskDevice.cpp b/Kernel/Storage/SATADiskDevice.cpp
index 35ba3ef61c..4d0677dc61 100644
--- a/Kernel/Storage/SATADiskDevice.cpp
+++ b/Kernel/Storage/SATADiskDevice.cpp
@@ -15,7 +15,7 @@ namespace Kernel {
NonnullRefPtr<SATADiskDevice> SATADiskDevice::create(const AHCIController& controller, const AHCIPort& port, size_t sector_size, u64 max_addressable_block)
{
- return adopt(*new SATADiskDevice(controller, port, sector_size, max_addressable_block));
+ return adopt_ref(*new SATADiskDevice(controller, port, sector_size, max_addressable_block));
}
SATADiskDevice::SATADiskDevice(const AHCIController& controller, const AHCIPort& port, size_t sector_size, u64 max_addressable_block)
diff --git a/Kernel/Syscalls/fork.cpp b/Kernel/Syscalls/fork.cpp
index 37d6b5796d..0caf62df5c 100644
--- a/Kernel/Syscalls/fork.cpp
+++ b/Kernel/Syscalls/fork.cpp
@@ -16,7 +16,7 @@ KResultOr<pid_t> Process::sys$fork(RegisterState& regs)
{
REQUIRE_PROMISE(proc);
RefPtr<Thread> child_first_thread;
- auto child = adopt(*new Process(child_first_thread, m_name, uid(), gid(), pid(), m_is_kernel_process, m_cwd, m_executable, m_tty, this));
+ auto child = adopt_ref(*new Process(child_first_thread, m_name, uid(), gid(), pid(), m_is_kernel_process, m_cwd, m_executable, m_tty, this));
if (!child_first_thread)
return ENOMEM;
child->m_root_directory = m_root_directory;
diff --git a/Kernel/Syscalls/futex.cpp b/Kernel/Syscalls/futex.cpp
index 193e63999c..89a801d073 100644
--- a/Kernel/Syscalls/futex.cpp
+++ b/Kernel/Syscalls/futex.cpp
@@ -167,7 +167,7 @@ KResultOr<int> Process::sys$futex(Userspace<const Syscall::SC_futex_params*> use
if (it != queues->end())
return it->value;
if (create_if_not_found) {
- auto futex_queue = adopt(*new FutexQueue(user_address_or_offset, vmobject));
+ auto futex_queue = adopt_ref(*new FutexQueue(user_address_or_offset, vmobject));
auto result = queues->set(user_address_or_offset, futex_queue);
VERIFY(result == AK::HashSetResult::InsertedNewEntry);
return futex_queue;
diff --git a/Kernel/TTY/MasterPTY.cpp b/Kernel/TTY/MasterPTY.cpp
index bc83242d7e..42a80baf58 100644
--- a/Kernel/TTY/MasterPTY.cpp
+++ b/Kernel/TTY/MasterPTY.cpp
@@ -17,7 +17,7 @@ namespace Kernel {
MasterPTY::MasterPTY(unsigned index)
: CharacterDevice(200, index)
- , m_slave(adopt(*new SlavePTY(*this, index)))
+ , m_slave(adopt_ref(*new SlavePTY(*this, index)))
, m_index(index)
{
m_pts_name = String::formatted("/dev/pts/{}", m_index);
diff --git a/Kernel/TTY/PTYMultiplexer.cpp b/Kernel/TTY/PTYMultiplexer.cpp
index eb5cc0bb9b..1df690cc5c 100644
--- a/Kernel/TTY/PTYMultiplexer.cpp
+++ b/Kernel/TTY/PTYMultiplexer.cpp
@@ -40,7 +40,7 @@ KResultOr<NonnullRefPtr<FileDescription>> PTYMultiplexer::open(int options)
if (m_freelist.is_empty())
return EBUSY;
auto master_index = m_freelist.take_last();
- auto master = adopt(*new MasterPTY(master_index));
+ auto master = adopt_ref(*new MasterPTY(master_index));
dbgln_if(PTMX_DEBUG, "PTYMultiplexer::open: Vending master {}", master->index());
auto description = FileDescription::create(move(master));
if (!description.is_error()) {
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index fd70f82b24..de51daedf6 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -41,7 +41,7 @@ KResultOr<NonnullRefPtr<Thread>> Thread::try_create(NonnullRefPtr<Process> proce
if (!kernel_stack_region)
return ENOMEM;
kernel_stack_region->set_stack(true);
- return adopt(*new Thread(move(process), kernel_stack_region.release_nonnull()));
+ return adopt_ref(*new Thread(move(process), kernel_stack_region.release_nonnull()));
}
Thread::Thread(NonnullRefPtr<Process> process, NonnullOwnPtr<Region> kernel_stack_region)
diff --git a/Kernel/Time/APICTimer.cpp b/Kernel/Time/APICTimer.cpp
index b89391bd4d..a2543aa0ca 100644
--- a/Kernel/Time/APICTimer.cpp
+++ b/Kernel/Time/APICTimer.cpp
@@ -19,7 +19,7 @@ namespace Kernel {
UNMAP_AFTER_INIT APICTimer* APICTimer::initialize(u8 interrupt_number, HardwareTimerBase& calibration_source)
{
- auto timer = adopt(*new APICTimer(interrupt_number, nullptr));
+ auto timer = adopt_ref(*new APICTimer(interrupt_number, nullptr));
timer->register_interrupt_handler();
if (!timer->calibrate(calibration_source)) {
return nullptr;
diff --git a/Kernel/Time/HPETComparator.cpp b/Kernel/Time/HPETComparator.cpp
index 7d48821fdf..7ba16bef36 100644
--- a/Kernel/Time/HPETComparator.cpp
+++ b/Kernel/Time/HPETComparator.cpp
@@ -13,7 +13,7 @@ namespace Kernel {
UNMAP_AFTER_INIT NonnullRefPtr<HPETComparator> HPETComparator::create(u8 number, u8 irq, bool periodic_capable)
{
- auto timer = adopt(*new HPETComparator(number, irq, periodic_capable));
+ auto timer = adopt_ref(*new HPETComparator(number, irq, periodic_capable));
timer->register_interrupt_handler();
return timer;
}
diff --git a/Kernel/Time/PIT.cpp b/Kernel/Time/PIT.cpp
index 69f9636414..8e2f916998 100644
--- a/Kernel/Time/PIT.cpp
+++ b/Kernel/Time/PIT.cpp
@@ -17,7 +17,7 @@ namespace Kernel {
UNMAP_AFTER_INIT NonnullRefPtr<PIT> PIT::initialize(Function<void(const RegisterState&)> callback)
{
- return adopt(*new PIT(move(callback)));
+ return adopt_ref(*new PIT(move(callback)));
}
inline static void reset_countdown(u16 timer_reload)
diff --git a/Kernel/Time/RTC.cpp b/Kernel/Time/RTC.cpp
index 3d6958884c..31c1f09e02 100644
--- a/Kernel/Time/RTC.cpp
+++ b/Kernel/Time/RTC.cpp
@@ -16,7 +16,7 @@ namespace Kernel {
NonnullRefPtr<RealTimeClock> RealTimeClock::create(Function<void(const RegisterState&)> callback)
{
- return adopt(*new RealTimeClock(move(callback)));
+ return adopt_ref(*new RealTimeClock(move(callback)));
}
RealTimeClock::RealTimeClock(Function<void(const RegisterState&)> callback)
: HardwareTimer(IRQ_TIMER, move(callback))
diff --git a/Kernel/TimerQueue.cpp b/Kernel/TimerQueue.cpp
index 85ae642eb7..b7dd9efc45 100644
--- a/Kernel/TimerQueue.cpp
+++ b/Kernel/TimerQueue.cpp
@@ -67,7 +67,7 @@ RefPtr<Timer> TimerQueue::add_timer_without_id(clockid_t clock_id, const Time& d
// *must* be a RefPtr<Timer>. Otherwise calling cancel_timer() could
// inadvertently cancel another timer that has been created between
// returning from the timer handler and a call to cancel_timer().
- auto timer = adopt(*new Timer(clock_id, deadline, move(callback)));
+ auto timer = adopt_ref(*new Timer(clock_id, deadline, move(callback)));
ScopedSpinLock lock(g_timerqueue_lock);
timer->m_id = 0; // Don't generate a timer id
@@ -119,7 +119,7 @@ TimerId TimerQueue::add_timer(clockid_t clock_id, const Time& deadline, Function
{
auto expires = TimeManagement::the().current_time(clock_id).value();
expires = expires + deadline;
- return add_timer(adopt(*new Timer(clock_id, expires, move(callback))));
+ return add_timer(adopt_ref(*new Timer(clock_id, expires, move(callback))));
}
bool TimerQueue::cancel_timer(TimerId id)
diff --git a/Kernel/VM/AnonymousVMObject.cpp b/Kernel/VM/AnonymousVMObject.cpp
index 2863e47cb5..7d9b577832 100644
--- a/Kernel/VM/AnonymousVMObject.cpp
+++ b/Kernel/VM/AnonymousVMObject.cpp
@@ -41,13 +41,13 @@ RefPtr<VMObject> AnonymousVMObject::clone()
// one would keep the one it still has. This ensures that the original
// one and this one, as well as the clone have sufficient resources
// to cow all pages as needed
- m_shared_committed_cow_pages = adopt(*new CommittedCowPages(need_cow_pages));
+ m_shared_committed_cow_pages = adopt_ref(*new CommittedCowPages(need_cow_pages));
// Both original and clone become COW. So create a COW map for ourselves
// or reset all pages to be copied again if we were previously cloned
ensure_or_reset_cow_map();
- return adopt(*new AnonymousVMObject(*this));
+ return adopt_ref(*new AnonymousVMObject(*this));
}
RefPtr<AnonymousVMObject> AnonymousVMObject::create_with_size(size_t size, AllocationStrategy commit)
@@ -57,17 +57,17 @@ RefPtr<AnonymousVMObject> AnonymousVMObject::create_with_size(size_t size, Alloc
if (!MM.commit_user_physical_pages(ceil_div(size, static_cast<size_t>(PAGE_SIZE))))
return {};
}
- return adopt(*new AnonymousVMObject(size, commit));
+ return adopt_ref(*new AnonymousVMObject(size, commit));
}
NonnullRefPtr<AnonymousVMObject> AnonymousVMObject::create_with_physical_pages(NonnullRefPtrVector<PhysicalPage> physical_pages)
{
- return adopt(*new AnonymousVMObject(physical_pages));
+ return adopt_ref(*new AnonymousVMObject(physical_pages));
}
NonnullRefPtr<AnonymousVMObject> AnonymousVMObject::create_with_physical_page(PhysicalPage& page)
{
- return adopt(*new AnonymousVMObject(page));
+ return adopt_ref(*new AnonymousVMObject(page));
}
RefPtr<AnonymousVMObject> AnonymousVMObject::create_for_physical_range(PhysicalAddress paddr, size_t size)
@@ -76,7 +76,7 @@ RefPtr<AnonymousVMObject> AnonymousVMObject::create_for_physical_range(PhysicalA
dbgln("Shenanigans! create_for_physical_range({}, {}) would wrap around", paddr, size);
return nullptr;
}
- return adopt(*new AnonymousVMObject(paddr, size));
+ return adopt_ref(*new AnonymousVMObject(paddr, size));
}
AnonymousVMObject::AnonymousVMObject(size_t size, AllocationStrategy strategy)
diff --git a/Kernel/VM/ContiguousVMObject.cpp b/Kernel/VM/ContiguousVMObject.cpp
index 243314c87e..2550cec829 100644
--- a/Kernel/VM/ContiguousVMObject.cpp
+++ b/Kernel/VM/ContiguousVMObject.cpp
@@ -12,7 +12,7 @@ namespace Kernel {
NonnullRefPtr<ContiguousVMObject> ContiguousVMObject::create_with_size(size_t size, size_t physical_alignment)
{
- return adopt(*new ContiguousVMObject(size, physical_alignment));
+ return adopt_ref(*new ContiguousVMObject(size, physical_alignment));
}
ContiguousVMObject::ContiguousVMObject(size_t size, size_t physical_alignment)
diff --git a/Kernel/VM/PageDirectory.h b/Kernel/VM/PageDirectory.h
index d965d883ec..6f1a5bfbe5 100644
--- a/Kernel/VM/PageDirectory.h
+++ b/Kernel/VM/PageDirectory.h
@@ -22,12 +22,12 @@ class PageDirectory : public RefCounted<PageDirectory> {
public:
static RefPtr<PageDirectory> create_for_userspace(const RangeAllocator* parent_range_allocator = nullptr)
{
- auto page_directory = adopt(*new PageDirectory(parent_range_allocator));
+ auto page_directory = adopt_ref(*new PageDirectory(parent_range_allocator));
if (!page_directory->is_valid())
return {};
return page_directory;
}
- static NonnullRefPtr<PageDirectory> create_kernel_page_directory() { return adopt(*new PageDirectory); }
+ static NonnullRefPtr<PageDirectory> create_kernel_page_directory() { return adopt_ref(*new PageDirectory); }
static RefPtr<PageDirectory> find_by_cr3(u32);
~PageDirectory();
diff --git a/Kernel/VM/PhysicalPage.cpp b/Kernel/VM/PhysicalPage.cpp
index ed17fbc025..082c636d1d 100644
--- a/Kernel/VM/PhysicalPage.cpp
+++ b/Kernel/VM/PhysicalPage.cpp
@@ -12,7 +12,7 @@ namespace Kernel {
NonnullRefPtr<PhysicalPage> PhysicalPage::create(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist)
{
- return adopt(*new PhysicalPage(paddr, supervisor, may_return_to_freelist));
+ return adopt_ref(*new PhysicalPage(paddr, supervisor, may_return_to_freelist));
}
PhysicalPage::PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist)
diff --git a/Kernel/VM/PhysicalRegion.cpp b/Kernel/VM/PhysicalRegion.cpp
index c9ffa7f498..420442bf41 100644
--- a/Kernel/VM/PhysicalRegion.cpp
+++ b/Kernel/VM/PhysicalRegion.cpp
@@ -17,7 +17,7 @@ namespace Kernel {
NonnullRefPtr<PhysicalRegion> PhysicalRegion::create(PhysicalAddress lower, PhysicalAddress upper)
{
- return adopt(*new PhysicalRegion(lower, upper));
+ return adopt_ref(*new PhysicalRegion(lower, upper));
}
PhysicalRegion::PhysicalRegion(PhysicalAddress lower, PhysicalAddress upper)
diff --git a/Kernel/VM/PrivateInodeVMObject.cpp b/Kernel/VM/PrivateInodeVMObject.cpp
index 9e92035ca9..18aa0fb21f 100644
--- a/Kernel/VM/PrivateInodeVMObject.cpp
+++ b/Kernel/VM/PrivateInodeVMObject.cpp
@@ -11,12 +11,12 @@ namespace Kernel {
NonnullRefPtr<PrivateInodeVMObject> PrivateInodeVMObject::create_with_inode(Inode& inode)
{
- return adopt(*new PrivateInodeVMObject(inode, inode.size()));
+ return adopt_ref(*new PrivateInodeVMObject(inode, inode.size()));
}
RefPtr<VMObject> PrivateInodeVMObject::clone()
{
- return adopt(*new PrivateInodeVMObject(*this));
+ return adopt_ref(*new PrivateInodeVMObject(*this));
}
PrivateInodeVMObject::PrivateInodeVMObject(Inode& inode, size_t size)
diff --git a/Kernel/VM/SharedInodeVMObject.cpp b/Kernel/VM/SharedInodeVMObject.cpp
index 2114bbbdeb..91e7873fb7 100644
--- a/Kernel/VM/SharedInodeVMObject.cpp
+++ b/Kernel/VM/SharedInodeVMObject.cpp
@@ -14,14 +14,14 @@ NonnullRefPtr<SharedInodeVMObject> SharedInodeVMObject::create_with_inode(Inode&
size_t size = inode.size();
if (auto shared_vmobject = inode.shared_vmobject())
return shared_vmobject.release_nonnull();
- auto vmobject = adopt(*new SharedInodeVMObject(inode, size));
+ auto vmobject = adopt_ref(*new SharedInodeVMObject(inode, size));
vmobject->inode().set_shared_vmobject(*vmobject);
return vmobject;
}
RefPtr<VMObject> SharedInodeVMObject::clone()
{
- return adopt(*new SharedInodeVMObject(*this));
+ return adopt_ref(*new SharedInodeVMObject(*this));
}
SharedInodeVMObject::SharedInodeVMObject(Inode& inode, size_t size)
diff --git a/Kernel/VirtIO/VirtIO.cpp b/Kernel/VirtIO/VirtIO.cpp
index 4ef665f7f4..73e1f99d36 100644
--- a/Kernel/VirtIO/VirtIO.cpp
+++ b/Kernel/VirtIO/VirtIO.cpp
@@ -22,11 +22,11 @@ void VirtIO::detect()
return;
switch (id.device_id) {
case VIRTIO_CONSOLE_PCI_DEVICE_ID: {
- [[maybe_unused]] auto& unused = adopt(*new VirtIOConsole(address)).leak_ref();
+ [[maybe_unused]] auto& unused = adopt_ref(*new VirtIOConsole(address)).leak_ref();
break;
}
case VIRTIO_ENTROPY_PCI_DEVICE_ID: {
- [[maybe_unused]] auto& unused = adopt(*new VirtIORNG(address)).leak_ref();
+ [[maybe_unused]] auto& unused = adopt_ref(*new VirtIORNG(address)).leak_ref();
break;
}
default:
diff --git a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp
index a6936b6924..c667c1c334 100644
--- a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp
+++ b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp
@@ -10,7 +10,7 @@
NonnullRefPtr<ClipboardHistoryModel> ClipboardHistoryModel::create()
{
- return adopt(*new ClipboardHistoryModel());
+ return adopt_ref(*new ClipboardHistoryModel());
}
ClipboardHistoryModel::~ClipboardHistoryModel()
diff --git a/Userland/Applications/Browser/ConsoleWidget.cpp b/Userland/Applications/Browser/ConsoleWidget.cpp
index 69b32ca309..1b69c858f5 100644
--- a/Userland/Applications/Browser/ConsoleWidget.cpp
+++ b/Userland/Applications/Browser/ConsoleWidget.cpp
@@ -30,7 +30,7 @@ ConsoleWidget::ConsoleWidget()
set_fill_with_background_color(true);
auto base_document = Web::DOM::Document::create();
- base_document->append_child(adopt(*new Web::DOM::DocumentType(base_document)));
+ base_document->append_child(adopt_ref(*new Web::DOM::DocumentType(base_document)));
auto html_element = base_document->create_element("html");
base_document->append_child(html_element);
auto head_element = base_document->create_element("head");
diff --git a/Userland/Applications/Calendar/AddEventDialog.h b/Userland/Applications/Calendar/AddEventDialog.h
index 5998a402ab..c400476764 100644
--- a/Userland/Applications/Calendar/AddEventDialog.h
+++ b/Userland/Applications/Calendar/AddEventDialog.h
@@ -32,7 +32,7 @@ private:
__Count,
};
- static NonnullRefPtr<MonthListModel> create() { return adopt(*new MonthListModel); }
+ static NonnullRefPtr<MonthListModel> create() { return adopt_ref(*new MonthListModel); }
virtual ~MonthListModel() override;
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp
index 1336abbb1a..6e66ee9b4e 100644
--- a/Userland/Applications/FileManager/DirectoryView.cpp
+++ b/Userland/Applications/FileManager/DirectoryView.cpp
@@ -118,7 +118,7 @@ NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(const UR
{
NonnullRefPtrVector<LauncherHandler> handlers;
for (auto& h : Desktop::Launcher::get_handlers_with_details_for_url(url)) {
- handlers.append(adopt(*new LauncherHandler(h)));
+ handlers.append(adopt_ref(*new LauncherHandler(h)));
}
return handlers;
}
diff --git a/Userland/Applications/FontEditor/FontEditor.cpp b/Userland/Applications/FontEditor/FontEditor.cpp
index 9ef1d6aed6..e6cc7bbaf8 100644
--- a/Userland/Applications/FontEditor/FontEditor.cpp
+++ b/Userland/Applications/FontEditor/FontEditor.cpp
@@ -481,7 +481,7 @@ void FontEditorWidget::initialize(const String& path, RefPtr<Gfx::BitmapFont>&&
});
m_undo_stack = make<GUI::UndoStack>();
- m_undo_glyph = adopt(*new UndoGlyph(m_glyph_map_widget->selected_glyph(), *m_edited_font));
+ m_undo_glyph = adopt_ref(*new UndoGlyph(m_glyph_map_widget->selected_glyph(), *m_edited_font));
did_change_undo_stack();
if (on_initialize)
diff --git a/Userland/Applications/FontEditor/UndoGlyph.h b/Userland/Applications/FontEditor/UndoGlyph.h
index c09e51d254..bfda5dc117 100644
--- a/Userland/Applications/FontEditor/UndoGlyph.h
+++ b/Userland/Applications/FontEditor/UndoGlyph.h
@@ -19,7 +19,7 @@ public:
}
RefPtr<UndoGlyph> save_state() const
{
- auto state = adopt(*new UndoGlyph(m_code_point, *m_font));
+ auto state = adopt_ref(*new UndoGlyph(m_code_point, *m_font));
auto glyph = font().glyph(m_code_point).glyph_bitmap();
for (int x = 0; x < glyph.width(); x++)
for (int y = 0; y < glyph.height(); y++)
diff --git a/Userland/Applications/Help/ManualModel.h b/Userland/Applications/Help/ManualModel.h
index 936739751b..39bd85360b 100644
--- a/Userland/Applications/Help/ManualModel.h
+++ b/Userland/Applications/Help/ManualModel.h
@@ -16,7 +16,7 @@ class ManualModel final : public GUI::Model {
public:
static NonnullRefPtr<ManualModel> create()
{
- return adopt(*new ManualModel);
+ return adopt_ref(*new ManualModel);
}
virtual ~ManualModel() override {};
diff --git a/Userland/Applications/IRCClient/IRCChannel.cpp b/Userland/Applications/IRCClient/IRCChannel.cpp
index a4ebc7ca42..750acc43a0 100644
--- a/Userland/Applications/IRCClient/IRCChannel.cpp
+++ b/Userland/Applications/IRCClient/IRCChannel.cpp
@@ -25,7 +25,7 @@ IRCChannel::~IRCChannel()
NonnullRefPtr<IRCChannel> IRCChannel::create(IRCClient& client, const String& name)
{
- return adopt(*new IRCChannel(client, name));
+ return adopt_ref(*new IRCChannel(client, name));
}
void IRCChannel::add_member(const String& name, char prefix)
diff --git a/Userland/Applications/IRCClient/IRCChannelMemberListModel.h b/Userland/Applications/IRCClient/IRCChannelMemberListModel.h
index 8e38ad32be..5d3145be62 100644
--- a/Userland/Applications/IRCClient/IRCChannelMemberListModel.h
+++ b/Userland/Applications/IRCClient/IRCChannelMemberListModel.h
@@ -16,7 +16,7 @@ public:
enum Column {
Name
};
- static NonnullRefPtr<IRCChannelMemberListModel> create(IRCChannel& channel) { return adopt(*new IRCChannelMemberListModel(channel)); }
+ static NonnullRefPtr<IRCChannelMemberListModel> create(IRCChannel& channel) { return adopt_ref(*new IRCChannelMemberListModel(channel)); }
virtual ~IRCChannelMemberListModel() override;
virtual int row_count(const GUI::ModelIndex&) const override;
diff --git a/Userland/Applications/IRCClient/IRCLogBuffer.cpp b/Userland/Applications/IRCClient/IRCLogBuffer.cpp
index d883db957e..c6a8511e65 100644
--- a/Userland/Applications/IRCClient/IRCLogBuffer.cpp
+++ b/Userland/Applications/IRCClient/IRCLogBuffer.cpp
@@ -15,19 +15,19 @@
NonnullRefPtr<IRCLogBuffer> IRCLogBuffer::create()
{
- return adopt(*new IRCLogBuffer);
+ return adopt_ref(*new IRCLogBuffer);
}
IRCLogBuffer::IRCLogBuffer()
{
m_document = Web::DOM::Document::create();
- m_document->append_child(adopt(*new Web::DOM::DocumentType(document())));
+ m_document->append_child(adopt_ref(*new Web::DOM::DocumentType(document())));
auto html_element = m_document->create_element("html");
m_document->append_child(html_element);
auto head_element = m_document->create_element("head");
html_element->append_child(head_element);
auto style_element = m_document->create_element("style");
- style_element->append_child(adopt(*new Web::DOM::Text(document(), "div { font-family: Csilla; font-weight: lighter; }")));
+ style_element->append_child(adopt_ref(*new Web::DOM::Text(document(), "div { font-family: Csilla; font-weight: lighter; }")));
head_element->append_child(style_element);
auto body_element = m_document->create_element("body");
html_element->append_child(body_element);
diff --git a/Userland/Applications/IRCClient/IRCQuery.cpp b/Userland/Applications/IRCClient/IRCQuery.cpp
index 644377da4c..bc939f371a 100644
--- a/Userland/Applications/IRCClient/IRCQuery.cpp
+++ b/Userland/Applications/IRCClient/IRCQuery.cpp
@@ -23,7 +23,7 @@ IRCQuery::~IRCQuery()
NonnullRefPtr<IRCQuery> IRCQuery::create(IRCClient& client, const String& name)
{
- return adopt(*new IRCQuery(client, name));
+ return adopt_ref(*new IRCQuery(client, name));
}
void IRCQuery::add_message(char prefix, const String& name, const String& text, Color color)
diff --git a/Userland/Applications/IRCClient/IRCWindowListModel.h b/Userland/Applications/IRCClient/IRCWindowListModel.h
index a0e33ed81a..fce8f8e3c6 100644
--- a/Userland/Applications/IRCClient/IRCWindowListModel.h
+++ b/Userland/Applications/IRCClient/IRCWindowListModel.h
@@ -18,7 +18,7 @@ public:
Name,
};
- static NonnullRefPtr<IRCWindowListModel> create(IRCClient& client) { return adopt(*new IRCWindowListModel(client)); }
+ static NonnullRefPtr<IRCWindowListModel> create(IRCClient& client) { return adopt_ref(*new IRCWindowListModel(client)); }
virtual ~IRCWindowListModel() override;
virtual int row_count(const GUI::ModelIndex&) const override;
diff --git a/Userland/Applications/KeyboardSettings/CharacterMapFileListModel.h b/Userland/Applications/KeyboardSettings/CharacterMapFileListModel.h
index 0ccc31166a..d0585e1c46 100644
--- a/Userland/Applications/KeyboardSettings/CharacterMapFileListModel.h
+++ b/Userland/Applications/KeyboardSettings/CharacterMapFileListModel.h
@@ -13,7 +13,7 @@ class CharacterMapFileListModel final : public GUI::Model {
public:
static NonnullRefPtr<CharacterMapFileListModel> create(Vector<String>& file_names)
{
- return adopt(*new CharacterMapFileListModel(file_names));
+ return adopt_ref(*new CharacterMapFileListModel(file_names));
}
virtual ~CharacterMapFileListModel() override { }
diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp
index db88941bfb..62db2fac82 100644
--- a/Userland/Applications/PixelPaint/Image.cpp
+++ b/Userland/Applications/PixelPaint/Image.cpp
@@ -27,7 +27,7 @@ RefPtr<Image> Image::create_with_size(const Gfx::IntSize& size)
if (size.width() > 16384 || size.height() > 16384)
return nullptr;
- return adopt(*new Image(size));
+ return adopt_ref(*new Image(size));
}
Image::Image(const Gfx::IntSize& size)
diff --git a/Userland/Applications/PixelPaint/Layer.cpp b/Userland/Applications/PixelPaint/Layer.cpp
index f81382e32d..92ce3422b9 100644
--- a/Userland/Applications/PixelPaint/Layer.cpp
+++ b/Userland/Applications/PixelPaint/Layer.cpp
@@ -18,7 +18,7 @@ RefPtr<Layer> Layer::create_with_size(Image& image, const Gfx::IntSize& size, co
if (size.width() > 16384 || size.height() > 16384)
return nullptr;
- return adopt(*new Layer(image, size, name));
+ return adopt_ref(*new Layer(image, size, name));
}
RefPtr<Layer> Layer::create_with_bitmap(Image& image, const Gfx::Bitmap& bitmap, const String& name)
@@ -29,7 +29,7 @@ RefPtr<Layer> Layer::create_with_bitmap(Image& image, const Gfx::Bitmap& bitmap,
if (bitmap.size().width() > 16384 || bitmap.size().height() > 16384)
return nullptr;
- return adopt(*new Layer(image, bitmap, name));
+ return adopt_ref(*new Layer(image, bitmap, name));
}
RefPtr<Layer> Layer::create_snapshot(Image& image, const Layer& layer)
diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp
index 356dea2e78..07c358700e 100644
--- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp
+++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp
@@ -35,7 +35,7 @@ SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window
set_layout<GUI::VerticalBoxLayout>();
m_splitter = add<GUI::HorizontalSplitter>();
m_player_view = m_splitter->add<GUI::Widget>();
- m_playlist_model = adopt(*new PlaylistModel());
+ m_playlist_model = adopt_ref(*new PlaylistModel());
m_player_view->set_layout<GUI::VerticalBoxLayout>();
diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp
index 440db2a39e..c28f0da7fe 100644
--- a/Userland/Applications/SpaceAnalyzer/main.cpp
+++ b/Userland/Applications/SpaceAnalyzer/main.cpp
@@ -253,7 +253,7 @@ int main(int argc, char* argv[])
{
auto app = GUI::Application::construct(argc, argv);
- RefPtr<Tree> tree = adopt(*new Tree(""));
+ RefPtr<Tree> tree = adopt_ref(*new Tree(""));
// Configure application window.
auto app_icon = GUI::Icon::default_icon("app-space-analyzer");
diff --git a/Userland/Applications/Spreadsheet/HelpWindow.cpp b/Userland/Applications/Spreadsheet/HelpWindow.cpp
index a1f49fd739..0ee42e3709 100644
--- a/Userland/Applications/Spreadsheet/HelpWindow.cpp
+++ b/Userland/Applications/Spreadsheet/HelpWindow.cpp
@@ -21,7 +21,7 @@ namespace Spreadsheet {
class HelpListModel final : public GUI::Model {
public:
- static NonnullRefPtr<HelpListModel> create() { return adopt(*new HelpListModel); }
+ static NonnullRefPtr<HelpListModel> create() { return adopt_ref(*new HelpListModel); }
virtual ~HelpListModel() override { }
diff --git a/Userland/Applications/Spreadsheet/HelpWindow.h b/Userland/Applications/Spreadsheet/HelpWindow.h
index 29029d5c05..d5756c81c0 100644
--- a/Userland/Applications/Spreadsheet/HelpWindow.h
+++ b/Userland/Applications/Spreadsheet/HelpWindow.h
@@ -23,7 +23,7 @@ public:
if (s_the)
return *s_the;
- return *(s_the = adopt(*new HelpWindow(window)));
+ return *(s_the = adopt_ref(*new HelpWindow(window)));
}
virtual ~HelpWindow() override;
diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
index 1f5e343903..30db02f98b 100644
--- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp
+++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
@@ -359,7 +359,7 @@ void Sheet::copy_cells(Vector<Position> from, Vector<Position> to, Optional<Posi
RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook)
{
- auto sheet = adopt(*new Sheet(workbook));
+ auto sheet = adopt_ref(*new Sheet(workbook));
auto rows = object.get("rows").to_u32(default_row_count);
auto columns = object.get("columns");
auto name = object.get("name").as_string_or("Sheet");
@@ -617,7 +617,7 @@ RefPtr<Sheet> Sheet::from_xsv(const Reader::XSV& xsv, Workbook& workbook)
auto cols = xsv.headers();
auto rows = xsv.size();
- auto sheet = adopt(*new Sheet(workbook));
+ auto sheet = adopt_ref(*new Sheet(workbook));
if (xsv.has_explicit_headers()) {
sheet->m_columns = cols;
} else {
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetModel.h b/Userland/Applications/Spreadsheet/SpreadsheetModel.h
index 6626c011f2..0eb77e3600 100644
--- a/Userland/Applications/Spreadsheet/SpreadsheetModel.h
+++ b/Userland/Applications/Spreadsheet/SpreadsheetModel.h
@@ -13,7 +13,7 @@ namespace Spreadsheet {
class SheetModel final : public GUI::Model {
public:
- static NonnullRefPtr<SheetModel> create(Sheet& sheet) { return adopt(*new SheetModel(sheet)); }
+ static NonnullRefPtr<SheetModel> create(Sheet& sheet) { return adopt_ref(*new SheetModel(sheet)); }
virtual ~SheetModel() override;
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_sheet->row_count(); }
diff --git a/Userland/Applications/SystemMonitor/DevicesModel.cpp b/Userland/Applications/SystemMonitor/DevicesModel.cpp
index 22abd5c9e1..08b578aa98 100644
--- a/Userland/Applications/SystemMonitor/DevicesModel.cpp
+++ b/Userland/Applications/SystemMonitor/DevicesModel.cpp
@@ -14,7 +14,7 @@
NonnullRefPtr<DevicesModel> DevicesModel::create()
{
- return adopt(*new DevicesModel);
+ return adopt_ref(*new DevicesModel);
}
DevicesModel::DevicesModel()
diff --git a/Userland/Applications/SystemMonitor/ProcessModel.h b/Userland/Applications/SystemMonitor/ProcessModel.h
index e928f360b3..3ca2f8e248 100644
--- a/Userland/Applications/SystemMonitor/ProcessModel.h
+++ b/Userland/Applications/SystemMonitor/ProcessModel.h
@@ -53,7 +53,7 @@ public:
static ProcessModel& the();
- static NonnullRefPtr<ProcessModel> create() { return adopt(*new ProcessModel); }
+ static NonnullRefPtr<ProcessModel> create() { return adopt_ref(*new ProcessModel); }
virtual ~ProcessModel() override;
virtual int row_count(const GUI::ModelIndex&) const override;
diff --git a/Userland/Applications/SystemMonitor/ProcessStateWidget.cpp b/Userland/Applications/SystemMonitor/ProcessStateWidget.cpp
index 91bdbdeb3f..c7a0b6b8f3 100644
--- a/Userland/Applications/SystemMonitor/ProcessStateWidget.cpp
+++ b/Userland/Applications/SystemMonitor/ProcessStateWidget.cpp
@@ -88,7 +88,7 @@ ProcessStateWidget::ProcessStateWidget(pid_t pid)
m_table_view = add<GUI::TableView>();
m_table_view->column_header().set_visible(false);
m_table_view->column_header().set_section_size(0, 90);
- m_table_view->set_model(adopt(*new ProcessStateModel(ProcessModel::the(), pid)));
+ m_table_view->set_model(adopt_ref(*new ProcessStateModel(ProcessModel::the(), pid)));
}
ProcessStateWidget::~ProcessStateWidget()
diff --git a/Userland/Applications/ThemeEditor/main.cpp b/Userland/Applications/ThemeEditor/main.cpp
index 6e612afaf7..be2e37154f 100644
--- a/Userland/Applications/ThemeEditor/main.cpp
+++ b/Userland/Applications/ThemeEditor/main.cpp
@@ -95,7 +95,7 @@ int main(int argc, char** argv)
#undef __ENUMERATE_COLOR_ROLE
combo_box.set_only_allow_values_from_model(true);
- combo_box.set_model(adopt(*new ColorRoleModel(color_roles)));
+ combo_box.set_model(adopt_ref(*new ColorRoleModel(color_roles)));
combo_box.on_change = [&](auto&, auto& index) {
auto role = static_cast<const ColorRoleModel*>(index.model())->color_role(index);
color_input.set_color(preview_palette.color(role));
diff --git a/Userland/Demos/WidgetGallery/GalleryModels.h b/Userland/Demos/WidgetGallery/GalleryModels.h
index 9a29d320e9..a42153ee02 100644
--- a/Userland/Demos/WidgetGallery/GalleryModels.h
+++ b/Userland/Demos/WidgetGallery/GalleryModels.h
@@ -13,7 +13,7 @@
class MouseCursorModel final : public GUI::Model {
public:
- static NonnullRefPtr<MouseCursorModel> create() { return adopt(*new MouseCursorModel); }
+ static NonnullRefPtr<MouseCursorModel> create() { return adopt_ref(*new MouseCursorModel); }
virtual ~MouseCursorModel() override { }
enum Column {
@@ -86,7 +86,7 @@ private:
class FileIconsModel final : public GUI::Model {
public:
- static NonnullRefPtr<FileIconsModel> create() { return adopt(*new FileIconsModel); }
+ static NonnullRefPtr<FileIconsModel> create() { return adopt_ref(*new FileIconsModel); }
virtual ~FileIconsModel() override { }
enum Column {
diff --git a/Userland/DevTools/HackStudio/ClassViewWidget.cpp b/Userland/DevTools/HackStudio/ClassViewWidget.cpp
index 820da3cb08..4f05ac67f6 100644
--- a/Userland/DevTools/HackStudio/ClassViewWidget.cpp
+++ b/Userland/DevTools/HackStudio/ClassViewWidget.cpp
@@ -33,7 +33,7 @@ ClassViewWidget::ClassViewWidget()
RefPtr<ClassViewModel> ClassViewModel::create()
{
- return adopt(*new ClassViewModel());
+ return adopt_ref(*new ClassViewModel());
}
int ClassViewModel::row_count(const GUI::ModelIndex& index) const
diff --git a/Userland/DevTools/HackStudio/CodeDocument.cpp b/Userland/DevTools/HackStudio/CodeDocument.cpp
index 43078fe205..bc08806b59 100644
--- a/Userland/DevTools/HackStudio/CodeDocument.cpp
+++ b/Userland/DevTools/HackStudio/CodeDocument.cpp
@@ -10,12 +10,12 @@ namespace HackStudio {
NonnullRefPtr<CodeDocument> CodeDocument::create(const String& file_path, Client* client)
{
- return adopt(*new CodeDocument(file_path, client));
+ return adopt_ref(*new CodeDocument(file_path, client));
}
NonnullRefPtr<CodeDocument> CodeDocument::create(Client* client)
{
- return adopt(*new CodeDocument(client));
+ return adopt_ref(*new CodeDocument(client));
}
CodeDocument::CodeDocument(const String& file_path, Client* client)
diff --git a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp
index 03b103929d..4cc245ee92 100644
--- a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp
+++ b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp
@@ -12,7 +12,7 @@ namespace HackStudio {
NonnullRefPtr<BacktraceModel> BacktraceModel::create(const Debug::DebugSession& debug_session, const PtraceRegisters& regs)
{
- return adopt(*new BacktraceModel(create_backtrace(debug_session, regs)));
+ return adopt_ref(*new BacktraceModel(create_backtrace(debug_session, regs)));
}
GUI::Variant BacktraceModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h
index 870ccd853e..ba856bcb6c 100644
--- a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h
+++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h
@@ -30,7 +30,7 @@ class DisassemblyModel final : public GUI::Model {
public:
static NonnullRefPtr<DisassemblyModel> create(const Debug::DebugSession& debug_session, const PtraceRegisters& regs)
{
- return adopt(*new DisassemblyModel(debug_session, regs));
+ return adopt_ref(*new DisassemblyModel(debug_session, regs));
}
enum Column {
diff --git a/Userland/DevTools/HackStudio/Debugger/RegistersModel.h b/Userland/DevTools/HackStudio/Debugger/RegistersModel.h
index e540391234..cc984f86f2 100644
--- a/Userland/DevTools/HackStudio/Debugger/RegistersModel.h
+++ b/Userland/DevTools/HackStudio/Debugger/RegistersModel.h
@@ -22,12 +22,12 @@ class RegistersModel final : public GUI::Model {
public:
static RefPtr<RegistersModel> create(const PtraceRegisters& regs)
{
- return adopt(*new RegistersModel(regs));
+ return adopt_ref(*new RegistersModel(regs));
}
static RefPtr<RegistersModel> create(const PtraceRegisters& current_regs, const PtraceRegisters& previous_regs)
{
- return adopt(*new RegistersModel(current_regs, previous_regs));
+ return adopt_ref(*new RegistersModel(current_regs, previous_regs));
}
enum Column {
diff --git a/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp b/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp
index c5a8d17188..40749baed9 100644
--- a/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp
+++ b/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp
@@ -169,7 +169,7 @@ RefPtr<VariablesModel> VariablesModel::create(const PtraceRegisters& regs)
if (!lib)
return nullptr;
auto variables = lib->debug_info->get_variables_in_current_scope(regs);
- return adopt(*new VariablesModel(move(variables), regs));
+ return adopt_ref(*new VariablesModel(move(variables), regs));
}
}
diff --git a/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h b/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h
index c52f2db1b1..4674a738cf 100644
--- a/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h
+++ b/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h
@@ -19,7 +19,7 @@ class ProjectTemplatesModel final : public GUI::Model {
public:
static NonnullRefPtr<ProjectTemplatesModel> create()
{
- return adopt(*new ProjectTemplatesModel());
+ return adopt_ref(*new ProjectTemplatesModel());
}
enum Column {
diff --git a/Userland/DevTools/HackStudio/FindInFilesWidget.cpp b/Userland/DevTools/HackStudio/FindInFilesWidget.cpp
index a82a9c0c3d..7bc50f0da8 100644
--- a/Userland/DevTools/HackStudio/FindInFilesWidget.cpp
+++ b/Userland/DevTools/HackStudio/FindInFilesWidget.cpp
@@ -110,7 +110,7 @@ static RefPtr<SearchResultsModel> find_in_files(const StringView& text)
}
});
- return adopt(*new SearchResultsModel(move(matches)));
+ return adopt_ref(*new SearchResultsModel(move(matches)));
}
FindInFilesWidget::FindInFilesWidget()
diff --git a/Userland/DevTools/HackStudio/Git/GitFilesModel.cpp b/Userland/DevTools/HackStudio/Git/GitFilesModel.cpp
index 89b24e4691..99cb8a6f4e 100644
--- a/Userland/DevTools/HackStudio/Git/GitFilesModel.cpp
+++ b/Userland/DevTools/HackStudio/Git/GitFilesModel.cpp
@@ -10,7 +10,7 @@ namespace HackStudio {
NonnullRefPtr<GitFilesModel> GitFilesModel::create(Vector<LexicalPath>&& files)
{
- return adopt(*new GitFilesModel(move(files)));
+ return adopt_ref(*new GitFilesModel(move(files)));
}
GitFilesModel::GitFilesModel(Vector<LexicalPath>&& files)
diff --git a/Userland/DevTools/HackStudio/Git/GitRepo.cpp b/Userland/DevTools/HackStudio/Git/GitRepo.cpp
index 50506fd13a..f42f832994 100644
--- a/Userland/DevTools/HackStudio/Git/GitRepo.cpp
+++ b/Userland/DevTools/HackStudio/Git/GitRepo.cpp
@@ -20,7 +20,7 @@ GitRepo::CreateResult GitRepo::try_to_create(const LexicalPath& repository_root)
return { CreateResult::Type::NoGitRepo, nullptr };
}
- return { CreateResult::Type::Success, adopt(*new GitRepo(repository_root)) };
+ return { CreateResult::Type::Success, adopt_ref(*new GitRepo(repository_root)) };
}
RefPtr<GitRepo> GitRepo::initialize_repository(const LexicalPath& repository_root)
@@ -30,7 +30,7 @@ RefPtr<GitRepo> GitRepo::initialize_repository(const LexicalPath& repository_roo
return {};
VERIFY(git_repo_exists(repository_root));
- return adopt(*new GitRepo(repository_root));
+ return adopt_ref(*new GitRepo(repository_root));
}
Vector<LexicalPath> GitRepo::unstaged_files() const
diff --git a/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp b/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp
index ee608fba20..0dc64cb6a3 100644
--- a/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp
+++ b/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp
@@ -26,7 +26,7 @@ RefPtr<GUI::TextDocument> FileDB::get(const String& file_name)
auto document = reinterpret_cast<const FileDB*>(this)->get(file_name);
if (document.is_null())
return nullptr;
- return adopt(*const_cast<GUI::TextDocument*>(document.leak_ref()));
+ return adopt_ref(*const_cast<GUI::TextDocument*>(document.leak_ref()));
}
RefPtr<const GUI::TextDocument> FileDB::get_or_create_from_filesystem(const String& file_name) const
@@ -43,7 +43,7 @@ RefPtr<GUI::TextDocument> FileDB::get_or_create_from_filesystem(const String& fi
auto document = reinterpret_cast<const FileDB*>(this)->get_or_create_from_filesystem(file_name);
if (document.is_null())
return nullptr;
- return adopt(*const_cast<GUI::TextDocument*>(document.leak_ref()));
+ return adopt_ref(*const_cast<GUI::TextDocument*>(document.leak_ref()));
}
bool FileDB::is_open(const String& file_name) const
diff --git a/Userland/DevTools/HackStudio/Locator.cpp b/Userland/DevTools/HackStudio/Locator.cpp
index 3d24bca48a..44eba20f23 100644
--- a/Userland/DevTools/HackStudio/Locator.cpp
+++ b/Userland/DevTools/HackStudio/Locator.cpp
@@ -211,7 +211,7 @@ void Locator::update_suggestions()
bool has_suggestions = !suggestions.is_empty();
- m_suggestion_view->set_model(adopt(*new LocatorSuggestionModel(move(suggestions))));
+ m_suggestion_view->set_model(adopt_ref(*new LocatorSuggestionModel(move(suggestions))));
if (!has_suggestions)
m_suggestion_view->selection().clear();
diff --git a/Userland/DevTools/HackStudio/ProjectFile.h b/Userland/DevTools/HackStudio/ProjectFile.h
index c44362e8b0..72fc3e7a24 100644
--- a/Userland/DevTools/HackStudio/ProjectFile.h
+++ b/Userland/DevTools/HackStudio/ProjectFile.h
@@ -18,7 +18,7 @@ class ProjectFile : public RefCounted<ProjectFile> {
public:
static NonnullRefPtr<ProjectFile> construct_with_name(const String& name)
{
- return adopt(*new ProjectFile(name));
+ return adopt_ref(*new ProjectFile(name));
}
const String& name() const { return m_name; }
diff --git a/Userland/DevTools/HackStudio/ProjectTemplate.cpp b/Userland/DevTools/HackStudio/ProjectTemplate.cpp
index 84e8b95d0b..8c0f6c3f82 100644
--- a/Userland/DevTools/HackStudio/ProjectTemplate.cpp
+++ b/Userland/DevTools/HackStudio/ProjectTemplate.cpp
@@ -62,7 +62,7 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(const String& manife
icon = GUI::Icon(move(bitmap32));
}
- return adopt(*new ProjectTemplate(id, name, description, icon, priority));
+ return adopt_ref(*new ProjectTemplate(id, name, description, icon, priority));
}
Result<void, String> ProjectTemplate::create_project(const String& name, const String& path)
diff --git a/Userland/DevTools/HackStudio/WidgetTreeModel.h b/Userland/DevTools/HackStudio/WidgetTreeModel.h
index f487aacf3e..c8dacf9e54 100644
--- a/Userland/DevTools/HackStudio/WidgetTreeModel.h
+++ b/Userland/DevTools/HackStudio/WidgetTreeModel.h
@@ -13,7 +13,7 @@ namespace HackStudio {
class WidgetTreeModel final : public GUI::Model {
public:
- static NonnullRefPtr<WidgetTreeModel> create(GUI::Widget& root) { return adopt(*new WidgetTreeModel(root)); }
+ static NonnullRefPtr<WidgetTreeModel> create(GUI::Widget& root) { return adopt_ref(*new WidgetTreeModel(root)); }
virtual ~WidgetTreeModel() override;
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
diff --git a/Userland/DevTools/Inspector/RemoteObjectGraphModel.h b/Userland/DevTools/Inspector/RemoteObjectGraphModel.h
index ae8986e753..dd2aec7948 100644
--- a/Userland/DevTools/Inspector/RemoteObjectGraphModel.h
+++ b/Userland/DevTools/Inspector/RemoteObjectGraphModel.h
@@ -20,7 +20,7 @@ class RemoteObjectGraphModel final : public GUI::Model {
public:
static NonnullRefPtr<RemoteObjectGraphModel> create(RemoteProcess& process)
{
- return adopt(*new RemoteObjectGraphModel(process));
+ return adopt_ref(*new RemoteObjectGraphModel(process));
}
virtual ~RemoteObjectGraphModel() override;
diff --git a/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h b/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h
index d8f1d26352..fca20109fe 100644
--- a/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h
+++ b/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h
@@ -20,7 +20,7 @@ public:
virtual ~RemoteObjectPropertyModel() override { }
static NonnullRefPtr<RemoteObjectPropertyModel> create(RemoteObject& object)
{
- return adopt(*new RemoteObjectPropertyModel(object));
+ return adopt_ref(*new RemoteObjectPropertyModel(object));
}
enum Column {
diff --git a/Userland/DevTools/Profiler/DisassemblyModel.h b/Userland/DevTools/Profiler/DisassemblyModel.h
index 961570a0c9..382c384fde 100644
--- a/Userland/DevTools/Profiler/DisassemblyModel.h
+++ b/Userland/DevTools/Profiler/DisassemblyModel.h
@@ -25,7 +25,7 @@ class DisassemblyModel final : public GUI::Model {
public:
static NonnullRefPtr<DisassemblyModel> create(Profile& profile, ProfileNode& node)
{
- return adopt(*new DisassemblyModel(profile, node));
+ return adopt_ref(*new DisassemblyModel(profile, node));
}
enum Column {
diff --git a/Userland/DevTools/Profiler/IndividualSampleModel.h b/Userland/DevTools/Profiler/IndividualSampleModel.h
index cdd7008967..7ff5dacd73 100644
--- a/Userland/DevTools/Profiler/IndividualSampleModel.h
+++ b/Userland/DevTools/Profiler/IndividualSampleModel.h
@@ -14,7 +14,7 @@ class IndividualSampleModel final : public GUI::Model {
public:
static NonnullRefPtr<IndividualSampleModel> create(Profile& profile, size_t event_index)
{
- return adopt(*new IndividualSampleModel(profile, event_index));
+ return adopt_ref(*new IndividualSampleModel(profile, event_index));
}
enum Column {
diff --git a/Userland/DevTools/Profiler/Profile.h b/Userland/DevTools/Profiler/Profile.h
index 54e5c34bc9..659d0b6d12 100644
--- a/Userland/DevTools/Profiler/Profile.h
+++ b/Userland/DevTools/Profiler/Profile.h
@@ -71,7 +71,7 @@ class ProfileNode : public RefCounted<ProfileNode> {
public:
static NonnullRefPtr<ProfileNode> create(FlyString object_name, String symbol, u32 address, u32 offset, u64 timestamp, pid_t pid)
{
- return adopt(*new ProfileNode(move(object_name), move(symbol), address, offset, timestamp, pid));
+ return adopt_ref(*new ProfileNode(move(object_name), move(symbol), address, offset, timestamp, pid));
}
// These functions are only relevant for root nodes
diff --git a/Userland/DevTools/Profiler/ProfileModel.h b/Userland/DevTools/Profiler/ProfileModel.h
index 21ebbc837e..b9612c2894 100644
--- a/Userland/DevTools/Profiler/ProfileModel.h
+++ b/Userland/DevTools/Profiler/ProfileModel.h
@@ -14,7 +14,7 @@ class ProfileModel final : public GUI::Model {
public:
static NonnullRefPtr<ProfileModel> create(Profile& profile)
{
- return adopt(*new ProfileModel(profile));
+ return adopt_ref(*new ProfileModel(profile));
}
enum Column {
diff --git a/Userland/DevTools/Profiler/SamplesModel.h b/Userland/DevTools/Profiler/SamplesModel.h
index d3ef72556e..9ebf18c049 100644
--- a/Userland/DevTools/Profiler/SamplesModel.h
+++ b/Userland/DevTools/Profiler/SamplesModel.h
@@ -14,7 +14,7 @@ class SamplesModel final : public GUI::Model {
public:
static NonnullRefPtr<SamplesModel> create(Profile& profile)
{
- return adopt(*new SamplesModel(profile));
+ return adopt_ref(*new SamplesModel(profile));
}
enum Column {
diff --git a/Userland/Libraries/LibAudio/Buffer.h b/Userland/Libraries/LibAudio/Buffer.h
index bf9f7bfa30..fda5e0ef9c 100644
--- a/Userland/Libraries/LibAudio/Buffer.h
+++ b/Userland/Libraries/LibAudio/Buffer.h
@@ -93,11 +93,11 @@ public:
static RefPtr<Buffer> from_pcm_stream(InputMemoryStream& stream, ResampleHelper& resampler, int num_channels, int bits_per_sample, int num_samples);
static NonnullRefPtr<Buffer> create_with_samples(Vector<Frame>&& samples)
{
- return adopt(*new Buffer(move(samples)));
+ return adopt_ref(*new Buffer(move(samples)));
}
static NonnullRefPtr<Buffer> create_with_anonymous_buffer(Core::AnonymousBuffer buffer, i32 buffer_id, int sample_count)
{
- return adopt(*new Buffer(move(buffer), buffer_id, sample_count));
+ return adopt_ref(*new Buffer(move(buffer), buffer_id, sample_count));
}
const Frame* samples() const { return (const Frame*)data(); }
diff --git a/Userland/Libraries/LibAudio/Loader.h b/Userland/Libraries/LibAudio/Loader.h
index 1e92262079..5cd605934d 100644
--- a/Userland/Libraries/LibAudio/Loader.h
+++ b/Userland/Libraries/LibAudio/Loader.h
@@ -39,8 +39,8 @@ public:
class Loader : public RefCounted<Loader> {
public:
- static NonnullRefPtr<Loader> create(const StringView& path) { return adopt(*new Loader(path)); }
- static NonnullRefPtr<Loader> create(const ByteBuffer& buffer) { return adopt(*new Loader(buffer)); }
+ static NonnullRefPtr<Loader> create(const StringView& path) { return adopt_ref(*new Loader(path)); }
+ static NonnullRefPtr<Loader> create(const ByteBuffer& buffer) { return adopt_ref(*new Loader(buffer)); }
bool has_error() const { return m_plugin ? m_plugin->has_error() : true; }
const char* error_string() const { return m_plugin ? m_plugin->error_string() : "No loader plugin available"; }
diff --git a/Userland/Libraries/LibCore/AnonymousBuffer.cpp b/Userland/Libraries/LibCore/AnonymousBuffer.cpp
index f0a8033490..1c73399913 100644
--- a/Userland/Libraries/LibCore/AnonymousBuffer.cpp
+++ b/Userland/Libraries/LibCore/AnonymousBuffer.cpp
@@ -61,7 +61,7 @@ RefPtr<AnonymousBufferImpl> AnonymousBufferImpl::create(int fd, size_t size)
perror("mmap");
return {};
}
- return adopt(*new AnonymousBufferImpl(fd, size, data));
+ return adopt_ref(*new AnonymousBufferImpl(fd, size, data));
}
AnonymousBufferImpl::~AnonymousBufferImpl()
diff --git a/Userland/Libraries/LibCore/ConfigFile.cpp b/Userland/Libraries/LibCore/ConfigFile.cpp
index f55ec626ef..7bb69df9ac 100644
--- a/Userland/Libraries/LibCore/ConfigFile.cpp
+++ b/Userland/Libraries/LibCore/ConfigFile.cpp
@@ -20,25 +20,25 @@ NonnullRefPtr<ConfigFile> ConfigFile::get_for_lib(const String& lib_name)
String directory = StandardPaths::config_directory();
auto path = String::formatted("{}/lib/{}.ini", directory, lib_name);
- return adopt(*new ConfigFile(path));
+ return adopt_ref(*new ConfigFile(path));
}
NonnullRefPtr<ConfigFile> ConfigFile::get_for_app(const String& app_name)
{
String directory = StandardPaths::config_directory();
auto path = String::formatted("{}/{}.ini", directory, app_name);
- return adopt(*new ConfigFile(path));
+ return adopt_ref(*new ConfigFile(path));
}
NonnullRefPtr<ConfigFile> ConfigFile::get_for_system(const String& app_name)
{
auto path = String::formatted("/etc/{}.ini", app_name);
- return adopt(*new ConfigFile(path));
+ return adopt_ref(*new ConfigFile(path));
}
NonnullRefPtr<ConfigFile> ConfigFile::open(const String& path)
{
- return adopt(*new ConfigFile(path));
+ return adopt_ref(*new ConfigFile(path));
}
ConfigFile::ConfigFile(const String& file_name)
diff --git a/Userland/Libraries/LibCore/EventLoop.cpp b/Userland/Libraries/LibCore/EventLoop.cpp
index 0e91e6825a..3fee668783 100644
--- a/Userland/Libraries/LibCore/EventLoop.cpp
+++ b/Userland/Libraries/LibCore/EventLoop.cpp
@@ -525,7 +525,7 @@ int EventLoop::register_signal(int signo, Function<void(int)> handler)
auto& info = *signals_info();
auto handlers = info.signal_handlers.find(signo);
if (handlers == info.signal_handlers.end()) {
- auto signal_handlers = adopt(*new SignalHandlers(signo, EventLoop::handle_signal));
+ auto signal_handlers = adopt_ref(*new SignalHandlers(signo, EventLoop::handle_signal));
auto handler_id = signal_handlers->add(move(handler));
info.signal_handlers.set(signo, move(signal_handlers));
return handler_id;
diff --git a/Userland/Libraries/LibCore/FileWatcher.cpp b/Userland/Libraries/LibCore/FileWatcher.cpp
index 67113999db..a023434931 100644
--- a/Userland/Libraries/LibCore/FileWatcher.cpp
+++ b/Userland/Libraries/LibCore/FileWatcher.cpp
@@ -103,7 +103,7 @@ Result<NonnullRefPtr<FileWatcher>, String> FileWatcher::watch(const String& path
dbgln_if(FILE_WATCHER_DEBUG, "Started watcher for file '{}'", path.characters());
auto notifier = Notifier::construct(watch_fd, Notifier::Event::Read);
- return adopt(*new FileWatcher(move(notifier), move(path)));
+ return adopt_ref(*new FileWatcher(move(notifier), move(path)));
}
FileWatcher::FileWatcher(NonnullRefPtr<Notifier> notifier, const String& path)
diff --git a/Userland/Libraries/LibCore/Object.h b/Userland/Libraries/LibCore/Object.h
index cf0dc7cef1..c171c395f7 100644
--- a/Userland/Libraries/LibCore/Object.h
+++ b/Userland/Libraries/LibCore/Object.h
@@ -32,7 +32,7 @@ public: \
template<class... Args> \
static inline NonnullRefPtr<klass> construct(Args&&... args) \
{ \
- return adopt(*new klass(forward<Args>(args)...)); \
+ return adopt_ref(*new klass(forward<Args>(args)...)); \
}
#define C_OBJECT_ABSTRACT(klass) \
diff --git a/Userland/Libraries/LibCore/Timer.h b/Userland/Libraries/LibCore/Timer.h
index 32d36ab0eb..7e790224f0 100644
--- a/Userland/Libraries/LibCore/Timer.h
+++ b/Userland/Libraries/LibCore/Timer.h
@@ -17,13 +17,13 @@ class Timer final : public Object {
public:
static NonnullRefPtr<Timer> create_repeating(int interval, Function<void()>&& timeout_handler, Object* parent = nullptr)
{
- auto timer = adopt(*new Timer(interval, move(timeout_handler), parent));
+ auto timer = adopt_ref(*new Timer(interval, move(timeout_handler), parent));
timer->stop();
return timer;
}
static NonnullRefPtr<Timer> create_single_shot(int interval, Function<void()>&& timeout_handler, Object* parent = nullptr)
{
- auto timer = adopt(*new Timer(interval, move(timeout_handler), parent));
+ auto timer = adopt_ref(*new Timer(interval, move(timeout_handler), parent));
timer->set_single_shot(true);
timer->stop();
return timer;
diff --git a/Userland/Libraries/LibCpp/Parser.h b/Userland/Libraries/LibCpp/Parser.h
index 085d4edcdb..90107c398d 100644
--- a/Userland/Libraries/LibCpp/Parser.h
+++ b/Userland/Libraries/LibCpp/Parser.h
@@ -139,7 +139,7 @@ private:
NonnullRefPtr<T>
create_ast_node(ASTNode& parent, const Position& start, Optional<Position> end, Args&&... args)
{
- auto node = adopt(*new T(&parent, start, end, m_filename, forward<Args>(args)...));
+ auto node = adopt_ref(*new T(&parent, start, end, m_filename, forward<Args>(args)...));
if (!parent.is_dummy_node()) {
m_state.nodes.append(node);
}
@@ -149,7 +149,7 @@ private:
NonnullRefPtr<TranslationUnit>
create_root_ast_node(const Position& start, Position end)
{
- auto node = adopt(*new TranslationUnit(nullptr, start, end, m_filename));
+ auto node = adopt_ref(*new TranslationUnit(nullptr, start, end, m_filename));
m_state.nodes.append(node);
m_root_node = node;
return node;
@@ -157,7 +157,7 @@ private:
DummyAstNode& get_dummy_node()
{
- static NonnullRefPtr<DummyAstNode> dummy = adopt(*new DummyAstNode(nullptr, {}, {}, {}));
+ static NonnullRefPtr<DummyAstNode> dummy = adopt_ref(*new DummyAstNode(nullptr, {}, {}, {}));
return dummy;
}
diff --git a/Userland/Libraries/LibDesktop/AppFile.cpp b/Userland/Libraries/LibDesktop/AppFile.cpp
index ecb4b318c5..dee54d7631 100644
--- a/Userland/Libraries/LibDesktop/AppFile.cpp
+++ b/Userland/Libraries/LibDesktop/AppFile.cpp
@@ -20,7 +20,7 @@ NonnullRefPtr<AppFile> AppFile::get_for_app(const StringView& app_name)
NonnullRefPtr<AppFile> AppFile::open(const StringView& path)
{
- return adopt(*new AppFile(path));
+ return adopt_ref(*new AppFile(path));
}
void AppFile::for_each(Function<void(NonnullRefPtr<AppFile>)> callback, const StringView& directory)
diff --git a/Userland/Libraries/LibDesktop/Launcher.cpp b/Userland/Libraries/LibDesktop/Launcher.cpp
index 90ce83bc7e..da1a321c35 100644
--- a/Userland/Libraries/LibDesktop/Launcher.cpp
+++ b/Userland/Libraries/LibDesktop/Launcher.cpp
@@ -16,7 +16,7 @@ namespace Desktop {
auto Launcher::Details::from_details_str(const String& details_str) -> NonnullRefPtr<Details>
{
- auto details = adopt(*new Details);
+ auto details = adopt_ref(*new Details);
auto json = JsonValue::from_string(details_str);
VERIFY(json.has_value());
auto obj = json.value().as_object();
diff --git a/Userland/Libraries/LibELF/DynamicLoader.cpp b/Userland/Libraries/LibELF/DynamicLoader.cpp
index 5eeac24cd5..d211617dfa 100644
--- a/Userland/Libraries/LibELF/DynamicLoader.cpp
+++ b/Userland/Libraries/LibELF/DynamicLoader.cpp
@@ -54,7 +54,7 @@ RefPtr<DynamicLoader> DynamicLoader::try_create(int fd, String filename)
return {};
}
- return adopt(*new DynamicLoader(fd, move(filename), data, size));
+ return adopt_ref(*new DynamicLoader(fd, move(filename), data, size));
}
DynamicLoader::DynamicLoader(int fd, String filename, void* data, size_t size)
diff --git a/Userland/Libraries/LibELF/DynamicObject.cpp b/Userland/Libraries/LibELF/DynamicObject.cpp
index cd101632ea..7c5b2957cf 100644
--- a/Userland/Libraries/LibELF/DynamicObject.cpp
+++ b/Userland/Libraries/LibELF/DynamicObject.cpp
@@ -444,7 +444,7 @@ auto DynamicObject::lookup_symbol(const StringView& name, u32 gnu_hash, u32 sysv
NonnullRefPtr<DynamicObject> DynamicObject::create(const String& filename, VirtualAddress base_address, VirtualAddress dynamic_section_address)
{
- return adopt(*new DynamicObject(filename, base_address, dynamic_section_address));
+ return adopt_ref(*new DynamicObject(filename, base_address, dynamic_section_address));
}
// offset is in PLT relocation table
diff --git a/Userland/Libraries/LibGUI/Action.cpp b/Userland/Libraries/LibGUI/Action.cpp
index 666bbbf595..64aee3d101 100644
--- a/Userland/Libraries/LibGUI/Action.cpp
+++ b/Userland/Libraries/LibGUI/Action.cpp
@@ -158,42 +158,42 @@ NonnullRefPtr<Action> make_properties_action(Function<void(Action&)> callback, C
NonnullRefPtr<Action> Action::create(String text, Function<void(Action&)> callback, Core::Object* parent)
{
- return adopt(*new Action(move(text), move(callback), parent));
+ return adopt_ref(*new Action(move(text), move(callback), parent));
}
NonnullRefPtr<Action> Action::create(String text, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent)
{
- return adopt(*new Action(move(text), move(icon), move(callback), parent));
+ return adopt_ref(*new Action(move(text), move(icon), move(callback), parent));
}
NonnullRefPtr<Action> Action::create(String text, const Shortcut& shortcut, Function<void(Action&)> callback, Core::Object* parent)
{
- return adopt(*new Action(move(text), shortcut, move(callback), parent));
+ return adopt_ref(*new Action(move(text), shortcut, move(callback), parent));
}
NonnullRefPtr<Action> Action::create(String text, const Shortcut& shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent)
{
- return adopt(*new Action(move(text), shortcut, move(icon), move(callback), parent));
+ return adopt_ref(*new Action(move(text), shortcut, move(icon), move(callback), parent));
}
NonnullRefPtr<Action> Action::create_checkable(String text, Function<void(Action&)> callback, Core::Object* parent)
{
- return adopt(*new Action(move(text), move(callback), parent, true));
+ return adopt_ref(*new Action(move(text), move(callback), parent, true));
}
NonnullRefPtr<Action> Action::create_checkable(String text, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent)
{
- return adopt(*new Action(move(text), move(icon), move(callback), parent, true));
+ return adopt_ref(*new Action(move(text), move(icon), move(callback), parent, true));
}
NonnullRefPtr<Action> Action::create_checkable(String text, const Shortcut& shortcut, Function<void(Action&)> callback, Core::Object* parent)
{
- return adopt(*new Action(move(text), shortcut, move(callback), parent, true));
+ return adopt_ref(*new Action(move(text), shortcut, move(callback), parent, true));
}
NonnullRefPtr<Action> Action::create_checkable(String text, const Shortcut& shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent)
{
- return adopt(*new Action(move(text), shortcut, move(icon), move(callback), parent, true));
+ return adopt_ref(*new Action(move(text), shortcut, move(icon), move(callback), parent, true));
}
Action::Action(String text, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable)
diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp
index 306b5c2355..990eefd06e 100644
--- a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp
+++ b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp
@@ -98,7 +98,7 @@ void AutocompleteBox::update_suggestions(Vector<AutocompleteProvider::Entry>&& s
auto& model = *static_cast<AutocompleteSuggestionModel*>(m_suggestion_view->model());
model.set_suggestions(move(suggestions));
} else {
- m_suggestion_view->set_model(adopt(*new AutocompleteSuggestionModel(move(suggestions))));
+ m_suggestion_view->set_model(adopt_ref(*new AutocompleteSuggestionModel(move(suggestions))));
m_suggestion_view->update();
if (has_suggestions)
m_suggestion_view->set_cursor(m_suggestion_view->model()->index(0), GUI::AbstractView::SelectionUpdate::Set);
diff --git a/Userland/Libraries/LibGUI/DisplayLink.cpp b/Userland/Libraries/LibGUI/DisplayLink.cpp
index ed3aea7efa..cd64dd4dd8 100644
--- a/Userland/Libraries/LibGUI/DisplayLink.cpp
+++ b/Userland/Libraries/LibGUI/DisplayLink.cpp
@@ -46,7 +46,7 @@ i32 DisplayLink::register_callback(Function<void(i32)> callback)
WindowServerConnection::the().post_message(Messages::WindowServer::EnableDisplayLink());
i32 callback_id = s_next_callback_id++;
- callbacks().set(callback_id, adopt(*new DisplayLinkCallback(callback_id, move(callback))));
+ callbacks().set(callback_id, adopt_ref(*new DisplayLinkCallback(callback_id, move(callback))));
return callback_id;
}
diff --git a/Userland/Libraries/LibGUI/FileSystemModel.h b/Userland/Libraries/LibGUI/FileSystemModel.h
index 16da76a3a4..6b7c7544aa 100644
--- a/Userland/Libraries/LibGUI/FileSystemModel.h
+++ b/Userland/Libraries/LibGUI/FileSystemModel.h
@@ -100,7 +100,7 @@ public:
static NonnullRefPtr<FileSystemModel> create(String root_path = "/", Mode mode = Mode::FilesAndDirectories)
{
- return adopt(*new FileSystemModel(root_path, mode));
+ return adopt_ref(*new FileSystemModel(root_path, mode));
}
virtual ~FileSystemModel() override;
diff --git a/Userland/Libraries/LibGUI/FilteringProxyModel.h b/Userland/Libraries/LibGUI/FilteringProxyModel.h
index 7c6f74accb..a83fb0f52f 100644
--- a/Userland/Libraries/LibGUI/FilteringProxyModel.h
+++ b/Userland/Libraries/LibGUI/FilteringProxyModel.h
@@ -18,7 +18,7 @@ class FilteringProxyModel final : public Model {
public:
static NonnullRefPtr<FilteringProxyModel> construct(Model& model)
{
- return adopt(*new FilteringProxyModel(model));
+ return adopt_ref(*new FilteringProxyModel(model));
}
virtual ~FilteringProxyModel() override {};
diff --git a/Userland/Libraries/LibGUI/FontPicker.cpp b/Userland/Libraries/LibGUI/FontPicker.cpp
index b26871edba..140c094f95 100644
--- a/Userland/Libraries/LibGUI/FontPicker.cpp
+++ b/Userland/Libraries/LibGUI/FontPicker.cpp
@@ -35,7 +35,7 @@ FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font, boo
m_family_list_view->horizontal_scrollbar().set_visible(false);
m_weight_list_view = *widget.find_descendant_of_type_named<ListView>("weight_list_view");
- m_weight_list_view->set_model(adopt(*new FontWeightListModel(m_weights)));
+ m_weight_list_view->set_model(adopt_ref(*new FontWeightListModel(m_weights)));
m_weight_list_view->horizontal_scrollbar().set_visible(false);
m_size_spin_box = *widget.find_descendant_of_type_named<SpinBox>("size_spin_box");
diff --git a/Userland/Libraries/LibGUI/Icon.h b/Userland/Libraries/LibGUI/Icon.h
index f33c11a7cc..3be0b7a3c4 100644
--- a/Userland/Libraries/LibGUI/Icon.h
+++ b/Userland/Libraries/LibGUI/Icon.h
@@ -15,7 +15,7 @@ namespace GUI {
class IconImpl : public RefCounted<IconImpl> {
public:
- static NonnullRefPtr<IconImpl> create() { return adopt(*new IconImpl); }
+ static NonnullRefPtr<IconImpl> create() { return adopt_ref(*new IconImpl); }
~IconImpl() { }
const Gfx::Bitmap* bitmap_for_size(int) const;
diff --git a/Userland/Libraries/LibGUI/ItemListModel.h b/Userland/Libraries/LibGUI/ItemListModel.h
index ed2f6f8ae3..fc6cbca461 100644
--- a/Userland/Libraries/LibGUI/ItemListModel.h
+++ b/Userland/Libraries/LibGUI/ItemListModel.h
@@ -27,11 +27,11 @@ public:
static NonnullRefPtr<ItemListModel> create(const Container& data, const ColumnNamesT& column_names, const Optional<size_t>& row_count = {}) requires(IsTwoDimensional)
{
- return adopt(*new ItemListModel<T, Container, ColumnNameListType>(data, column_names, row_count));
+ return adopt_ref(*new ItemListModel<T, Container, ColumnNameListType>(data, column_names, row_count));
}
static NonnullRefPtr<ItemListModel> create(const Container& data, const Optional<size_t>& row_count = {}) requires(!IsTwoDimensional)
{
- return adopt(*new ItemListModel<T, Container>(data, row_count));
+ return adopt_ref(*new ItemListModel<T, Container>(data, row_count));
}
virtual ~ItemListModel() override { }
diff --git a/Userland/Libraries/LibGUI/JsonArrayModel.h b/Userland/Libraries/LibGUI/JsonArrayModel.h
index e5a12f3507..c8233bd15e 100644
--- a/Userland/Libraries/LibGUI/JsonArrayModel.h
+++ b/Userland/Libraries/LibGUI/JsonArrayModel.h
@@ -41,7 +41,7 @@ public:
static NonnullRefPtr<JsonArrayModel> create(const String& json_path, Vector<FieldSpec>&& fields)
{
- return adopt(*new JsonArrayModel(json_path, move(fields)));
+ return adopt_ref(*new JsonArrayModel(json_path, move(fields)));
}
virtual ~JsonArrayModel() override { }
diff --git a/Userland/Libraries/LibGUI/RunningProcessesModel.cpp b/Userland/Libraries/LibGUI/RunningProcessesModel.cpp
index 2223d02f1c..653c490101 100644
--- a/Userland/Libraries/LibGUI/RunningProcessesModel.cpp
+++ b/Userland/Libraries/LibGUI/RunningProcessesModel.cpp
@@ -12,7 +12,7 @@ namespace GUI {
NonnullRefPtr<RunningProcessesModel> RunningProcessesModel::create()
{
- return adopt(*new RunningProcessesModel);
+ return adopt_ref(*new RunningProcessesModel);
}
RunningProcessesModel::RunningProcessesModel()
diff --git a/Userland/Libraries/LibGUI/SortingProxyModel.h b/Userland/Libraries/LibGUI/SortingProxyModel.h
index 6937302956..57da81998f 100644
--- a/Userland/Libraries/LibGUI/SortingProxyModel.h
+++ b/Userland/Libraries/LibGUI/SortingProxyModel.h
@@ -14,7 +14,7 @@ class SortingProxyModel
: public Model
, private ModelClient {
public:
- static NonnullRefPtr<SortingProxyModel> create(NonnullRefPtr<Model> source) { return adopt(*new SortingProxyModel(move(source))); }
+ static NonnullRefPtr<SortingProxyModel> create(NonnullRefPtr<Model> source) { return adopt_ref(*new SortingProxyModel(move(source))); }
virtual ~SortingProxyModel() override;
virtual int row_count(const ModelIndex& = ModelIndex()) const override;
diff --git a/Userland/Libraries/LibGUI/TextDocument.cpp b/Userland/Libraries/LibGUI/TextDocument.cpp
index f719a87b77..8c7f6dfb6e 100644
--- a/Userland/Libraries/LibGUI/TextDocument.cpp
+++ b/Userland/Libraries/LibGUI/TextDocument.cpp
@@ -18,7 +18,7 @@ namespace GUI {
NonnullRefPtr<TextDocument> TextDocument::create(Client* client)
{
- return adopt(*new TextDocument(client));
+ return adopt_ref(*new TextDocument(client));
}
TextDocument::TextDocument(Client* client)
diff --git a/Userland/Libraries/LibGemini/Document.cpp b/Userland/Libraries/LibGemini/Document.cpp
index ee8ad53a22..566a565af9 100644
--- a/Userland/Libraries/LibGemini/Document.cpp
+++ b/Userland/Libraries/LibGemini/Document.cpp
@@ -30,7 +30,7 @@ String Document::render_to_html() const
NonnullRefPtr<Document> Document::parse(const StringView& lines, const URL& url)
{
- auto document = adopt(*new Document(url));
+ auto document = adopt_ref(*new Document(url));
document->read_lines(lines);
return document;
}
diff --git a/Userland/Libraries/LibGemini/GeminiResponse.h b/Userland/Libraries/LibGemini/GeminiResponse.h
index 192ece3fff..a69a686cc0 100644
--- a/Userland/Libraries/LibGemini/GeminiResponse.h
+++ b/Userland/Libraries/LibGemini/GeminiResponse.h
@@ -16,7 +16,7 @@ public:
virtual ~GeminiResponse() override;
static NonnullRefPtr<GeminiResponse> create(int status, String meta)
{
- return adopt(*new GeminiResponse(status, meta));
+ return adopt_ref(*new GeminiResponse(status, meta));
}
int status() const { return m_status; }
diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp
index 325d311629..201e334a0b 100644
--- a/Userland/Libraries/LibGfx/Bitmap.cpp
+++ b/Userland/Libraries/LibGfx/Bitmap.cpp
@@ -73,7 +73,7 @@ RefPtr<Bitmap> Bitmap::create(BitmapFormat format, const IntSize& size, int scal
auto backing_store = Bitmap::allocate_backing_store(format, size, scale_factor, Purgeable::No);
if (!backing_store.has_value())
return nullptr;
- return adopt(*new Bitmap(format, size, scale_factor, Purgeable::No, backing_store.value()));
+ return adopt_ref(*new Bitmap(format, size, scale_factor, Purgeable::No, backing_store.value()));
}
RefPtr<Bitmap> Bitmap::create_purgeable(BitmapFormat format, const IntSize& size, int scale_factor)
@@ -81,7 +81,7 @@ RefPtr<Bitmap> Bitmap::create_purgeable(BitmapFormat format, const IntSize& size
auto backing_store = Bitmap::allocate_backing_store(format, size, scale_factor, Purgeable::Yes);
if (!backing_store.has_value())
return nullptr;
- return adopt(*new Bitmap(format, size, scale_factor, Purgeable::Yes, backing_store.value()));
+ return adopt_ref(*new Bitmap(format, size, scale_factor, Purgeable::Yes, backing_store.value()));
}
#ifdef __serenity__
@@ -120,7 +120,7 @@ RefPtr<Bitmap> Bitmap::create_wrapper(BitmapFormat format, const IntSize& size,
{
if (size_would_overflow(format, size, scale_factor))
return nullptr;
- return adopt(*new Bitmap(format, size, scale_factor, pitch, data));
+ return adopt_ref(*new Bitmap(format, size, scale_factor, pitch, data));
}
RefPtr<Bitmap> Bitmap::load_from_file(String const& path, int scale_factor)
@@ -219,7 +219,7 @@ RefPtr<Bitmap> Bitmap::create_with_anon_fd(BitmapFormat format, int anon_fd, con
}
}
- return adopt(*new Bitmap(format, anon_fd, size, scale_factor, data, palette));
+ return adopt_ref(*new Bitmap(format, anon_fd, size, scale_factor, data, palette));
}
/// Read a bitmap as described by:
diff --git a/Userland/Libraries/LibGfx/BitmapFont.cpp b/Userland/Libraries/LibGfx/BitmapFont.cpp
index eeac6e9055..a50ba1b454 100644
--- a/Userland/Libraries/LibGfx/BitmapFont.cpp
+++ b/Userland/Libraries/LibGfx/BitmapFont.cpp
@@ -44,7 +44,7 @@ NonnullRefPtr<Font> BitmapFont::clone() const
memcpy(new_rows, m_rows, bytes_per_glyph * m_glyph_count);
auto* new_widths = static_cast<u8*>(malloc(m_glyph_count));
memcpy(new_widths, m_glyph_widths, m_glyph_count);
- return adopt(*new BitmapFont(m_name, m_family, new_rows, new_widths, m_fixed_width, m_glyph_width, m_glyph_height, m_glyph_spacing, m_type, m_baseline, m_mean_line, m_presentation_size, m_weight, true));
+ return adopt_ref(*new BitmapFont(m_name, m_family, new_rows, new_widths, m_fixed_width, m_glyph_width, m_glyph_height, m_glyph_spacing, m_type, m_baseline, m_mean_line, m_presentation_size, m_weight, true));
}
NonnullRefPtr<BitmapFont> BitmapFont::create(u8 glyph_height, u8 glyph_width, bool fixed, FontTypes type)
@@ -55,7 +55,7 @@ NonnullRefPtr<BitmapFont> BitmapFont::create(u8 glyph_height, u8 glyph_width, bo
memset(new_rows, 0, bytes_per_glyph * count);
auto* new_widths = static_cast<u8*>(malloc(count));
memset(new_widths, 0, count);
- return adopt(*new BitmapFont("Untitled", "Untitled", new_rows, new_widths, fixed, glyph_width, glyph_height, 1, type, 0, 0, 0, 400, true));
+ return adopt_ref(*new BitmapFont("Untitled", "Untitled", new_rows, new_widths, fixed, glyph_width, glyph_height, 1, type, 0, 0, 0, 400, true));
}
BitmapFont::BitmapFont(String name, String family, unsigned* rows, u8* widths, bool is_fixed_width, u8 glyph_width, u8 glyph_height, u8 glyph_spacing, FontTypes type, u8 baseline, u8 mean_line, u8 presentation_size, u16 weight, bool owns_arrays)
@@ -137,7 +137,7 @@ RefPtr<BitmapFont> BitmapFont::load_from_memory(const u8* data)
auto* rows = const_cast<unsigned*>((const unsigned*)(data + sizeof(FontFileHeader)));
u8* widths = (u8*)(rows) + count * bytes_per_glyph;
- return adopt(*new BitmapFont(String(header.name), String(header.family), rows, widths, !header.is_variable_width, header.glyph_width, header.glyph_height, header.glyph_spacing, type, header.baseline, header.mean_line, header.presentation_size, header.weight));
+ return adopt_ref(*new BitmapFont(String(header.name), String(header.family), rows, widths, !header.is_variable_width, header.glyph_width, header.glyph_height, header.glyph_spacing, type, header.baseline, header.mean_line, header.presentation_size, header.weight));
}
size_t BitmapFont::glyph_count_by_type(FontTypes type)
diff --git a/Userland/Libraries/LibGfx/CharacterBitmap.cpp b/Userland/Libraries/LibGfx/CharacterBitmap.cpp
index 86943ba63b..5f9d2843ae 100644
--- a/Userland/Libraries/LibGfx/CharacterBitmap.cpp
+++ b/Userland/Libraries/LibGfx/CharacterBitmap.cpp
@@ -20,7 +20,7 @@ CharacterBitmap::~CharacterBitmap()
NonnullRefPtr<CharacterBitmap> CharacterBitmap::create_from_ascii(const char* asciiData, unsigned width, unsigned height)
{
- return adopt(*new CharacterBitmap(asciiData, width, height));
+ return adopt_ref(*new CharacterBitmap(asciiData, width, height));
}
}
diff --git a/Userland/Libraries/LibGfx/FontDatabase.cpp b/Userland/Libraries/LibGfx/FontDatabase.cpp
index 7840549c17..44b934d109 100644
--- a/Userland/Libraries/LibGfx/FontDatabase.cpp
+++ b/Userland/Libraries/LibGfx/FontDatabase.cpp
@@ -158,7 +158,7 @@ RefPtr<Typeface> FontDatabase::get_or_create_typeface(const String& family, cons
if (typeface->family() == family && typeface->variant() == variant)
return typeface;
}
- auto typeface = adopt(*new Typeface(family, variant));
+ auto typeface = adopt_ref(*new Typeface(family, variant));
m_private->typefaces.append(typeface);
return typeface;
}
diff --git a/Userland/Libraries/LibGfx/ImageDecoder.h b/Userland/Libraries/LibGfx/ImageDecoder.h
index 497cfd9ed6..0855673871 100644
--- a/Userland/Libraries/LibGfx/ImageDecoder.h
+++ b/Userland/Libraries/LibGfx/ImageDecoder.h
@@ -48,8 +48,8 @@ protected:
class ImageDecoder : public RefCounted<ImageDecoder> {
public:
- static NonnullRefPtr<ImageDecoder> create(const u8* data, size_t size) { return adopt(*new ImageDecoder(data, size)); }
- static NonnullRefPtr<ImageDecoder> create(const ByteBuffer& data) { return adopt(*new ImageDecoder(data.data(), data.size())); }
+ static NonnullRefPtr<ImageDecoder> create(const u8* data, size_t size) { return adopt_ref(*new ImageDecoder(data, size)); }
+ static NonnullRefPtr<ImageDecoder> create(const ByteBuffer& data) { return adopt_ref(*new ImageDecoder(data.data(), data.size())); }
~ImageDecoder();
bool is_valid() const { return m_plugin; }
diff --git a/Userland/Libraries/LibGfx/Palette.cpp b/Userland/Libraries/LibGfx/Palette.cpp
index 761765db8b..d45b6c0881 100644
--- a/Userland/Libraries/LibGfx/Palette.cpp
+++ b/Userland/Libraries/LibGfx/Palette.cpp
@@ -12,7 +12,7 @@ namespace Gfx {
NonnullRefPtr<PaletteImpl> PaletteImpl::create_with_anonymous_buffer(Core::AnonymousBuffer buffer)
{
- return adopt(*new PaletteImpl(move(buffer)));
+ return adopt_ref(*new PaletteImpl(move(buffer)));
}
PaletteImpl::PaletteImpl(Core::AnonymousBuffer buffer)
@@ -45,7 +45,7 @@ NonnullRefPtr<PaletteImpl> PaletteImpl::clone() const
{
auto new_theme_buffer = Core::AnonymousBuffer::create_with_size(m_theme_buffer.size());
memcpy(new_theme_buffer.data<SystemTheme>(), &theme(), m_theme_buffer.size());
- return adopt(*new PaletteImpl(move(new_theme_buffer)));
+ return adopt_ref(*new PaletteImpl(move(new_theme_buffer)));
}
void Palette::set_color(ColorRole role, Color color)
diff --git a/Userland/Libraries/LibGfx/Path.h b/Userland/Libraries/LibGfx/Path.h
index 40cfdcc769..62a7a80558 100644
--- a/Userland/Libraries/LibGfx/Path.h
+++ b/Userland/Libraries/LibGfx/Path.h
@@ -197,7 +197,7 @@ private:
template<typename T, typename... Args>
void append_segment(Args&&... args)
{
- m_segments.append(adopt(*new T(forward<Args>(args)...)));
+ m_segments.append(adopt_ref(*new T(forward<Args>(args)...)));
}
NonnullRefPtrVector<Segment> m_segments {};
diff --git a/Userland/Libraries/LibGfx/Typeface.cpp b/Userland/Libraries/LibGfx/Typeface.cpp
index b8f7cc2ce2..4fe7bba05a 100644
--- a/Userland/Libraries/LibGfx/Typeface.cpp
+++ b/Userland/Libraries/LibGfx/Typeface.cpp
@@ -46,7 +46,7 @@ RefPtr<Font> Typeface::get_font(unsigned size)
}
if (m_ttf_font)
- return adopt(*new TTF::ScaledFont(*m_ttf_font, size, size));
+ return adopt_ref(*new TTF::ScaledFont(*m_ttf_font, size, size));
return {};
}
diff --git a/Userland/Libraries/LibHTTP/HttpResponse.h b/Userland/Libraries/LibHTTP/HttpResponse.h
index d46e30c32a..897e013684 100644
--- a/Userland/Libraries/LibHTTP/HttpResponse.h
+++ b/Userland/Libraries/LibHTTP/HttpResponse.h
@@ -17,7 +17,7 @@ public:
virtual ~HttpResponse() override;
static NonnullRefPtr<HttpResponse> create(int code, HashMap<String, String, CaseInsensitiveStringTraits>&& headers)
{
- return adopt(*new HttpResponse(code, move(headers)));
+ return adopt_ref(*new HttpResponse(code, move(headers)));
}
int code() const { return m_code; }
diff --git a/Userland/Libraries/LibJS/AST.h b/Userland/Libraries/LibJS/AST.h
index 488bf090ad..e307e08ead 100644
--- a/Userland/Libraries/LibJS/AST.h
+++ b/Userland/Libraries/LibJS/AST.h
@@ -27,7 +27,7 @@ template<class T, class... Args>
static inline NonnullRefPtr<T>
create_ast_node(SourceRange range, Args&&... args)
{
- return adopt(*new T(range, forward<Args>(args)...));
+ return adopt_ref(*new T(range, forward<Args>(args)...));
}
class ASTNode : public RefCounted<ASTNode> {
diff --git a/Userland/Libraries/LibJS/Heap/Handle.h b/Userland/Libraries/LibJS/Heap/Handle.h
index ef720584c1..ace0257ade 100644
--- a/Userland/Libraries/LibJS/Heap/Handle.h
+++ b/Userland/Libraries/LibJS/Heap/Handle.h
@@ -39,7 +39,7 @@ public:
static Handle create(T* cell)
{
- return Handle(adopt(*new HandleImpl(cell)));
+ return Handle(adopt_ref(*new HandleImpl(cell)));
}
T* cell() { return static_cast<T*>(m_impl->cell()); }
diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp
index be5bf07337..f34d6eb2e2 100644
--- a/Userland/Libraries/LibJS/Parser.cpp
+++ b/Userland/Libraries/LibJS/Parser.cpp
@@ -228,7 +228,7 @@ NonnullRefPtr<Program> Parser::parse_program()
{
auto rule_start = push_start();
ScopePusher scope(*this, ScopePusher::Var | ScopePusher::Let | ScopePusher::Function);
- auto program = adopt(*new Program({ m_filename, rule_start.position(), position() }));
+ auto program = adopt_ref(*new Program({ m_filename, rule_start.position(), position() }));
bool first = true;
while (!done()) {
diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp
index da77d31b40..b7fc15c781 100644
--- a/Userland/Libraries/LibJS/Runtime/VM.cpp
+++ b/Userland/Libraries/LibJS/Runtime/VM.cpp
@@ -24,7 +24,7 @@ namespace JS {
NonnullRefPtr<VM> VM::create()
{
- return adopt(*new VM);
+ return adopt_ref(*new VM);
}
VM::VM()
diff --git a/Userland/Libraries/LibPCIDB/Database.cpp b/Userland/Libraries/LibPCIDB/Database.cpp
index 5b93cd2171..3821049d68 100644
--- a/Userland/Libraries/LibPCIDB/Database.cpp
+++ b/Userland/Libraries/LibPCIDB/Database.cpp
@@ -17,7 +17,7 @@ RefPtr<Database> Database::open(const String& file_name)
auto file_or_error = MappedFile::map(file_name);
if (file_or_error.is_error())
return nullptr;
- auto res = adopt(*new Database(file_or_error.release_value()));
+ auto res = adopt_ref(*new Database(file_or_error.release_value()));
if (res->init() != 0)
return nullptr;
return res;
diff --git a/Userland/Libraries/LibProtocol/Download.h b/Userland/Libraries/LibProtocol/Download.h
index ec2ac28d95..8dfdd47036 100644
--- a/Userland/Libraries/LibProtocol/Download.h
+++ b/Userland/Libraries/LibProtocol/Download.h
@@ -30,7 +30,7 @@ public:
static NonnullRefPtr<Download> create_from_id(Badge<Client>, Client& client, i32 download_id)
{
- return adopt(*new Download(client, download_id));
+ return adopt_ref(*new Download(client, download_id));
}
int id() const { return m_download_id; }
diff --git a/Userland/Libraries/LibSQL/AST.h b/Userland/Libraries/LibSQL/AST.h
index fed6eaf0c0..922432b48a 100644
--- a/Userland/Libraries/LibSQL/AST.h
+++ b/Userland/Libraries/LibSQL/AST.h
@@ -20,7 +20,7 @@ template<class T, class... Args>
static inline NonnullRefPtr<T>
create_ast_node(Args&&... args)
{
- return adopt(*new T(forward<Args>(args)...));
+ return adopt_ref(*new T(forward<Args>(args)...));
}
class ASTNode : public RefCounted<ASTNode> {
diff --git a/Userland/Libraries/LibTTF/Font.cpp b/Userland/Libraries/LibTTF/Font.cpp
index 73388f6f37..71d28bdb93 100644
--- a/Userland/Libraries/LibTTF/Font.cpp
+++ b/Userland/Libraries/LibTTF/Font.cpp
@@ -389,7 +389,7 @@ RefPtr<Font> Font::load_from_offset(ByteBuffer&& buffer, u32 offset)
}
}
- return adopt(*new Font(move(buffer), move(head), move(name), move(hhea), move(maxp), move(hmtx), move(cmap), move(loca), move(glyf)));
+ return adopt_ref(*new Font(move(buffer), move(head), move(name), move(hhea), move(maxp), move(hmtx), move(cmap), move(loca), move(glyf)));
}
ScaledFontMetrics Font::metrics(float x_scale, float y_scale) const
diff --git a/Userland/Libraries/LibThread/BackgroundAction.h b/Userland/Libraries/LibThread/BackgroundAction.h
index 066770fad4..c3664db039 100644
--- a/Userland/Libraries/LibThread/BackgroundAction.h
+++ b/Userland/Libraries/LibThread/BackgroundAction.h
@@ -42,7 +42,7 @@ public:
Function<Result()> action,
Function<void(Result)> on_complete = nullptr)
{
- return adopt(*new BackgroundAction(move(action), move(on_complete)));
+ return adopt_ref(*new BackgroundAction(move(action), move(on_complete)));
}
virtual ~BackgroundAction() { }
diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h
index 6b5c3d376c..cd3cc32b81 100644
--- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h
+++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h
@@ -18,7 +18,7 @@ class CSSImportRule : public CSSRule {
public:
static NonnullRefPtr<CSSImportRule> create(URL url)
{
- return adopt(*new CSSImportRule(move(url)));
+ return adopt_ref(*new CSSImportRule(move(url)));
}
~CSSImportRule();
diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h
index 92f97d2a64..2a8ad6a672 100644
--- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h
+++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h
@@ -27,7 +27,7 @@ public:
static NonnullRefPtr<CSSStyleDeclaration> create(Vector<StyleProperty>&& properties)
{
- return adopt(*new CSSStyleDeclaration(move(properties)));
+ return adopt_ref(*new CSSStyleDeclaration(move(properties)));
}
virtual ~CSSStyleDeclaration();
@@ -48,7 +48,7 @@ private:
class ElementInlineCSSStyleDeclaration final : public CSSStyleDeclaration {
public:
- static NonnullRefPtr<ElementInlineCSSStyleDeclaration> create(DOM::Element& element) { return adopt(*new ElementInlineCSSStyleDeclaration(element)); }
+ static NonnullRefPtr<ElementInlineCSSStyleDeclaration> create(DOM::Element& element) { return adopt_ref(*new ElementInlineCSSStyleDeclaration(element)); }
virtual ~ElementInlineCSSStyleDeclaration() override;
DOM::Element* element() { return m_element.ptr(); }
diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h
index c778df7b3b..41dce31a78 100644
--- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h
+++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h
@@ -21,7 +21,7 @@ class CSSStyleRule : public CSSRule {
public:
static NonnullRefPtr<CSSStyleRule> create(Vector<Selector>&& selectors, NonnullRefPtr<CSSStyleDeclaration>&& declaration)
{
- return adopt(*new CSSStyleRule(move(selectors), move(declaration)));
+ return adopt_ref(*new CSSStyleRule(move(selectors), move(declaration)));
}
~CSSStyleRule();
diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h
index 3ad97bc56e..ea9904de49 100644
--- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h
+++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h
@@ -21,7 +21,7 @@ public:
static NonnullRefPtr<CSSStyleSheet> create(NonnullRefPtrVector<CSSRule> rules)
{
- return adopt(*new CSSStyleSheet(move(rules)));
+ return adopt_ref(*new CSSStyleSheet(move(rules)));
}
virtual ~CSSStyleSheet() override;
diff --git a/Userland/Libraries/LibWeb/CSS/Screen.h b/Userland/Libraries/LibWeb/CSS/Screen.h
index c17197afc9..7ca9b0f6d0 100644
--- a/Userland/Libraries/LibWeb/CSS/Screen.h
+++ b/Userland/Libraries/LibWeb/CSS/Screen.h
@@ -21,7 +21,7 @@ public:
static NonnullRefPtr<Screen> create(DOM::Window& window)
{
- return adopt(*new Screen(window));
+ return adopt_ref(*new Screen(window));
}
i32 width() const { return screen_rect().width(); }
diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
index 739ace583e..853ca513dd 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
@@ -28,7 +28,7 @@ StyleProperties::StyleProperties(const StyleProperties& other)
NonnullRefPtr<StyleProperties> StyleProperties::clone() const
{
- return adopt(*new StyleProperties(*this));
+ return adopt_ref(*new StyleProperties(*this));
}
void StyleProperties::set_property(CSS::PropertyID id, NonnullRefPtr<StyleValue> value)
diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.h b/Userland/Libraries/LibWeb/CSS/StyleProperties.h
index 1b493d5063..6cdaafcff5 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleProperties.h
+++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.h
@@ -21,7 +21,7 @@ public:
explicit StyleProperties(const StyleProperties&);
- static NonnullRefPtr<StyleProperties> create() { return adopt(*new StyleProperties); }
+ static NonnullRefPtr<StyleProperties> create() { return adopt_ref(*new StyleProperties); }
NonnullRefPtr<StyleProperties> clone() const;
diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h
index ff4d63fee1..5b52008f3a 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h
+++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h
@@ -22,7 +22,7 @@ public:
static NonnullRefPtr<StyleSheetList> create(DOM::Document& document)
{
- return adopt(*new StyleSheetList(document));
+ return adopt_ref(*new StyleSheetList(document));
}
void add_sheet(NonnullRefPtr<CSSStyleSheet>);
diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h
index 0051b72a3f..d4ad707d38 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleValue.h
+++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h
@@ -232,7 +232,7 @@ class StringStyleValue : public StyleValue {
public:
static NonnullRefPtr<StringStyleValue> create(const String& string)
{
- return adopt(*new StringStyleValue(string));
+ return adopt_ref(*new StringStyleValue(string));
}
virtual ~StringStyleValue() override { }
@@ -252,7 +252,7 @@ class LengthStyleValue : public StyleValue {
public:
static NonnullRefPtr<LengthStyleValue> create(const Length& length)
{
- return adopt(*new LengthStyleValue(length));
+ return adopt_ref(*new LengthStyleValue(length));
}
virtual ~LengthStyleValue() override { }
@@ -282,7 +282,7 @@ private:
class InitialStyleValue final : public StyleValue {
public:
- static NonnullRefPtr<InitialStyleValue> create() { return adopt(*new InitialStyleValue); }
+ static NonnullRefPtr<InitialStyleValue> create() { return adopt_ref(*new InitialStyleValue); }
virtual ~InitialStyleValue() override { }
String to_string() const override { return "initial"; }
@@ -296,7 +296,7 @@ private:
class InheritStyleValue final : public StyleValue {
public:
- static NonnullRefPtr<InheritStyleValue> create() { return adopt(*new InheritStyleValue); }
+ static NonnullRefPtr<InheritStyleValue> create() { return adopt_ref(*new InheritStyleValue); }
virtual ~InheritStyleValue() override { }
String to_string() const override { return "inherit"; }
@@ -312,7 +312,7 @@ class ColorStyleValue : public StyleValue {
public:
static NonnullRefPtr<ColorStyleValue> create(Color color)
{
- return adopt(*new ColorStyleValue(color));
+ return adopt_ref(*new ColorStyleValue(color));
}
virtual ~ColorStyleValue() override { }
@@ -341,7 +341,7 @@ class IdentifierStyleValue final : public StyleValue {
public:
static NonnullRefPtr<IdentifierStyleValue> create(CSS::ValueID id)
{
- return adopt(*new IdentifierStyleValue(id));
+ return adopt_ref(*new IdentifierStyleValue(id));
}
virtual ~IdentifierStyleValue() override { }
@@ -371,7 +371,7 @@ class ImageStyleValue final
: public StyleValue
, public ImageResourceClient {
public:
- static NonnullRefPtr<ImageStyleValue> create(const URL& url, DOM::Document& document) { return adopt(*new ImageStyleValue(url, document)); }
+ static NonnullRefPtr<ImageStyleValue> create(const URL& url, DOM::Document& document) { return adopt_ref(*new ImageStyleValue(url, document)); }
virtual ~ImageStyleValue() override { }
String to_string() const override { return String::formatted("Image({})", m_url.to_string()); }
diff --git a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
index 52d2e80e41..470135b4ae 100644
--- a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
+++ b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
@@ -553,7 +553,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotA, "Function");
@return_statement@
}
- @cpp_name@ = adopt(*new EventListener(JS::make_handle(&@js_name@@js_suffix@.as_function())));
+ @cpp_name@ = adopt_ref(*new EventListener(JS::make_handle(&@js_name@@js_suffix@.as_function())));
}
)~~~");
} else {
@@ -562,7 +562,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotA, "Function");
@return_statement@
}
- auto @cpp_name@ = adopt(*new EventListener(JS::make_handle(&@js_name@@js_suffix@.as_function())));
+ auto @cpp_name@ = adopt_ref(*new EventListener(JS::make_handle(&@js_name@@js_suffix@.as_function())));
)~~~");
}
} else if (is_wrappable_type(parameter.type)) {
diff --git a/Userland/Libraries/LibWeb/DOM/DOMException.h b/Userland/Libraries/LibWeb/DOM/DOMException.h
index 6b67558b61..6e837ec22d 100644
--- a/Userland/Libraries/LibWeb/DOM/DOMException.h
+++ b/Userland/Libraries/LibWeb/DOM/DOMException.h
@@ -98,13 +98,13 @@ public:
static NonnullRefPtr<DOMException> create(const FlyString& name, const FlyString& message)
{
- return adopt(*new DOMException(name, message));
+ return adopt_ref(*new DOMException(name, message));
}
// JS constructor has message first, name second
static NonnullRefPtr<DOMException> create_with_global_object(Bindings::WindowObject&, const FlyString& message, const FlyString& name)
{
- return adopt(*new DOMException(name, message));
+ return adopt_ref(*new DOMException(name, message));
}
const FlyString& name() const { return m_name; }
diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp
index 4e602f9231..04493eda8b 100644
--- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp
+++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp
@@ -26,7 +26,7 @@ const NonnullRefPtr<Document> DOMImplementation::create_html_document(const Stri
html_document->set_content_type("text/html");
html_document->set_ready_for_post_load_tasks(true);
- auto doctype = adopt(*new DocumentType(html_document));
+ auto doctype = adopt_ref(*new DocumentType(html_document));
doctype->set_name("html");
html_document->append_child(doctype);
@@ -40,7 +40,7 @@ const NonnullRefPtr<Document> DOMImplementation::create_html_document(const Stri
auto title_element = create_element(html_document, HTML::TagNames::title, Namespace::HTML);
head_element->append_child(title_element);
- auto text_node = adopt(*new Text(html_document, title));
+ auto text_node = adopt_ref(*new Text(html_document, title));
title_element->append_child(text_node);
}
diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h
index 759c1d0b4b..2635030adc 100644
--- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h
+++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h
@@ -22,7 +22,7 @@ public:
static NonnullRefPtr<DOMImplementation> create(Document& document)
{
- return adopt(*new DOMImplementation(document));
+ return adopt_ref(*new DOMImplementation(document));
}
const NonnullRefPtr<Document> create_html_document(const String& title) const;
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index c6e1b41f96..3e3e8e82a2 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -269,7 +269,7 @@ void Document::set_title(const String& title)
}
title_element->remove_all_children(true);
- title_element->append_child(adopt(*new Text(*this, title)));
+ title_element->append_child(adopt_ref(*new Text(*this, title)));
if (auto* page = this->page()) {
if (frame() == &page->main_frame())
@@ -433,7 +433,7 @@ void Document::update_style()
RefPtr<Layout::Node> Document::create_layout_node()
{
- return adopt(*new Layout::InitialContainingBlockBox(*this, CSS::StyleProperties::create()));
+ return adopt_ref(*new Layout::InitialContainingBlockBox(*this, CSS::StyleProperties::create()));
}
void Document::set_link_color(Color color)
@@ -598,17 +598,17 @@ NonnullRefPtr<Element> Document::create_element_ns(const String& namespace_, con
NonnullRefPtr<DocumentFragment> Document::create_document_fragment()
{
- return adopt(*new DocumentFragment(*this));
+ return adopt_ref(*new DocumentFragment(*this));
}
NonnullRefPtr<Text> Document::create_text_node(const String& data)
{
- return adopt(*new Text(*this, data));
+ return adopt_ref(*new Text(*this, data));
}
NonnullRefPtr<Comment> Document::create_comment(const String& data)
{
- return adopt(*new Comment(*this, data));
+ return adopt_ref(*new Comment(*this, data));
}
NonnullRefPtr<Range> Document::create_range()
@@ -732,10 +732,10 @@ void Document::adopt_node(Node& node)
ExceptionOr<NonnullRefPtr<Node>> Document::adopt_node_binding(NonnullRefPtr<Node> node)
{
if (is<Document>(*node))
- return DOM ::NotSupportedError::create("Cannot adopt a document into a document");
+ return DOM ::NotSupportedError::create("Cannot adopt_ref a document into a document");
if (is<ShadowRoot>(*node))
- return DOM::HierarchyRequestError::create("Cannot adopt a shadow root into a document");
+ return DOM::HierarchyRequestError::create("Cannot adopt_ref a shadow root into a document");
if (is<DocumentFragment>(*node) && downcast<DocumentFragment>(*node).host())
return node;
diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h
index f070ac17fd..d1c062507c 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.h
+++ b/Userland/Libraries/LibWeb/DOM/Document.h
@@ -45,7 +45,7 @@ public:
static NonnullRefPtr<Document> create(const URL& url = "about:blank")
{
- return adopt(*new Document(url));
+ return adopt_ref(*new Document(url));
}
static NonnullRefPtr<Document> create_with_global_object(Bindings::WindowObject&)
{
diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp
index 8ec37bd14a..37cff6ec5f 100644
--- a/Userland/Libraries/LibWeb/DOM/Element.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Element.cpp
@@ -115,35 +115,35 @@ RefPtr<Layout::Node> Element::create_layout_node()
VERIFY_NOT_REACHED();
break;
case CSS::Display::Block:
- return adopt(*new Layout::BlockBox(document(), this, move(style)));
+ return adopt_ref(*new Layout::BlockBox(document(), this, move(style)));
case CSS::Display::Inline:
if (style->float_().value_or(CSS::Float::None) != CSS::Float::None)
- return adopt(*new Layout::BlockBox(document(), this, move(style)));
- return adopt(*new Layout::InlineNode(document(), *this, move(style)));
+ return adopt_ref(*new Layout::BlockBox(document(), this, move(style)));
+ return adopt_ref(*new Layout::InlineNode(document(), *this, move(style)));
case CSS::Display::ListItem:
- return adopt(*new Layout::ListItemBox(document(), *this, move(style)));
+ return adopt_ref(*new Layout::ListItemBox(document(), *this, move(style)));
case CSS::Display::Table:
- return adopt(*new Layout::TableBox(document(), this, move(style)));
+ return adopt_ref(*new Layout::TableBox(document(), this, move(style)));
case CSS::Display::TableRow:
- return adopt(*new Layout::TableRowBox(document(), this, move(style)));
+ return adopt_ref(*new Layout::TableRowBox(document(), this, move(style)));
case CSS::Display::TableCell:
- return adopt(*new Layout::TableCellBox(document(), this, move(style)));
+ return adopt_ref(*new Layout::TableCellBox(document(), this, move(style)));
case CSS::Display::TableRowGroup:
case CSS::Display::TableHeaderGroup:
case CSS::Display::TableFooterGroup:
- return adopt(*new Layout::TableRowGroupBox(document(), *this, move(style)));
+ return adopt_ref(*new Layout::TableRowGroupBox(document(), *this, move(style)));
case CSS::Display::InlineBlock: {
- auto inline_block = adopt(*new Layout::BlockBox(document(), this, move(style)));
+ auto inline_block = adopt_ref(*new Layout::BlockBox(document(), this, move(style)));
inline_block->set_inline(true);
return inline_block;
}
case CSS::Display::Flex:
- return adopt(*new Layout::BlockBox(document(), this, move(style)));
+ return adopt_ref(*new Layout::BlockBox(document(), this, move(style)));
case CSS::Display::TableColumn:
case CSS::Display::TableColumnGroup:
case CSS::Display::TableCaption:
// FIXME: This is just an incorrect placeholder until we improve table layout support.
- return adopt(*new Layout::BlockBox(document(), this, move(style)));
+ return adopt_ref(*new Layout::BlockBox(document(), this, move(style)));
}
VERIFY_NOT_REACHED();
}
diff --git a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp
index 3601cd9704..db06933113 100644
--- a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp
+++ b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp
@@ -88,157 +88,157 @@ NonnullRefPtr<Element> create_element(Document& document, const FlyString& tag_n
// FIXME: Add prefix when we support it.
auto qualified_name = QualifiedName(tag_name, {}, namespace_);
if (lowercase_tag_name == HTML::TagNames::a)
- return adopt(*new HTML::HTMLAnchorElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLAnchorElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::area)
- return adopt(*new HTML::HTMLAreaElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLAreaElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::audio)
- return adopt(*new HTML::HTMLAudioElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLAudioElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::base)
- return adopt(*new HTML::HTMLBaseElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLBaseElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::blink)
- return adopt(*new HTML::HTMLBlinkElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLBlinkElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::body)
- return adopt(*new HTML::HTMLBodyElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLBodyElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::br)
- return adopt(*new HTML::HTMLBRElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLBRElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::button)
- return adopt(*new HTML::HTMLButtonElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLButtonElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::canvas)
- return adopt(*new HTML::HTMLCanvasElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLCanvasElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::data)
- return adopt(*new HTML::HTMLDataElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLDataElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::datalist)
- return adopt(*new HTML::HTMLDataListElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLDataListElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::details)
- return adopt(*new HTML::HTMLDetailsElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLDetailsElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::dialog)
- return adopt(*new HTML::HTMLDialogElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLDialogElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::dir)
- return adopt(*new HTML::HTMLDirectoryElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLDirectoryElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::div)
- return adopt(*new HTML::HTMLDivElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLDivElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::dl)
- return adopt(*new HTML::HTMLDListElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLDListElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::embed)
- return adopt(*new HTML::HTMLEmbedElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLEmbedElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::fieldset)
- return adopt(*new HTML::HTMLFieldSetElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLFieldSetElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::font)
- return adopt(*new HTML::HTMLFontElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLFontElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::form)
- return adopt(*new HTML::HTMLFormElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLFormElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::frame)
- return adopt(*new HTML::HTMLFrameElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLFrameElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::frameset)
- return adopt(*new HTML::HTMLFrameSetElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLFrameSetElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::head)
- return adopt(*new HTML::HTMLHeadElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLHeadElement(document, move(qualified_name)));
if (lowercase_tag_name.is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6))
- return adopt(*new HTML::HTMLHeadingElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLHeadingElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::hr)
- return adopt(*new HTML::HTMLHRElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLHRElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::html)
- return adopt(*new HTML::HTMLHtmlElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLHtmlElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::iframe)
- return adopt(*new HTML::HTMLIFrameElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLIFrameElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::img)
- return adopt(*new HTML::HTMLImageElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLImageElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::input)
- return adopt(*new HTML::HTMLInputElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLInputElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::label)
- return adopt(*new HTML::HTMLLabelElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLLabelElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::legend)
- return adopt(*new HTML::HTMLLegendElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLLegendElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::li)
- return adopt(*new HTML::HTMLLIElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLLIElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::link)
- return adopt(*new HTML::HTMLLinkElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLLinkElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::map)
- return adopt(*new HTML::HTMLMapElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLMapElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::marquee)
- return adopt(*new HTML::HTMLMarqueeElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLMarqueeElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::menu)
- return adopt(*new HTML::HTMLMenuElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLMenuElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::meta)
- return adopt(*new HTML::HTMLMetaElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLMetaElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::meter)
- return adopt(*new HTML::HTMLMeterElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLMeterElement(document, move(qualified_name)));
if (lowercase_tag_name.is_one_of(HTML::TagNames::ins, HTML::TagNames::del))
- return adopt(*new HTML::HTMLModElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLModElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::object)
- return adopt(*new HTML::HTMLObjectElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLObjectElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::ol)
- return adopt(*new HTML::HTMLOListElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLOListElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::optgroup)
- return adopt(*new HTML::HTMLOptGroupElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLOptGroupElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::option)
- return adopt(*new HTML::HTMLOptionElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLOptionElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::output)
- return adopt(*new HTML::HTMLOutputElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLOutputElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::p)
- return adopt(*new HTML::HTMLParagraphElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLParagraphElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::param)
- return adopt(*new HTML::HTMLParamElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLParamElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::picture)
- return adopt(*new HTML::HTMLPictureElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLPictureElement(document, move(qualified_name)));
// NOTE: The obsolete elements "listing" and "xmp" are explicitly mapped to HTMLPreElement in the specification.
if (lowercase_tag_name.is_one_of(HTML::TagNames::pre, HTML::TagNames::listing, HTML::TagNames::xmp))
- return adopt(*new HTML::HTMLPreElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLPreElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::progress)
- return adopt(*new HTML::HTMLProgressElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLProgressElement(document, move(qualified_name)));
if (lowercase_tag_name.is_one_of(HTML::TagNames::blockquote, HTML::TagNames::q))
- return adopt(*new HTML::HTMLQuoteElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLQuoteElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::script)
- return adopt(*new HTML::HTMLScriptElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLScriptElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::select)
- return adopt(*new HTML::HTMLSelectElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLSelectElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::slot)
- return adopt(*new HTML::HTMLSlotElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLSlotElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::source)
- return adopt(*new HTML::HTMLSourceElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLSourceElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::span)
- return adopt(*new HTML::HTMLSpanElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLSpanElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::style)
- return adopt(*new HTML::HTMLStyleElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLStyleElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::caption)
- return adopt(*new HTML::HTMLTableCaptionElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLTableCaptionElement(document, move(qualified_name)));
if (lowercase_tag_name.is_one_of(Web::HTML::TagNames::td, Web::HTML::TagNames::th))
- return adopt(*new HTML::HTMLTableCellElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLTableCellElement(document, move(qualified_name)));
if (lowercase_tag_name.is_one_of(HTML::TagNames::colgroup, HTML::TagNames::col))
- return adopt(*new HTML::HTMLTableColElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLTableColElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::table)
- return adopt(*new HTML::HTMLTableElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLTableElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::tr)
- return adopt(*new HTML::HTMLTableRowElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLTableRowElement(document, move(qualified_name)));
if (lowercase_tag_name.is_one_of(HTML::TagNames::tbody, HTML::TagNames::thead, HTML::TagNames::tfoot))
- return adopt(*new HTML::HTMLTableSectionElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLTableSectionElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::template_)
- return adopt(*new HTML::HTMLTemplateElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLTemplateElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::textarea)
- return adopt(*new HTML::HTMLTextAreaElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLTextAreaElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::time)
- return adopt(*new HTML::HTMLTimeElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLTimeElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::title)
- return adopt(*new HTML::HTMLTitleElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLTitleElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::track)
- return adopt(*new HTML::HTMLTrackElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLTrackElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::ul)
- return adopt(*new HTML::HTMLUListElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLUListElement(document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::video)
- return adopt(*new HTML::HTMLVideoElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLVideoElement(document, move(qualified_name)));
if (lowercase_tag_name.is_one_of(
HTML::TagNames::article, HTML::TagNames::section, HTML::TagNames::nav, HTML::TagNames::aside, HTML::TagNames::hgroup, HTML::TagNames::header, HTML::TagNames::footer, HTML::TagNames::address, HTML::TagNames::dt, HTML::TagNames::dd, HTML::TagNames::figure, HTML::TagNames::figcaption, HTML::TagNames::main, HTML::TagNames::em, HTML::TagNames::strong, HTML::TagNames::small, HTML::TagNames::s, HTML::TagNames::cite, HTML::TagNames::dfn, HTML::TagNames::abbr, HTML::TagNames::ruby, HTML::TagNames::rt, HTML::TagNames::rp, HTML::TagNames::code, HTML::TagNames::var, HTML::TagNames::samp, HTML::TagNames::kbd, HTML::TagNames::sub, HTML::TagNames::sup, HTML::TagNames::i, HTML::TagNames::b, HTML::TagNames::u, HTML::TagNames::mark, HTML::TagNames::bdi, HTML::TagNames::bdo, HTML::TagNames::wbr, HTML::TagNames::summary, HTML::TagNames::noscript,
// Obsolete
HTML::TagNames::acronym, HTML::TagNames::basefont, HTML::TagNames::big, HTML::TagNames::center, HTML::TagNames::nobr, HTML::TagNames::noembed, HTML::TagNames::noframes, HTML::TagNames::plaintext, HTML::TagNames::rb, HTML::TagNames::rtc, HTML::TagNames::strike, HTML::TagNames::tt))
- return adopt(*new HTML::HTMLElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLElement(document, move(qualified_name)));
if (lowercase_tag_name == SVG::TagNames::svg)
- return adopt(*new SVG::SVGSVGElement(document, move(qualified_name)));
+ return adopt_ref(*new SVG::SVGSVGElement(document, move(qualified_name)));
if (lowercase_tag_name == SVG::TagNames::path)
- return adopt(*new SVG::SVGPathElement(document, move(qualified_name)));
+ return adopt_ref(*new SVG::SVGPathElement(document, move(qualified_name)));
// FIXME: If name is a valid custom element name, then return HTMLElement.
- return adopt(*new HTML::HTMLUnknownElement(document, move(qualified_name)));
+ return adopt_ref(*new HTML::HTMLUnknownElement(document, move(qualified_name)));
}
}
diff --git a/Userland/Libraries/LibWeb/DOM/Event.h b/Userland/Libraries/LibWeb/DOM/Event.h
index 7fbe7db1a2..1da8eadc4e 100644
--- a/Userland/Libraries/LibWeb/DOM/Event.h
+++ b/Userland/Libraries/LibWeb/DOM/Event.h
@@ -43,7 +43,7 @@ public:
static NonnullRefPtr<Event> create(const FlyString& event_name)
{
- return adopt(*new Event(event_name));
+ return adopt_ref(*new Event(event_name));
}
static NonnullRefPtr<Event> create_with_global_object(Bindings::WindowObject&, const FlyString& event_name)
{
diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h
index a4c87f4fe4..8ee6c69d53 100644
--- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h
+++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h
@@ -36,7 +36,7 @@ public:
static NonnullRefPtr<HTMLCollection> create(ParentNode& root, Function<bool(Element const&)> filter)
{
- return adopt(*new HTMLCollection(root, move(filter)));
+ return adopt_ref(*new HTMLCollection(root, move(filter)));
}
~HTMLCollection();
diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp
index e8c66af51d..058dda44cc 100644
--- a/Userland/Libraries/LibWeb/DOM/Node.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Node.cpp
@@ -354,7 +354,7 @@ NonnullRefPtr<Node> Node::clone_node(Document* document, bool clone_children) co
if (is<Element>(this)) {
auto& element = *downcast<Element>(this);
auto qualified_name = QualifiedName(element.local_name(), element.prefix(), element.namespace_());
- auto element_copy = adopt(*new Element(*document, move(qualified_name)));
+ auto element_copy = adopt_ref(*new Element(*document, move(qualified_name)));
element.for_each_attribute([&](auto& name, auto& value) {
element_copy->set_attribute(name, value);
});
@@ -370,22 +370,22 @@ NonnullRefPtr<Node> Node::clone_node(Document* document, bool clone_children) co
copy = move(document_copy);
} else if (is<DocumentType>(this)) {
auto document_type = downcast<DocumentType>(this);
- auto document_type_copy = adopt(*new DocumentType(*document));
+ auto document_type_copy = adopt_ref(*new DocumentType(*document));
document_type_copy->set_name(document_type->name());
document_type_copy->set_public_id(document_type->public_id());
document_type_copy->set_system_id(document_type->system_id());
copy = move(document_type_copy);
} else if (is<Text>(this)) {
auto text = downcast<Text>(this);
- auto text_copy = adopt(*new Text(*document, text->data()));
+ auto text_copy = adopt_ref(*new Text(*document, text->data()));
copy = move(text_copy);
} else if (is<Comment>(this)) {
auto comment = downcast<Comment>(this);
- auto comment_copy = adopt(*new Comment(*document, comment->data()));
+ auto comment_copy = adopt_ref(*new Comment(*document, comment->data()));
copy = move(comment_copy);
} else if (is<ProcessingInstruction>(this)) {
auto processing_instruction = downcast<ProcessingInstruction>(this);
- auto processing_instruction_copy = adopt(*new ProcessingInstruction(*document, processing_instruction->data(), processing_instruction->target()));
+ auto processing_instruction_copy = adopt_ref(*new ProcessingInstruction(*document, processing_instruction->data(), processing_instruction->target()));
copy = move(processing_instruction_copy);
} else {
dbgln("clone_node() not implemented for NodeType {}", (u16)m_type);
diff --git a/Userland/Libraries/LibWeb/DOM/Range.cpp b/Userland/Libraries/LibWeb/DOM/Range.cpp
index b74e8dfe94..3125a41b98 100644
--- a/Userland/Libraries/LibWeb/DOM/Range.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Range.cpp
@@ -18,12 +18,12 @@ NonnullRefPtr<Range> Range::create(Window& window)
NonnullRefPtr<Range> Range::create(Document& document)
{
- return adopt(*new Range(document));
+ return adopt_ref(*new Range(document));
}
NonnullRefPtr<Range> Range::create(Node& start_container, size_t start_offset, Node& end_container, size_t end_offset)
{
- return adopt(*new Range(start_container, start_offset, end_container, end_offset));
+ return adopt_ref(*new Range(start_container, start_offset, end_container, end_offset));
}
NonnullRefPtr<Range> Range::create_with_global_object(Bindings::WindowObject& window)
{
@@ -45,12 +45,12 @@ Range::Range(Node& start_container, size_t start_offset, Node& end_container, si
NonnullRefPtr<Range> Range::clone_range() const
{
- return adopt(*new Range(const_cast<Node&>(*m_start_container), m_start_offset, const_cast<Node&>(*m_end_container), m_end_offset));
+ return adopt_ref(*new Range(const_cast<Node&>(*m_start_container), m_start_offset, const_cast<Node&>(*m_end_container), m_end_offset));
}
NonnullRefPtr<Range> Range::inverted() const
{
- return adopt(*new Range(const_cast<Node&>(*m_end_container), m_end_offset, const_cast<Node&>(*m_start_container), m_start_offset));
+ return adopt_ref(*new Range(const_cast<Node&>(*m_end_container), m_end_offset, const_cast<Node&>(*m_start_container), m_start_offset));
}
NonnullRefPtr<Range> Range::normalized() const
diff --git a/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp b/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp
index f108e52fd1..de9b47db75 100644
--- a/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp
+++ b/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp
@@ -29,7 +29,7 @@ EventTarget* ShadowRoot::get_parent(const Event& event)
RefPtr<Layout::Node> ShadowRoot::create_layout_node()
{
- return adopt(*new Layout::BlockBox(document(), this, CSS::ComputedValues {}));
+ return adopt_ref(*new Layout::BlockBox(document(), this, CSS::ComputedValues {}));
}
}
diff --git a/Userland/Libraries/LibWeb/DOM/Text.cpp b/Userland/Libraries/LibWeb/DOM/Text.cpp
index 6e3755ce92..03bf69d26a 100644
--- a/Userland/Libraries/LibWeb/DOM/Text.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Text.cpp
@@ -20,7 +20,7 @@ Text::~Text()
RefPtr<Layout::Node> Text::create_layout_node()
{
- return adopt(*new Layout::TextNode(document(), *this));
+ return adopt_ref(*new Layout::TextNode(document(), *this));
}
}
diff --git a/Userland/Libraries/LibWeb/DOM/Timer.cpp b/Userland/Libraries/LibWeb/DOM/Timer.cpp
index f628e5e33b..4ef944a9eb 100644
--- a/Userland/Libraries/LibWeb/DOM/Timer.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Timer.cpp
@@ -13,12 +13,12 @@ namespace Web::DOM {
NonnullRefPtr<Timer> Timer::create_interval(Window& window, int milliseconds, JS::Function& callback)
{
- return adopt(*new Timer(window, Type::Interval, milliseconds, callback));
+ return adopt_ref(*new Timer(window, Type::Interval, milliseconds, callback));
}
NonnullRefPtr<Timer> Timer::create_timeout(Window& window, int milliseconds, JS::Function& callback)
{
- return adopt(*new Timer(window, Type::Timeout, milliseconds, callback));
+ return adopt_ref(*new Timer(window, Type::Timeout, milliseconds, callback));
}
Timer::Timer(Window& window, Type type, int milliseconds, JS::Function& callback)
diff --git a/Userland/Libraries/LibWeb/DOM/Window.cpp b/Userland/Libraries/LibWeb/DOM/Window.cpp
index e54b383145..1b9f70e320 100644
--- a/Userland/Libraries/LibWeb/DOM/Window.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Window.cpp
@@ -20,7 +20,7 @@ namespace Web::DOM {
NonnullRefPtr<Window> Window::create_with_document(Document& document)
{
- return adopt(*new Window(document));
+ return adopt_ref(*new Window(document));
}
Window::Window(Document& document)
diff --git a/Userland/Libraries/LibWeb/DOMTreeModel.h b/Userland/Libraries/LibWeb/DOMTreeModel.h
index a8488d83b6..7a0c6656e4 100644
--- a/Userland/Libraries/LibWeb/DOMTreeModel.h
+++ b/Userland/Libraries/LibWeb/DOMTreeModel.h
@@ -15,7 +15,7 @@ class DOMTreeModel final : public GUI::Model {
public:
static NonnullRefPtr<DOMTreeModel> create(DOM::Document& document)
{
- return adopt(*new DOMTreeModel(document));
+ return adopt_ref(*new DOMTreeModel(document));
}
virtual ~DOMTreeModel() override;
diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h
index a87b63b2ab..1896e336b0 100644
--- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h
+++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h
@@ -27,7 +27,7 @@ class CanvasRenderingContext2D
public:
using WrapperType = Bindings::CanvasRenderingContext2DWrapper;
- static NonnullRefPtr<CanvasRenderingContext2D> create(HTMLCanvasElement& element) { return adopt(*new CanvasRenderingContext2D(element)); }
+ static NonnullRefPtr<CanvasRenderingContext2D> create(HTMLCanvasElement& element) { return adopt_ref(*new CanvasRenderingContext2D(element)); }
~CanvasRenderingContext2D();
void set_fill_style(String);
diff --git a/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp b/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp
index 89f41eb5fe..f6f49a72d8 100644
--- a/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp
+++ b/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp
@@ -39,7 +39,7 @@ void GlobalEventHandlers::set_event_handler_attribute(const FlyString& name, HTM
RefPtr<DOM::EventListener> listener;
if (!value.callback.is_null()) {
- listener = adopt(*new DOM::EventListener(move(value.callback)));
+ listener = adopt_ref(*new DOM::EventListener(move(value.callback)));
} else {
StringBuilder builder;
builder.appendff("function {}(event) {{\n{}\n}}", name, value.string);
@@ -51,7 +51,7 @@ void GlobalEventHandlers::set_event_handler_attribute(const FlyString& name, HTM
}
auto* function = JS::ScriptFunction::create(self.script_execution_context()->interpreter().global_object(), name, program->body(), program->parameters(), program->function_length(), nullptr, false, false);
VERIFY(function);
- listener = adopt(*new DOM::EventListener(JS::make_handle(static_cast<JS::Function*>(function))));
+ listener = adopt_ref(*new DOM::EventListener(JS::make_handle(static_cast<JS::Function*>(function))));
}
if (listener) {
for (auto& registered_listener : self.listeners()) {
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp
index 9e783d2d10..91db220071 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp
@@ -20,7 +20,7 @@ HTMLBRElement::~HTMLBRElement()
RefPtr<Layout::Node> HTMLBRElement::create_layout_node()
{
- return adopt(*new Layout::BreakNode(document(), *this));
+ return adopt_ref(*new Layout::BreakNode(document(), *this));
}
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp
index 697d5145fe..0b0f2561c3 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp
@@ -42,7 +42,7 @@ RefPtr<Layout::Node> HTMLCanvasElement::create_layout_node()
auto style = document().style_resolver().resolve_style(*this);
if (style->display() == CSS::Display::None)
return nullptr;
- return adopt(*new Layout::CanvasBox(document(), *this, move(style)));
+ return adopt_ref(*new Layout::CanvasBox(document(), *this, move(style)));
}
CanvasRenderingContext2D* HTMLCanvasElement::get_context(String type)
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp
index fd5dca1ad5..736a446457 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp
@@ -24,7 +24,7 @@ HTMLIFrameElement::~HTMLIFrameElement()
RefPtr<Layout::Node> HTMLIFrameElement::create_layout_node()
{
auto style = document().style_resolver().resolve_style(*this);
- return adopt(*new Layout::FrameBox(document(), *this, move(style)));
+ return adopt_ref(*new Layout::FrameBox(document(), *this, move(style)));
}
void HTMLIFrameElement::parse_attribute(const FlyString& name, const String& value)
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
index 192f85dca7..75cf9b4586 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
@@ -69,7 +69,7 @@ RefPtr<Layout::Node> HTMLImageElement::create_layout_node()
auto style = document().style_resolver().resolve_style(*this);
if (style->display() == CSS::Display::None)
return nullptr;
- return adopt(*new Layout::ImageBox(document(), *this, move(style), m_image_loader));
+ return adopt_ref(*new Layout::ImageBox(document(), *this, move(style), m_image_loader));
}
const Gfx::Bitmap* HTMLImageElement::bitmap() const
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
index f79a02951a..27fcc3e7bd 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
@@ -53,16 +53,16 @@ RefPtr<Layout::Node> HTMLInputElement::create_layout_node()
return nullptr;
if (type().equals_ignoring_case("submit") || type().equals_ignoring_case("button"))
- return adopt(*new Layout::ButtonBox(document(), *this, move(style)));
+ return adopt_ref(*new Layout::ButtonBox(document(), *this, move(style)));
if (type() == "checkbox")
- return adopt(*new Layout::CheckBox(document(), *this, move(style)));
+ return adopt_ref(*new Layout::CheckBox(document(), *this, move(style)));
if (type() == "radio")
- return adopt(*new Layout::RadioButton(document(), *this, move(style)));
+ return adopt_ref(*new Layout::RadioButton(document(), *this, move(style)));
create_shadow_tree_if_needed();
- auto layout_node = adopt(*new Layout::BlockBox(document(), this, move(style)));
+ auto layout_node = adopt_ref(*new Layout::BlockBox(document(), this, move(style)));
layout_node->set_inline(true);
return layout_node;
}
@@ -105,13 +105,13 @@ void HTMLInputElement::create_shadow_tree_if_needed()
return;
// FIXME: This assumes that we want a text box. Is that always true?
- auto shadow_root = adopt(*new DOM::ShadowRoot(document(), *this));
+ auto shadow_root = adopt_ref(*new DOM::ShadowRoot(document(), *this));
auto initial_value = attribute(HTML::AttributeNames::value);
if (initial_value.is_null())
initial_value = String::empty();
auto element = document().create_element(HTML::TagNames::div);
element->set_attribute(HTML::AttributeNames::style, "white-space: pre");
- m_text_node = adopt(*new DOM::Text(document(), initial_value));
+ m_text_node = adopt_ref(*new DOM::Text(document(), initial_value));
m_text_node->set_always_editable(true);
element->append_child(*m_text_node);
shadow_root->append_child(move(element));
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp
index ff3512031d..07c2280134 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp
@@ -25,7 +25,7 @@ RefPtr<Layout::Node> HTMLLabelElement::create_layout_node()
if (style->display() == CSS::Display::None)
return nullptr;
- auto layout_node = adopt(*new Layout::Label(document(), this, move(style)));
+ auto layout_node = adopt_ref(*new Layout::Label(document(), this, move(style)));
layout_node->set_inline(true);
return layout_node;
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp
index 6909c1a7b7..1908feb99e 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp
@@ -50,7 +50,7 @@ RefPtr<Layout::Node> HTMLObjectElement::create_layout_node()
if (style->display() == CSS::Display::None)
return nullptr;
if (m_image_loader.has_image())
- return adopt(*new Layout::ImageBox(document(), *this, move(style), m_image_loader));
+ return adopt_ref(*new Layout::ImageBox(document(), *this, move(style), m_image_loader));
return nullptr;
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp
index 1c159bdd36..b752fdf6f4 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp
@@ -12,7 +12,7 @@ namespace Web::HTML {
HTMLTemplateElement::HTMLTemplateElement(DOM::Document& document, QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
- m_content = adopt(*new DOM::DocumentFragment(appropriate_template_contents_owner_document(document)));
+ m_content = adopt_ref(*new DOM::DocumentFragment(appropriate_template_contents_owner_document(document)));
m_content->set_host(*this);
}
diff --git a/Userland/Libraries/LibWeb/HTML/ImageData.cpp b/Userland/Libraries/LibWeb/HTML/ImageData.cpp
index 3af5c6785c..b44bb247a2 100644
--- a/Userland/Libraries/LibWeb/HTML/ImageData.cpp
+++ b/Userland/Libraries/LibWeb/HTML/ImageData.cpp
@@ -29,7 +29,7 @@ RefPtr<ImageData> ImageData::create_with_size(JS::GlobalObject& global_object, i
auto bitmap = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGBA8888, Gfx::IntSize(width, height), 1, width * sizeof(u32), (u32*)data->data());
if (!bitmap)
return nullptr;
- return adopt(*new ImageData(bitmap.release_nonnull(), move(data_handle)));
+ return adopt_ref(*new ImageData(bitmap.release_nonnull(), move(data_handle)));
}
ImageData::ImageData(NonnullRefPtr<Gfx::Bitmap> bitmap, JS::Handle<JS::Uint8ClampedArray> data)
diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp
index a26dd711ae..56e3da4eff 100644
--- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp
@@ -313,13 +313,13 @@ void HTMLDocumentParser::handle_initial(HTMLToken& token)
}
if (token.is_comment()) {
- auto comment = adopt(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string()));
+ auto comment = adopt_ref(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string()));
document().append_child(move(comment));
return;
}
if (token.is_doctype()) {
- auto doctype = adopt(*new DOM::DocumentType(document()));
+ auto doctype = adopt_ref(*new DOM::DocumentType(document()));
doctype->set_name(token.m_doctype.name.to_string());
doctype->set_public_id(token.m_doctype.public_identifier.to_string());
doctype->set_system_id(token.m_doctype.system_identifier.to_string());
@@ -343,7 +343,7 @@ void HTMLDocumentParser::handle_before_html(HTMLToken& token)
}
if (token.is_comment()) {
- auto comment = adopt(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string()));
+ auto comment = adopt_ref(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string()));
document().append_child(move(comment));
return;
}
@@ -518,7 +518,7 @@ void HTMLDocumentParser::insert_comment(HTMLToken& token)
{
auto data = token.m_comment_or_character.data.to_string();
auto adjusted_insertion_location = find_appropriate_place_for_inserting_node();
- adjusted_insertion_location.parent->insert_before(adopt(*new DOM::Comment(document(), data)), adjusted_insertion_location.insert_before_sibling);
+ adjusted_insertion_location.parent->insert_before(adopt_ref(*new DOM::Comment(document(), data)), adjusted_insertion_location.insert_before_sibling);
}
void HTMLDocumentParser::handle_in_head(HTMLToken& token)
@@ -703,7 +703,7 @@ DOM::Text* HTMLDocumentParser::find_character_insertion_node()
return nullptr;
if (adjusted_insertion_location.parent->last_child() && adjusted_insertion_location.parent->last_child()->is_text())
return downcast<DOM::Text>(adjusted_insertion_location.parent->last_child());
- auto new_text_node = adopt(*new DOM::Text(document(), ""));
+ auto new_text_node = adopt_ref(*new DOM::Text(document(), ""));
adjusted_insertion_location.parent->append_child(new_text_node);
return new_text_node;
}
@@ -830,7 +830,7 @@ void HTMLDocumentParser::handle_after_body(HTMLToken& token)
if (token.is_comment()) {
auto data = token.m_comment_or_character.data.to_string();
auto& insertion_location = m_stack_of_open_elements.first();
- insertion_location.append_child(adopt(*new DOM::Comment(document(), data)));
+ insertion_location.append_child(adopt_ref(*new DOM::Comment(document(), data)));
return;
}
@@ -866,7 +866,7 @@ void HTMLDocumentParser::handle_after_body(HTMLToken& token)
void HTMLDocumentParser::handle_after_after_body(HTMLToken& token)
{
if (token.is_comment()) {
- auto comment = adopt(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string()));
+ auto comment = adopt_ref(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string()));
document().append_child(move(comment));
return;
}
@@ -2748,7 +2748,7 @@ void HTMLDocumentParser::handle_after_frameset(HTMLToken& token)
void HTMLDocumentParser::handle_after_after_frameset(HTMLToken& token)
{
if (token.is_comment()) {
- auto comment = adopt(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string()));
+ auto comment = adopt_ref(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string()));
document().append_child(move(comment));
return;
}
diff --git a/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp b/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp
index 86b06f58eb..fc63ef6ded 100644
--- a/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp
+++ b/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp
@@ -11,7 +11,7 @@ namespace Web::HTML {
NonnullRefPtr<SubmitEvent> SubmitEvent::create(const FlyString& event_name, RefPtr<HTMLElement> submitter)
{
- return adopt(*new SubmitEvent(event_name, move(submitter)));
+ return adopt_ref(*new SubmitEvent(event_name, move(submitter)));
}
SubmitEvent::SubmitEvent(const FlyString& event_name, RefPtr<HTMLElement> submitter)
diff --git a/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp b/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp
index b524588de7..38c27373c6 100644
--- a/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp
+++ b/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp
@@ -31,7 +31,7 @@ void ListItemBox::layout_marker()
if (!m_marker) {
int child_index = parent()->index_of_child<ListItemBox>(*this).value();
- m_marker = adopt(*new ListItemMarkerBox(document(), computed_values().list_style_type(), child_index + 1));
+ m_marker = adopt_ref(*new ListItemMarkerBox(document(), computed_values().list_style_type(), child_index + 1));
if (first_child())
m_marker->set_inline(first_child()->is_inline());
append_child(*m_marker);
diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp
index 809b44aaaa..51b5b82601 100644
--- a/Userland/Libraries/LibWeb/Layout/Node.cpp
+++ b/Userland/Libraries/LibWeb/Layout/Node.cpp
@@ -346,7 +346,7 @@ bool Node::is_inline_block() const
NonnullRefPtr<NodeWithStyle> NodeWithStyle::create_anonymous_wrapper() const
{
- auto wrapper = adopt(*new BlockBox(const_cast<DOM::Document&>(document()), nullptr, m_computed_values.clone_inherited_values()));
+ auto wrapper = adopt_ref(*new BlockBox(const_cast<DOM::Document&>(document()), nullptr, m_computed_values.clone_inherited_values()));
wrapper->m_font = m_font;
wrapper->m_font_size = m_font_size;
wrapper->m_line_height = m_line_height;
diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
index 2beae5b090..7b2c1ce416 100644
--- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
+++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
@@ -60,7 +60,7 @@ static Layout::Node& insertion_parent_for_block_node(Layout::Node& layout_parent
layout_parent.remove_child(*child);
children.append(child.release_nonnull());
}
- layout_parent.append_child(adopt(*new BlockBox(layout_node.document(), nullptr, layout_parent.computed_values().clone_inherited_values())));
+ layout_parent.append_child(adopt_ref(*new BlockBox(layout_node.document(), nullptr, layout_parent.computed_values().clone_inherited_values())));
layout_parent.set_children_are_inline(false);
for (auto& child : children) {
layout_parent.last_child()->append_child(child);
@@ -247,7 +247,7 @@ static void wrap_in_anonymous(NonnullRefPtrVector<Node>& sequence, Node* nearest
auto& parent = *sequence.first().parent();
auto computed_values = parent.computed_values().clone_inherited_values();
static_cast<CSS::MutableComputedValues&>(computed_values).set_display(WrapperBoxType::static_display());
- auto wrapper = adopt(*new WrapperBoxType(parent.document(), nullptr, move(computed_values)));
+ auto wrapper = adopt_ref(*new WrapperBoxType(parent.document(), nullptr, move(computed_values)));
for (auto& child : sequence) {
parent.remove_child(child);
wrapper->append_child(child);
diff --git a/Userland/Libraries/LibWeb/LayoutTreeModel.h b/Userland/Libraries/LibWeb/LayoutTreeModel.h
index d7930c79ea..ec203227d2 100644
--- a/Userland/Libraries/LibWeb/LayoutTreeModel.h
+++ b/Userland/Libraries/LibWeb/LayoutTreeModel.h
@@ -15,7 +15,7 @@ class LayoutTreeModel final : public GUI::Model {
public:
static NonnullRefPtr<LayoutTreeModel> create(DOM::Document& document)
{
- return adopt(*new LayoutTreeModel(document));
+ return adopt_ref(*new LayoutTreeModel(document));
}
virtual ~LayoutTreeModel() override;
diff --git a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp
index 40ecda858c..8c1f6dd4c4 100644
--- a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp
+++ b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp
@@ -82,7 +82,7 @@ static bool build_image_document(DOM::Document& document, const ByteBuffer& data
head_element->append_child(title_element);
auto basename = LexicalPath(document.url().path()).basename();
- auto title_text = adopt(*new DOM::Text(document, String::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height())));
+ auto title_text = adopt_ref(*new DOM::Text(document, String::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height())));
title_element->append_child(title_text);
auto body_element = document.create_element("body");
diff --git a/Userland/Libraries/LibWeb/Loader/Resource.cpp b/Userland/Libraries/LibWeb/Loader/Resource.cpp
index e5bed81e4e..9223145f96 100644
--- a/Userland/Libraries/LibWeb/Loader/Resource.cpp
+++ b/Userland/Libraries/LibWeb/Loader/Resource.cpp
@@ -15,8 +15,8 @@ namespace Web {
NonnullRefPtr<Resource> Resource::create(Badge<ResourceLoader>, Type type, const LoadRequest& request)
{
if (type == Type::Image)
- return adopt(*new ImageResource(request));
- return adopt(*new Resource(type, request));
+ return adopt_ref(*new ImageResource(request));
+ return adopt_ref(*new Resource(type, request));
}
Resource::Resource(Type type, const LoadRequest& request)
diff --git a/Userland/Libraries/LibWeb/Page/Frame.h b/Userland/Libraries/LibWeb/Page/Frame.h
index 17b507122d..49370b8683 100644
--- a/Userland/Libraries/LibWeb/Page/Frame.h
+++ b/Userland/Libraries/LibWeb/Page/Frame.h
@@ -23,8 +23,8 @@ namespace Web {
class Frame : public TreeNode<Frame> {
public:
- static NonnullRefPtr<Frame> create_subframe(DOM::Element& host_element, Frame& main_frame) { return adopt(*new Frame(host_element, main_frame)); }
- static NonnullRefPtr<Frame> create(Page& page) { return adopt(*new Frame(page)); }
+ static NonnullRefPtr<Frame> create_subframe(DOM::Element& host_element, Frame& main_frame) { return adopt_ref(*new Frame(host_element, main_frame)); }
+ static NonnullRefPtr<Frame> create(Page& page) { return adopt_ref(*new Frame(page)); }
~Frame();
class ViewportClient {
diff --git a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp
index 84d6721295..9cd4b1a30a 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp
@@ -447,7 +447,7 @@ RefPtr<Layout::Node> SVGPathElement::create_layout_node()
auto style = document().style_resolver().resolve_style(*this);
if (style->display() == CSS::Display::None)
return nullptr;
- return adopt(*new Layout::SVGPathBox(document(), *this, move(style)));
+ return adopt_ref(*new Layout::SVGPathBox(document(), *this, move(style)));
}
void SVGPathElement::parse_attribute(const FlyString& name, const String& value)
diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp
index 218af6175d..effcf8edcb 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp
@@ -25,7 +25,7 @@ RefPtr<Layout::Node> SVGSVGElement::create_layout_node()
auto style = document().style_resolver().resolve_style(*this);
if (style->display() == CSS::Display::None)
return nullptr;
- return adopt(*new Layout::SVGSVGBox(document(), *this, move(style)));
+ return adopt_ref(*new Layout::SVGSVGBox(document(), *this, move(style)));
}
unsigned SVGSVGElement::width() const
diff --git a/Userland/Libraries/LibWeb/StylePropertiesModel.h b/Userland/Libraries/LibWeb/StylePropertiesModel.h
index 56cf0df533..eba0517708 100644
--- a/Userland/Libraries/LibWeb/StylePropertiesModel.h
+++ b/Userland/Libraries/LibWeb/StylePropertiesModel.h
@@ -22,7 +22,7 @@ public:
__Count
};
- static NonnullRefPtr<StylePropertiesModel> create(const CSS::StyleProperties& properties) { return adopt(*new StylePropertiesModel(properties)); }
+ static NonnullRefPtr<StylePropertiesModel> create(const CSS::StyleProperties& properties) { return adopt_ref(*new StylePropertiesModel(properties)); }
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h
index 8535c93cbd..8f56dac9e5 100644
--- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h
+++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h
@@ -17,7 +17,7 @@ public:
static NonnullRefPtr<MouseEvent> create(const FlyString& event_name, i32 offset_x, i32 offset_y, i32 client_x, i32 client_y)
{
- return adopt(*new MouseEvent(event_name, offset_x, offset_y, client_x, client_y));
+ return adopt_ref(*new MouseEvent(event_name, offset_x, offset_y, client_x, client_y));
}
virtual ~MouseEvent() override;
diff --git a/Userland/Libraries/LibWeb/XHR/ProgressEvent.h b/Userland/Libraries/LibWeb/XHR/ProgressEvent.h
index eab22a4b78..7cd2ca49d1 100644
--- a/Userland/Libraries/LibWeb/XHR/ProgressEvent.h
+++ b/Userland/Libraries/LibWeb/XHR/ProgressEvent.h
@@ -19,7 +19,7 @@ public:
static NonnullRefPtr<ProgressEvent> create(const FlyString& event_name, u32 transmitted, u32 length)
{
- return adopt(*new ProgressEvent(event_name, transmitted, length));
+ return adopt_ref(*new ProgressEvent(event_name, transmitted, length));
}
virtual ~ProgressEvent() override { }
diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h
index 1c1e91241e..2b3f46d271 100644
--- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h
+++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h
@@ -35,7 +35,7 @@ public:
static NonnullRefPtr<XMLHttpRequest> create(DOM::Window& window)
{
- return adopt(*new XMLHttpRequest(window));
+ return adopt_ref(*new XMLHttpRequest(window));
}
static NonnullRefPtr<XMLHttpRequest> create_with_global_object(Bindings::WindowObject& window)
{
diff --git a/Userland/Libraries/LibWebSocket/WebSocket.cpp b/Userland/Libraries/LibWebSocket/WebSocket.cpp
index a2ddefb0e4..75843ac71d 100644
--- a/Userland/Libraries/LibWebSocket/WebSocket.cpp
+++ b/Userland/Libraries/LibWebSocket/WebSocket.cpp
@@ -21,7 +21,7 @@ namespace WebSocket {
NonnullRefPtr<WebSocket> WebSocket::create(ConnectionInfo connection)
{
- return adopt(*new WebSocket(connection));
+ return adopt_ref(*new WebSocket(connection));
}
WebSocket::WebSocket(ConnectionInfo connection)
diff --git a/Userland/Services/AudioServer/Mixer.cpp b/Userland/Services/AudioServer/Mixer.cpp
index 8ef098a76d..7de474120d 100644
--- a/Userland/Services/AudioServer/Mixer.cpp
+++ b/Userland/Services/AudioServer/Mixer.cpp
@@ -42,7 +42,7 @@ Mixer::~Mixer()
NonnullRefPtr<BufferQueue> Mixer::create_queue(ClientConnection& client)
{
- auto queue = adopt(*new BufferQueue(client));
+ auto queue = adopt_ref(*new BufferQueue(client));
pthread_mutex_lock(&m_pending_mutex);
m_pending_mixing.append(*queue);
m_added_queue = true;
diff --git a/Userland/Services/EchoServer/Client.h b/Userland/Services/EchoServer/Client.h
index 9793d5d436..d9c3076881 100644
--- a/Userland/Services/EchoServer/Client.h
+++ b/Userland/Services/EchoServer/Client.h
@@ -12,7 +12,7 @@ class Client : public RefCounted<Client> {
public:
static NonnullRefPtr<Client> create(int id, RefPtr<Core::TCPSocket> socket)
{
- return adopt(*new Client(id, move(socket)));
+ return adopt_ref(*new Client(id, move(socket)));
}
Function<void()> on_exit;
diff --git a/Userland/Services/TelnetServer/Client.h b/Userland/Services/TelnetServer/Client.h
index 3908782bcb..e717aee4b3 100644
--- a/Userland/Services/TelnetServer/Client.h
+++ b/Userland/Services/TelnetServer/Client.h
@@ -19,7 +19,7 @@ class Client : public RefCounted<Client> {
public:
static NonnullRefPtr<Client> create(int id, RefPtr<Core::TCPSocket> socket, int ptm_fd)
{
- return adopt(*new Client(id, move(socket), ptm_fd));
+ return adopt_ref(*new Client(id, move(socket), ptm_fd));
}
Function<void()> on_exit;
diff --git a/Userland/Services/WindowServer/Cursor.cpp b/Userland/Services/WindowServer/Cursor.cpp
index f100a8cf2f..9722be3390 100644
--- a/Userland/Services/WindowServer/Cursor.cpp
+++ b/Userland/Services/WindowServer/Cursor.cpp
@@ -117,13 +117,13 @@ Cursor::~Cursor()
NonnullRefPtr<Cursor> Cursor::create(NonnullRefPtr<Gfx::Bitmap>&& bitmap)
{
auto hotspot = bitmap->rect().center();
- return adopt(*new Cursor(move(bitmap), CursorParams(hotspot)));
+ return adopt_ref(*new Cursor(move(bitmap), CursorParams(hotspot)));
}
NonnullRefPtr<Cursor> Cursor::create(NonnullRefPtr<Gfx::Bitmap>&& bitmap, const StringView& filename)
{
auto default_hotspot = bitmap->rect().center();
- return adopt(*new Cursor(move(bitmap), CursorParams::parse_from_file_name(filename, default_hotspot)));
+ return adopt_ref(*new Cursor(move(bitmap), CursorParams::parse_from_file_name(filename, default_hotspot)));
}
RefPtr<Cursor> Cursor::create(Gfx::StandardCursor standard_cursor)
diff --git a/Userland/Services/WindowServer/Menubar.h b/Userland/Services/WindowServer/Menubar.h
index d1c84f404d..03e10d14c5 100644
--- a/Userland/Services/WindowServer/Menubar.h
+++ b/Userland/Services/WindowServer/Menubar.h
@@ -17,7 +17,7 @@ class Menubar
: public RefCounted<Menubar>
, public Weakable<Menubar> {
public:
- static NonnullRefPtr<Menubar> create(ClientConnection& client, int menubar_id) { return adopt(*new Menubar(client, menubar_id)); }
+ static NonnullRefPtr<Menubar> create(ClientConnection& client, int menubar_id) { return adopt_ref(*new Menubar(client, menubar_id)); }
~Menubar();
ClientConnection& client() { return m_client; }
diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp
index 8600392784..e66566039b 100644
--- a/Userland/Shell/AST.cpp
+++ b/Userland/Shell/AST.cpp
@@ -829,7 +829,7 @@ RefPtr<Value> CloseFdRedirection::run(RefPtr<Shell>)
{
Command command;
command.position = position();
- command.redirections.append(adopt(*new CloseRedirection(m_fd)));
+ command.redirections.append(adopt_ref(*new CloseRedirection(m_fd)));
return create<CommandValue>(move(command));
}
@@ -3249,7 +3249,7 @@ ListValue::ListValue(Vector<String> values)
return;
m_contained_values.ensure_capacity(values.size());
for (auto& str : values)
- m_contained_values.append(adopt(*new StringValue(move(str))));
+ m_contained_values.append(adopt_ref(*new StringValue(move(str))));
}
NonnullRefPtr<Value> Value::with_slices(NonnullRefPtr<Slice> slice) const&
@@ -3447,7 +3447,7 @@ Vector<String> TildeValue::resolve_as_list(RefPtr<Shell> shell)
Result<NonnullRefPtr<Rewiring>, String> CloseRedirection::apply() const
{
- return adopt(*new Rewiring(fd, fd, Rewiring::Close::ImmediatelyCloseNew));
+ return adopt_ref(*new Rewiring(fd, fd, Rewiring::Close::ImmediatelyCloseNew));
}
CloseRedirection::~CloseRedirection()
@@ -3462,7 +3462,7 @@ Result<NonnullRefPtr<Rewiring>, String> PathRedirection::apply() const
dbgln("open() failed for '{}' with {}", path, error);
return error;
}
- return adopt(*new Rewiring(fd, my_fd, Rewiring::Close::Old));
+ return adopt_ref(*new Rewiring(fd, my_fd, Rewiring::Close::Old));
};
switch (direction) {
case AST::PathRedirection::WriteAppend:
diff --git a/Userland/Shell/AST.h b/Userland/Shell/AST.h
index 629fe69c70..69be321f10 100644
--- a/Userland/Shell/AST.h
+++ b/Userland/Shell/AST.h
@@ -24,13 +24,13 @@ namespace Shell::AST {
template<typename T, typename... Args>
static inline NonnullRefPtr<T> create(Args... args)
{
- return adopt(*new T(args...));
+ return adopt_ref(*new T(args...));
}
template<typename T>
static inline NonnullRefPtr<T> create(std::initializer_list<NonnullRefPtr<Value>> arg)
{
- return adopt(*new T(arg));
+ return adopt_ref(*new T(arg));
}
struct HighlightMetadata {
@@ -122,7 +122,7 @@ struct PathRedirection : public Redirection {
static NonnullRefPtr<PathRedirection> create(String path, int fd, decltype(direction) direction)
{
- return adopt(*new PathRedirection(move(path), fd, direction));
+ return adopt_ref(*new PathRedirection(move(path), fd, direction));
}
virtual Result<NonnullRefPtr<Rewiring>, String> apply() const override;
@@ -143,19 +143,19 @@ struct FdRedirection : public Redirection {
public:
static NonnullRefPtr<FdRedirection> create(int old_fd, int new_fd, Rewiring::Close close)
{
- return adopt(*new FdRedirection(old_fd, new_fd, close));
+ return adopt_ref(*new FdRedirection(old_fd, new_fd, close));
}
static NonnullRefPtr<FdRedirection> create(int old_fd, int new_fd, FdRedirection* pipe_end, Rewiring::Close close)
{
- return adopt(*new FdRedirection(old_fd, new_fd, pipe_end, close));
+ return adopt_ref(*new FdRedirection(old_fd, new_fd, pipe_end, close));
}
virtual ~FdRedirection();
virtual Result<NonnullRefPtr<Rewiring>, String> apply() const override
{
- return adopt(*new Rewiring(old_fd, new_fd, other_pipe_end, action));
+ return adopt_ref(*new Rewiring(old_fd, new_fd, other_pipe_end, action));
}
int old_fd { -1 };
diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp
index e1fa12ba54..ff1ca7f634 100644
--- a/Userland/Shell/Builtin.cpp
+++ b/Userland/Shell/Builtin.cpp
@@ -767,7 +767,7 @@ int Shell::builtin_shift(int argc, const char** argv)
}
if (!argv_->is_list())
- argv_ = adopt(*new AST::ListValue({ argv_.release_nonnull() }));
+ argv_ = adopt_ref(*new AST::ListValue({ argv_.release_nonnull() }));
auto& values = static_cast<AST::ListValue*>(argv_.ptr())->values();
if ((size_t)count > values.size()) {
diff --git a/Userland/Shell/Job.h b/Userland/Shell/Job.h
index d99219f91e..fd84b6c94e 100644
--- a/Userland/Shell/Job.h
+++ b/Userland/Shell/Job.h
@@ -27,7 +27,7 @@ struct LocalFrame;
class Job : public RefCounted<Job> {
public:
- static NonnullRefPtr<Job> create(pid_t pid, pid_t pgid, String cmd, u64 job_id, AST::Command&& command) { return adopt(*new Job(pid, pgid, move(cmd), job_id, move(command))); }
+ static NonnullRefPtr<Job> create(pid_t pid, pid_t pgid, String cmd, u64 job_id, AST::Command&& command) { return adopt_ref(*new Job(pid, pgid, move(cmd), job_id, move(command))); }
~Job()
{
diff --git a/Userland/Shell/Parser.cpp b/Userland/Shell/Parser.cpp
index 742c17039e..d1e422f6d8 100644
--- a/Userland/Shell/Parser.cpp
+++ b/Userland/Shell/Parser.cpp
@@ -84,7 +84,7 @@ bool Parser::expect(const StringView& expected)
template<typename A, typename... Args>
NonnullRefPtr<A> Parser::create(Args... args)
{
- return adopt(*new A(AST::Position { m_rule_start_offsets.last(), m_offset, m_rule_start_lines.last(), line() }, args...));
+ return adopt_ref(*new A(AST::Position { m_rule_start_offsets.last(), m_offset, m_rule_start_lines.last(), line() }, args...));
}
[[nodiscard]] OwnPtr<Parser::ScopedOffset> Parser::push_start()
diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp
index 317e68a5e0..6d0500bd85 100644
--- a/Userland/Shell/Shell.cpp
+++ b/Userland/Shell/Shell.cpp
@@ -297,9 +297,9 @@ Vector<AST::Command> Shell::expand_aliases(Vector<AST::Command> initial_commands
subcommand_ast = ast->command();
}
auto subcommand_nonnull = subcommand_ast.release_nonnull();
- NonnullRefPtr<AST::Node> substitute = adopt(*new AST::Join(subcommand_nonnull->position(),
+ NonnullRefPtr<AST::Node> substitute = adopt_ref(*new AST::Join(subcommand_nonnull->position(),
subcommand_nonnull,
- adopt(*new AST::CommandLiteral(subcommand_nonnull->position(), command))));
+ adopt_ref(*new AST::CommandLiteral(subcommand_nonnull->position(), command))));
auto res = substitute->run(*this);
for (auto& subst_command : res->resolve_as_commands(*this)) {
if (!subst_command.argv.is_empty() && subst_command.argv.first() == argv0) // Disallow an alias resolving to itself.
@@ -356,7 +356,7 @@ RefPtr<AST::Value> Shell::lookup_local_variable(const String& name)
RefPtr<AST::Value> Shell::get_argument(size_t index)
{
if (index == 0)
- return adopt(*new AST::StringValue(current_script));
+ return adopt_ref(*new AST::StringValue(current_script));
--index;
if (auto argv = lookup_local_variable("ARGV")) {
@@ -452,12 +452,12 @@ bool Shell::invoke_function(const AST::Command& command, int& retval)
size_t index = 0;
for (auto& arg : function.arguments) {
++index;
- set_local_variable(arg, adopt(*new AST::StringValue(command.argv[index])), true);
+ set_local_variable(arg, adopt_ref(*new AST::StringValue(command.argv[index])), true);
}
auto argv = command.argv;
argv.take_first();
- set_local_variable("ARGV", adopt(*new AST::ListValue(move(argv))), true);
+ set_local_variable("ARGV", adopt_ref(*new AST::ListValue(move(argv))), true);
Core::EventLoop loop;
setup_signals();
@@ -910,8 +910,8 @@ void Shell::run_tail(const AST::Command& invoking_command, const AST::NodeWithAc
}
auto node = next_in_chain.node;
if (!invoking_command.should_wait)
- node = adopt(static_cast<AST::Node&>(*new AST::Background(next_in_chain.node->position(), move(node))));
- adopt(static_cast<AST::Node&>(*new AST::Execute(next_in_chain.node->position(), move(node))))->run(*this);
+ node = adopt_ref(static_cast<AST::Node&>(*new AST::Background(next_in_chain.node->position(), move(node))));
+ adopt_ref(static_cast<AST::Node&>(*new AST::Execute(next_in_chain.node->position(), move(node))))->run(*this);
};
switch (next_in_chain.action) {
case AST::NodeWithAction::And:
diff --git a/Userland/Shell/main.cpp b/Userland/Shell/main.cpp
index c5428e5301..f8a15f7636 100644
--- a/Userland/Shell/main.cpp
+++ b/Userland/Shell/main.cpp
@@ -163,7 +163,7 @@ int main(int argc, char** argv)
Vector<String> args;
for (auto* arg : script_args)
args.empend(arg);
- shell->set_local_variable("ARGV", adopt(*new Shell::AST::ListValue(move(args))));
+ shell->set_local_variable("ARGV", adopt_ref(*new Shell::AST::ListValue(move(args))));
}
if (command_to_run) {