diff options
author | Andreas Kling <kling@serenityos.org> | 2021-04-23 16:46:57 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-23 16:46:57 +0200 |
commit | b91c49364df1683c7fe1191eb02b8d9c331874f6 (patch) | |
tree | a9ea5ff8e4cc8cfcfe75c279551be35793d0ffb3 /Userland/Libraries/LibWeb/HTML | |
parent | b3db01e20eeae632cc75df9af8666772bda67091 (diff) | |
download | serenity-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.)
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML')
13 files changed, 26 insertions, 26 deletions
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) |