1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:47:34 +00:00

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.)
This commit is contained in:
Andreas Kling 2021-04-23 16:46:57 +02:00
parent b3db01e20e
commit b91c49364d
228 changed files with 461 additions and 461 deletions

View file

@ -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(); }

View file

@ -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"; }

View file

@ -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()

View file

@ -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)

View file

@ -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;

View file

@ -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)

View file

@ -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) \

View file

@ -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;

View file

@ -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;
}

View file

@ -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)

View file

@ -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();

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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);

View file

@ -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;
}

View file

@ -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;

View file

@ -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 {};

View file

@ -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");

View file

@ -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;

View file

@ -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 { }

View file

@ -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 { }

View file

@ -12,7 +12,7 @@ namespace GUI {
NonnullRefPtr<RunningProcessesModel> RunningProcessesModel::create()
{
return adopt(*new RunningProcessesModel);
return adopt_ref(*new RunningProcessesModel);
}
RunningProcessesModel::RunningProcessesModel()

View file

@ -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;

View file

@ -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)

View file

@ -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;
}

View file

@ -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; }

View file

@ -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:

View file

@ -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)

View file

@ -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));
}
}

View file

@ -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;
}

View file

@ -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; }

View file

@ -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)

View file

@ -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 {};

View file

@ -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 {};
}

View file

@ -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; }

View file

@ -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> {

View file

@ -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()); }

View file

@ -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()) {

View file

@ -24,7 +24,7 @@ namespace JS {
NonnullRefPtr<VM> VM::create()
{
return adopt(*new VM);
return adopt_ref(*new VM);
}
VM::VM()

View file

@ -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;

View file

@ -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; }

View file

@ -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> {

View file

@ -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

View file

@ -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() { }

View file

@ -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();

View file

@ -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(); }

View file

@ -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();

View file

@ -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;

View file

@ -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(); }

View file

@ -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)

View file

@ -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;

View file

@ -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>);

View file

@ -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()); }

View file

@ -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)) {

View file

@ -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; }

View file

@ -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);
}

View file

@ -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;

View file

@ -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;

View file

@ -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&)
{

View file

@ -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();
}

View file

@ -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)));
}
}

View file

@ -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)
{

View file

@ -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();

View file

@ -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);

View file

@ -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

View file

@ -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 {}));
}
}

View file

@ -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));
}
}

View file

@ -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)

View file

@ -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)

View file

@ -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;

View file

@ -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);

View file

@ -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()) {

View file

@ -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));
}
}

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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));

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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)

View file

@ -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;
}

View file

@ -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)

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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");

View file

@ -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)

View file

@ -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 {

View file

@ -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)

View file

@ -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

View file

@ -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; }

View file

@ -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;

View file

@ -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 { }

View file

@ -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)
{

View file

@ -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)