mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 20:27:46 +00:00
LibJS: Convert Heap::allocate{,_without_realm}() to NonnullGCPtr
This commit is contained in:
parent
2a66fc6cae
commit
22089436ed
161 changed files with 367 additions and 370 deletions
|
@ -34,9 +34,9 @@ public:
|
|||
if (it != m_prototypes.end())
|
||||
return *it->value;
|
||||
auto& realm = *m_realm;
|
||||
auto* prototype = heap().allocate<T>(realm, realm);
|
||||
auto prototype = heap().allocate<T>(realm, realm);
|
||||
m_prototypes.set(class_name, prototype);
|
||||
return *prototype;
|
||||
return prototype;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -46,9 +46,9 @@ public:
|
|||
if (it != m_constructors.end())
|
||||
return *it->value;
|
||||
auto& realm = *m_realm;
|
||||
auto* constructor = heap().allocate<T>(realm, realm);
|
||||
auto constructor = heap().allocate<T>(realm, realm);
|
||||
m_constructors.set(class_name, constructor);
|
||||
return *constructor;
|
||||
return constructor;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -375,8 +375,8 @@ JS::VM& main_thread_vm()
|
|||
custom_data.root_execution_context = MUST(JS::Realm::initialize_host_defined_realm(*vm, nullptr, nullptr));
|
||||
|
||||
auto* root_realm = custom_data.root_execution_context->realm;
|
||||
auto* intrinsics = root_realm->heap().allocate<Intrinsics>(*root_realm, *root_realm);
|
||||
auto host_defined = make<HostDefined>(nullptr, *intrinsics);
|
||||
auto intrinsics = root_realm->heap().allocate<Intrinsics>(*root_realm, *root_realm);
|
||||
auto host_defined = make<HostDefined>(nullptr, intrinsics);
|
||||
root_realm->set_host_defined(move(host_defined));
|
||||
custom_data.internal_realm = root_realm;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Web::CSS {
|
|||
|
||||
CSSRuleList* CSSRuleList::create(JS::Realm& realm, JS::MarkedVector<CSSRule*> const& rules)
|
||||
{
|
||||
auto* rule_list = realm.heap().allocate<CSSRuleList>(realm, realm);
|
||||
auto rule_list = realm.heap().allocate<CSSRuleList>(realm, realm);
|
||||
for (auto* rule : rules)
|
||||
rule_list->m_rules.append(*rule);
|
||||
return rule_list;
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Web::CSS {
|
|||
|
||||
JS::NonnullGCPtr<MediaQueryList> MediaQueryList::create(DOM::Document& document, NonnullRefPtrVector<MediaQuery>&& media)
|
||||
{
|
||||
return *document.heap().allocate<MediaQueryList>(document.realm(), document, move(media));
|
||||
return document.heap().allocate<MediaQueryList>(document.realm(), document, move(media));
|
||||
}
|
||||
|
||||
MediaQueryList::MediaQueryList(DOM::Document& document, NonnullRefPtrVector<MediaQuery>&& media)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -15,7 +15,7 @@ namespace Web::CSS {
|
|||
|
||||
JS::NonnullGCPtr<Screen> Screen::create(HTML::Window& window)
|
||||
{
|
||||
return *window.heap().allocate<Screen>(window.realm(), window);
|
||||
return window.heap().allocate<Screen>(window.realm(), window);
|
||||
}
|
||||
|
||||
Screen::Screen(HTML::Window& window)
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Web::Crypto {
|
|||
|
||||
JS::NonnullGCPtr<Crypto> Crypto::create(JS::Realm& realm)
|
||||
{
|
||||
return *realm.heap().allocate<Crypto>(realm, realm);
|
||||
return realm.heap().allocate<Crypto>(realm, realm);
|
||||
}
|
||||
|
||||
Crypto::Crypto(JS::Realm& realm)
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Web::Crypto {
|
|||
|
||||
JS::NonnullGCPtr<SubtleCrypto> SubtleCrypto::create(JS::Realm& realm)
|
||||
{
|
||||
return *realm.heap().allocate<SubtleCrypto>(realm, realm);
|
||||
return realm.heap().allocate<SubtleCrypto>(realm, realm);
|
||||
}
|
||||
|
||||
SubtleCrypto::SubtleCrypto(JS::Realm& realm)
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::DOM {
|
|||
JS::NonnullGCPtr<AbortController> AbortController::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
auto signal = AbortSignal::construct_impl(realm);
|
||||
return *realm.heap().allocate<AbortController>(realm, realm, move(signal));
|
||||
return realm.heap().allocate<AbortController>(realm, realm, move(signal));
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-abortcontroller-abortcontroller
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<AbortSignal> AbortSignal::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
return *realm.heap().allocate<AbortSignal>(realm, realm);
|
||||
return realm.heap().allocate<AbortSignal>(realm, realm);
|
||||
}
|
||||
|
||||
AbortSignal::AbortSignal(JS::Realm& realm)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<Attr> Attr::create(Document& document, FlyString local_name, DeprecatedString value, Element const* owner_element)
|
||||
{
|
||||
return *document.heap().allocate<Attr>(document.realm(), document, QualifiedName(move(local_name), {}, {}), move(value), owner_element);
|
||||
return document.heap().allocate<Attr>(document.realm(), document, QualifiedName(move(local_name), {}, {}), move(value), owner_element);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Attr> Attr::clone(Document& document)
|
||||
|
|
|
@ -19,7 +19,7 @@ Comment::Comment(Document& document, DeprecatedString const& data)
|
|||
JS::NonnullGCPtr<Comment> Comment::construct_impl(JS::Realm& realm, DeprecatedString const& data)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
return *realm.heap().allocate<Comment>(realm, window.associated_document(), data);
|
||||
return realm.heap().allocate<Comment>(realm, window.associated_document(), data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Web::DOM {
|
|||
JS::NonnullGCPtr<DOMImplementation> DOMImplementation::create(Document& document)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
return *realm.heap().allocate<DOMImplementation>(realm, document);
|
||||
return realm.heap().allocate<DOMImplementation>(realm, document);
|
||||
}
|
||||
|
||||
DOMImplementation::DOMImplementation(Document& document)
|
||||
|
|
|
@ -289,7 +289,7 @@ JS::NonnullGCPtr<Document> Document::construct_impl(JS::Realm& realm)
|
|||
|
||||
JS::NonnullGCPtr<Document> Document::create(JS::Realm& realm, AK::URL const& url)
|
||||
{
|
||||
return *realm.heap().allocate<Document>(realm, realm, url);
|
||||
return realm.heap().allocate<Document>(realm, realm, url);
|
||||
}
|
||||
|
||||
Document::Document(JS::Realm& realm, const AK::URL& url)
|
||||
|
@ -680,7 +680,7 @@ void Document::set_title(DeprecatedString const& title)
|
|||
}
|
||||
|
||||
title_element->remove_all_children(true);
|
||||
MUST(title_element->append_child(*heap().allocate<Text>(realm(), *this, title)));
|
||||
MUST(title_element->append_child(heap().allocate<Text>(realm(), *this, title)));
|
||||
|
||||
if (auto* page = this->page()) {
|
||||
if (browsing_context() == &page->top_level_browsing_context())
|
||||
|
@ -1221,17 +1221,17 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element_ns(Depre
|
|||
|
||||
JS::NonnullGCPtr<DocumentFragment> Document::create_document_fragment()
|
||||
{
|
||||
return *heap().allocate<DocumentFragment>(realm(), *this);
|
||||
return heap().allocate<DocumentFragment>(realm(), *this);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Text> Document::create_text_node(DeprecatedString const& data)
|
||||
{
|
||||
return *heap().allocate<Text>(realm(), *this, data);
|
||||
return heap().allocate<Text>(realm(), *this, data);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Comment> Document::create_comment(DeprecatedString const& data)
|
||||
{
|
||||
return *heap().allocate<Comment>(realm(), *this, data);
|
||||
return heap().allocate<Comment>(realm(), *this, data);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
|
||||
|
|
|
@ -30,7 +30,7 @@ void DocumentFragment::set_host(Web::DOM::Element* element)
|
|||
JS::NonnullGCPtr<DocumentFragment> DocumentFragment::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
return *realm.heap().allocate<DocumentFragment>(realm, window.associated_document());
|
||||
return realm.heap().allocate<DocumentFragment>(realm, window.associated_document());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<DocumentType> DocumentType::create(Document& document)
|
||||
{
|
||||
return *document.heap().allocate<DocumentType>(document.realm(), document);
|
||||
return document.heap().allocate<DocumentType>(document.realm(), document);
|
||||
}
|
||||
|
||||
DocumentType::DocumentType(Document& document)
|
||||
|
|
|
@ -1174,11 +1174,11 @@ WebIDL::ExceptionOr<JS::GCPtr<Element>> Element::insert_adjacent_element(Depreca
|
|||
WebIDL::ExceptionOr<void> Element::insert_adjacent_text(DeprecatedString const& where, DeprecatedString const& data)
|
||||
{
|
||||
// 1. Let text be a new Text node whose data is data and node document is this’s node document.
|
||||
JS::NonnullGCPtr<Text> text = *heap().allocate<DOM::Text>(realm(), document(), data);
|
||||
auto text = heap().allocate<DOM::Text>(realm(), document(), data);
|
||||
|
||||
// 2. Run insert adjacent, given this, where, and text.
|
||||
// Spec Note: This method returns nothing because it existed before we had a chance to design it.
|
||||
(void)TRY(insert_adjacent(where, move(text)));
|
||||
(void)TRY(insert_adjacent(where, text));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -120,180 +120,180 @@ JS::NonnullGCPtr<Element> create_element(Document& document, FlyString local_nam
|
|||
|
||||
auto qualified_name = QualifiedName { local_name, prefix, namespace_ };
|
||||
if (lowercase_tag_name == HTML::TagNames::a)
|
||||
return *realm.heap().allocate<HTML::HTMLAnchorElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLAnchorElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::area)
|
||||
return *realm.heap().allocate<HTML::HTMLAreaElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLAreaElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::audio)
|
||||
return *realm.heap().allocate<HTML::HTMLAudioElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLAudioElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::base)
|
||||
return *realm.heap().allocate<HTML::HTMLBaseElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLBaseElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::blink)
|
||||
return *realm.heap().allocate<HTML::HTMLBlinkElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLBlinkElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::body)
|
||||
return *realm.heap().allocate<HTML::HTMLBodyElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLBodyElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::br)
|
||||
return *realm.heap().allocate<HTML::HTMLBRElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLBRElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::button)
|
||||
return *realm.heap().allocate<HTML::HTMLButtonElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLButtonElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::canvas)
|
||||
return *realm.heap().allocate<HTML::HTMLCanvasElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLCanvasElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::data)
|
||||
return *realm.heap().allocate<HTML::HTMLDataElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLDataElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::datalist)
|
||||
return *realm.heap().allocate<HTML::HTMLDataListElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLDataListElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::details)
|
||||
return *realm.heap().allocate<HTML::HTMLDetailsElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLDetailsElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::dialog)
|
||||
return *realm.heap().allocate<HTML::HTMLDialogElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLDialogElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::dir)
|
||||
return *realm.heap().allocate<HTML::HTMLDirectoryElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLDirectoryElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::div)
|
||||
return *realm.heap().allocate<HTML::HTMLDivElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLDivElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::dl)
|
||||
return *realm.heap().allocate<HTML::HTMLDListElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLDListElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::embed)
|
||||
return *realm.heap().allocate<HTML::HTMLEmbedElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLEmbedElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::fieldset)
|
||||
return *realm.heap().allocate<HTML::HTMLFieldSetElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLFieldSetElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::font)
|
||||
return *realm.heap().allocate<HTML::HTMLFontElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLFontElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::form)
|
||||
return *realm.heap().allocate<HTML::HTMLFormElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLFormElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::frame)
|
||||
return *realm.heap().allocate<HTML::HTMLFrameElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLFrameElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::frameset)
|
||||
return *realm.heap().allocate<HTML::HTMLFrameSetElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLFrameSetElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::head)
|
||||
return *realm.heap().allocate<HTML::HTMLHeadElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLHeadElement>(realm, 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 *realm.heap().allocate<HTML::HTMLHeadingElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLHeadingElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::hr)
|
||||
return *realm.heap().allocate<HTML::HTMLHRElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLHRElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::html)
|
||||
return *realm.heap().allocate<HTML::HTMLHtmlElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLHtmlElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::iframe)
|
||||
return *realm.heap().allocate<HTML::HTMLIFrameElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLIFrameElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::img)
|
||||
return *realm.heap().allocate<HTML::HTMLImageElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLImageElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::input)
|
||||
return *realm.heap().allocate<HTML::HTMLInputElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLInputElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::label)
|
||||
return *realm.heap().allocate<HTML::HTMLLabelElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLLabelElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::legend)
|
||||
return *realm.heap().allocate<HTML::HTMLLegendElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLLegendElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::li)
|
||||
return *realm.heap().allocate<HTML::HTMLLIElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLLIElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::link)
|
||||
return *realm.heap().allocate<HTML::HTMLLinkElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLLinkElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::map)
|
||||
return *realm.heap().allocate<HTML::HTMLMapElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLMapElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::marquee)
|
||||
return *realm.heap().allocate<HTML::HTMLMarqueeElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLMarqueeElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::menu)
|
||||
return *realm.heap().allocate<HTML::HTMLMenuElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLMenuElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::meta)
|
||||
return *realm.heap().allocate<HTML::HTMLMetaElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLMetaElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::meter)
|
||||
return *realm.heap().allocate<HTML::HTMLMeterElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLMeterElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name.is_one_of(HTML::TagNames::ins, HTML::TagNames::del))
|
||||
return *realm.heap().allocate<HTML::HTMLModElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLModElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::object)
|
||||
return *realm.heap().allocate<HTML::HTMLObjectElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLObjectElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::ol)
|
||||
return *realm.heap().allocate<HTML::HTMLOListElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLOListElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::optgroup)
|
||||
return *realm.heap().allocate<HTML::HTMLOptGroupElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLOptGroupElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::option)
|
||||
return *realm.heap().allocate<HTML::HTMLOptionElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLOptionElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::output)
|
||||
return *realm.heap().allocate<HTML::HTMLOutputElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLOutputElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::p)
|
||||
return *realm.heap().allocate<HTML::HTMLParagraphElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLParagraphElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::param)
|
||||
return *realm.heap().allocate<HTML::HTMLParamElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLParamElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::picture)
|
||||
return *realm.heap().allocate<HTML::HTMLPictureElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLPictureElement>(realm, 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 *realm.heap().allocate<HTML::HTMLPreElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLPreElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::progress)
|
||||
return *realm.heap().allocate<HTML::HTMLProgressElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLProgressElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name.is_one_of(HTML::TagNames::blockquote, HTML::TagNames::q))
|
||||
return *realm.heap().allocate<HTML::HTMLQuoteElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLQuoteElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::script)
|
||||
return *realm.heap().allocate<HTML::HTMLScriptElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLScriptElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::select)
|
||||
return *realm.heap().allocate<HTML::HTMLSelectElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLSelectElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::slot)
|
||||
return *realm.heap().allocate<HTML::HTMLSlotElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLSlotElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::source)
|
||||
return *realm.heap().allocate<HTML::HTMLSourceElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLSourceElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::span)
|
||||
return *realm.heap().allocate<HTML::HTMLSpanElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLSpanElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::style)
|
||||
return *realm.heap().allocate<HTML::HTMLStyleElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLStyleElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::caption)
|
||||
return *realm.heap().allocate<HTML::HTMLTableCaptionElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLTableCaptionElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name.is_one_of(Web::HTML::TagNames::td, Web::HTML::TagNames::th))
|
||||
return *realm.heap().allocate<HTML::HTMLTableCellElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLTableCellElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name.is_one_of(HTML::TagNames::colgroup, HTML::TagNames::col))
|
||||
return *realm.heap().allocate<HTML::HTMLTableColElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLTableColElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::table)
|
||||
return *realm.heap().allocate<HTML::HTMLTableElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLTableElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::tr)
|
||||
return *realm.heap().allocate<HTML::HTMLTableRowElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLTableRowElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name.is_one_of(HTML::TagNames::tbody, HTML::TagNames::thead, HTML::TagNames::tfoot))
|
||||
return *realm.heap().allocate<HTML::HTMLTableSectionElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLTableSectionElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::template_)
|
||||
return *realm.heap().allocate<HTML::HTMLTemplateElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLTemplateElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::textarea)
|
||||
return *realm.heap().allocate<HTML::HTMLTextAreaElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLTextAreaElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::time)
|
||||
return *realm.heap().allocate<HTML::HTMLTimeElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLTimeElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::title)
|
||||
return *realm.heap().allocate<HTML::HTMLTitleElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLTitleElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::track)
|
||||
return *realm.heap().allocate<HTML::HTMLTrackElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLTrackElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::ul)
|
||||
return *realm.heap().allocate<HTML::HTMLUListElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLUListElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::video)
|
||||
return *realm.heap().allocate<HTML::HTMLVideoElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLVideoElement>(realm, 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 *realm.heap().allocate<HTML::HTMLElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == SVG::TagNames::svg)
|
||||
return *realm.heap().allocate<SVG::SVGSVGElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<SVG::SVGSVGElement>(realm, document, move(qualified_name));
|
||||
// FIXME: Support SVG's mixedCase tag names properly.
|
||||
if (lowercase_tag_name.equals_ignoring_case(SVG::TagNames::clipPath))
|
||||
return *realm.heap().allocate<SVG::SVGClipPathElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<SVG::SVGClipPathElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == SVG::TagNames::circle)
|
||||
return *realm.heap().allocate<SVG::SVGCircleElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<SVG::SVGCircleElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name.equals_ignoring_case(SVG::TagNames::defs))
|
||||
return *realm.heap().allocate<SVG::SVGDefsElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<SVG::SVGDefsElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == SVG::TagNames::ellipse)
|
||||
return *realm.heap().allocate<SVG::SVGEllipseElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<SVG::SVGEllipseElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name.equals_ignoring_case(SVG::TagNames::foreignObject))
|
||||
return *realm.heap().allocate<SVG::SVGForeignObjectElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<SVG::SVGForeignObjectElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == SVG::TagNames::line)
|
||||
return *realm.heap().allocate<SVG::SVGLineElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<SVG::SVGLineElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == SVG::TagNames::path)
|
||||
return *realm.heap().allocate<SVG::SVGPathElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<SVG::SVGPathElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == SVG::TagNames::polygon)
|
||||
return *realm.heap().allocate<SVG::SVGPolygonElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<SVG::SVGPolygonElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == SVG::TagNames::polyline)
|
||||
return *realm.heap().allocate<SVG::SVGPolylineElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<SVG::SVGPolylineElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == SVG::TagNames::rect)
|
||||
return *realm.heap().allocate<SVG::SVGRectElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<SVG::SVGRectElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == SVG::TagNames::g)
|
||||
return *realm.heap().allocate<SVG::SVGGElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<SVG::SVGGElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == SVG::TagNames::text)
|
||||
return *realm.heap().allocate<SVG::SVGTextContentElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<SVG::SVGTextContentElement>(realm, document, move(qualified_name));
|
||||
|
||||
// FIXME: If name is a valid custom element name, then return HTMLElement.
|
||||
|
||||
return *realm.heap().allocate<HTML::HTMLUnknownElement>(realm, document, move(qualified_name));
|
||||
return realm.heap().allocate<HTML::HTMLUnknownElement>(realm, document, move(qualified_name));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<Event> Event::create(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init)
|
||||
{
|
||||
return *realm.heap().allocate<Event>(realm, realm, event_name, event_init);
|
||||
return realm.heap().allocate<Event>(realm, realm, event_name, event_init);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Event> Event::construct_impl(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init)
|
||||
|
|
|
@ -128,7 +128,7 @@ void EventTarget::add_event_listener(FlyString const& type, IDLEventListener* ca
|
|||
// 2. Add an event listener with this and an event listener whose type is type, callback is callback, capture is capture, passive is passive,
|
||||
// once is once, and signal is signal.
|
||||
|
||||
auto* event_listener = heap().allocate_without_realm<DOMEventListener>();
|
||||
auto event_listener = heap().allocate_without_realm<DOMEventListener>();
|
||||
event_listener->type = type;
|
||||
event_listener->callback = callback;
|
||||
event_listener->signal = move(flattened_options.signal);
|
||||
|
@ -464,7 +464,7 @@ WebIDL::CallbackType* EventTarget::get_current_value_of_event_handler(FlyString
|
|||
function->set_script_or_module({});
|
||||
|
||||
// 12. Set eventHandler's value to the result of creating a Web IDL EventHandler callback function object whose object reference is function and whose callback context is settings object.
|
||||
event_handler->value = realm.heap().allocate_without_realm<WebIDL::CallbackType>(*function, settings_object);
|
||||
event_handler->value = realm.heap().allocate_without_realm<WebIDL::CallbackType>(*function, settings_object).ptr();
|
||||
}
|
||||
|
||||
// 4. Return eventHandler's value.
|
||||
|
@ -498,7 +498,7 @@ void EventTarget::set_event_handler_attribute(FlyString const& name, WebIDL::Cal
|
|||
// 3. Set eventHandler's value to the given value.
|
||||
if (event_handler_iterator == handler_map.end()) {
|
||||
// NOTE: See the optimization comment in get_current_value_of_event_handler about why this is done.
|
||||
auto* new_event_handler = heap().allocate_without_realm<HTML::EventHandler>(*value);
|
||||
auto new_event_handler = heap().allocate_without_realm<HTML::EventHandler>(*value);
|
||||
|
||||
// 4. Activate an event handler given eventTarget and name.
|
||||
// Optimization: We pass in the event handler here instead of having activate_event_handler do another hash map lookup just to get the same object.
|
||||
|
@ -556,10 +556,10 @@ void EventTarget::activate_event_handler(FlyString const& name, HTML::EventHandl
|
|||
0, "", &realm);
|
||||
|
||||
// NOTE: As per the spec, the callback context is arbitrary.
|
||||
auto* callback = realm.heap().allocate_without_realm<WebIDL::CallbackType>(*callback_function, Bindings::host_defined_environment_settings_object(realm));
|
||||
auto callback = realm.heap().allocate_without_realm<WebIDL::CallbackType>(*callback_function, Bindings::host_defined_environment_settings_object(realm));
|
||||
|
||||
// 5. Let listener be a new event listener whose type is the event handler event type corresponding to eventHandler and callback is callback.
|
||||
auto* listener = realm.heap().allocate_without_realm<DOMEventListener>();
|
||||
auto listener = realm.heap().allocate_without_realm<DOMEventListener>();
|
||||
listener->type = name;
|
||||
listener->callback = IDLEventListener::create(realm, *callback).ptr();
|
||||
|
||||
|
@ -714,7 +714,7 @@ void EventTarget::element_event_handler_attribute_changed(FlyString const& local
|
|||
// NOTE: See the optimization comments in set_event_handler_attribute.
|
||||
|
||||
if (event_handler_iterator == handler_map.end()) {
|
||||
auto* new_event_handler = heap().allocate_without_realm<HTML::EventHandler>(value);
|
||||
auto new_event_handler = heap().allocate_without_realm<HTML::EventHandler>(value);
|
||||
|
||||
// 6. Activate an event handler given eventTarget and name.
|
||||
event_target->activate_event_handler(local_name, *new_event_handler);
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<HTMLCollection> HTMLCollection::create(ParentNode& root, Function<bool(Element const&)> filter)
|
||||
{
|
||||
return *root.heap().allocate<HTMLCollection>(root.realm(), root, move(filter));
|
||||
return root.heap().allocate<HTMLCollection>(root.realm(), root, move(filter));
|
||||
}
|
||||
|
||||
HTMLCollection::HTMLCollection(ParentNode& root, Function<bool(Element const&)> filter)
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<IDLEventListener> IDLEventListener::create(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::CallbackType> callback)
|
||||
{
|
||||
return *realm.heap().allocate<IDLEventListener>(realm, realm, move(callback));
|
||||
return realm.heap().allocate<IDLEventListener>(realm, realm, move(callback));
|
||||
}
|
||||
|
||||
IDLEventListener::IDLEventListener(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::CallbackType> callback)
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<NodeList> LiveNodeList::create(JS::Realm& realm, Node& root, Function<bool(Node const&)> filter)
|
||||
{
|
||||
return *realm.heap().allocate<LiveNodeList>(realm, realm, root, move(filter));
|
||||
return realm.heap().allocate<LiveNodeList>(realm, realm, root, move(filter));
|
||||
}
|
||||
|
||||
LiveNodeList::LiveNodeList(JS::Realm& realm, Node& root, Function<bool(Node const&)> filter)
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<MutationObserver> MutationObserver::construct_impl(JS::Realm& realm, JS::GCPtr<WebIDL::CallbackType> callback)
|
||||
{
|
||||
return *realm.heap().allocate<MutationObserver>(realm, realm, callback);
|
||||
return realm.heap().allocate<MutationObserver>(realm, realm, callback);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-mutationobserver-mutationobserver
|
||||
|
@ -142,7 +142,7 @@ Vector<JS::Handle<MutationRecord>> MutationObserver::take_records()
|
|||
|
||||
JS::NonnullGCPtr<RegisteredObserver> RegisteredObserver::create(MutationObserver& observer, MutationObserverInit const& options)
|
||||
{
|
||||
return *observer.heap().allocate_without_realm<RegisteredObserver>(observer, options);
|
||||
return observer.heap().allocate_without_realm<RegisteredObserver>(observer, options);
|
||||
}
|
||||
|
||||
RegisteredObserver::RegisteredObserver(MutationObserver& observer, MutationObserverInit const& options)
|
||||
|
@ -161,7 +161,7 @@ void RegisteredObserver::visit_edges(Cell::Visitor& visitor)
|
|||
|
||||
JS::NonnullGCPtr<TransientRegisteredObserver> TransientRegisteredObserver::create(MutationObserver& observer, MutationObserverInit const& options, RegisteredObserver& source)
|
||||
{
|
||||
return *observer.heap().allocate_without_realm<TransientRegisteredObserver>(observer, options, source);
|
||||
return observer.heap().allocate_without_realm<TransientRegisteredObserver>(observer, options, source);
|
||||
}
|
||||
|
||||
TransientRegisteredObserver::TransientRegisteredObserver(MutationObserver& observer, MutationObserverInit const& options, RegisteredObserver& source)
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<MutationRecord> MutationRecord::create(JS::Realm& realm, FlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value)
|
||||
{
|
||||
return *realm.heap().allocate<MutationRecord>(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value);
|
||||
return realm.heap().allocate<MutationRecord>(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value);
|
||||
}
|
||||
|
||||
MutationRecord::MutationRecord(JS::Realm& realm, FlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Web::DOM {
|
|||
JS::NonnullGCPtr<NamedNodeMap> NamedNodeMap::create(Element& element)
|
||||
{
|
||||
auto& realm = element.realm();
|
||||
return *realm.heap().allocate<NamedNodeMap>(realm, element);
|
||||
return realm.heap().allocate<NamedNodeMap>(realm, element);
|
||||
}
|
||||
|
||||
NamedNodeMap::NamedNodeMap(Element& element)
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<NodeFilter> NodeFilter::create(JS::Realm& realm, WebIDL::CallbackType& callback)
|
||||
{
|
||||
return *realm.heap().allocate<NodeFilter>(realm, realm, callback);
|
||||
return realm.heap().allocate<NodeFilter>(realm, realm, callback);
|
||||
}
|
||||
|
||||
NodeFilter::NodeFilter(JS::Realm& realm, WebIDL::CallbackType& callback)
|
||||
|
|
|
@ -45,7 +45,7 @@ JS::NonnullGCPtr<NodeIterator> NodeIterator::create(Node& root, unsigned what_to
|
|||
// 2. Set iterator’s root and iterator’s reference to root.
|
||||
// 3. Set iterator’s pointer before reference to true.
|
||||
auto& realm = root.realm();
|
||||
auto* iterator = realm.heap().allocate<NodeIterator>(realm, root);
|
||||
auto iterator = realm.heap().allocate<NodeIterator>(realm, root);
|
||||
|
||||
// 4. Set iterator’s whatToShow to whatToShow.
|
||||
iterator->m_what_to_show = what_to_show;
|
||||
|
@ -54,7 +54,7 @@ JS::NonnullGCPtr<NodeIterator> NodeIterator::create(Node& root, unsigned what_to
|
|||
iterator->m_filter = filter;
|
||||
|
||||
// 6. Return iterator.
|
||||
return *iterator;
|
||||
return iterator;
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-nodeiterator-detach
|
||||
|
|
|
@ -26,14 +26,13 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> convert_nodes_to_single_node(Vector<
|
|||
if (node.has<JS::Handle<Node>>())
|
||||
return *node.get<JS::Handle<Node>>();
|
||||
|
||||
return *document.heap().allocate<DOM::Text>(document.realm(), document, node.get<DeprecatedString>());
|
||||
return document.heap().allocate<DOM::Text>(document.realm(), document, node.get<DeprecatedString>());
|
||||
};
|
||||
|
||||
if (nodes.size() == 1)
|
||||
return potentially_convert_string_to_text_node(nodes.first());
|
||||
|
||||
// This is NNGCP<Node> instead of NNGCP<DocumentFragment> to be compatible with the return type.
|
||||
JS::NonnullGCPtr<Node> document_fragment = *document.heap().allocate<DOM::DocumentFragment>(document.realm(), document);
|
||||
auto document_fragment = document.heap().allocate<DOM::DocumentFragment>(document.realm(), document);
|
||||
for (auto& unconverted_node : nodes) {
|
||||
auto node = potentially_convert_string_to_text_node(unconverted_node);
|
||||
(void)TRY(document_fragment->append_child(node));
|
||||
|
|
|
@ -34,13 +34,13 @@ JS::NonnullGCPtr<Range> Range::create(HTML::Window& window)
|
|||
JS::NonnullGCPtr<Range> Range::create(Document& document)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
return *realm.heap().allocate<Range>(realm, document);
|
||||
return realm.heap().allocate<Range>(realm, document);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Range> Range::create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset)
|
||||
{
|
||||
auto& realm = start_container.realm();
|
||||
return *realm.heap().allocate<Range>(realm, start_container, start_offset, end_container, end_offset);
|
||||
return realm.heap().allocate<Range>(realm, start_container, start_offset, end_container, end_offset);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Range> Range::construct_impl(JS::Realm& realm)
|
||||
|
@ -396,12 +396,12 @@ WebIDL::ExceptionOr<void> Range::select_node_contents(Node const& node)
|
|||
|
||||
JS::NonnullGCPtr<Range> Range::clone_range() const
|
||||
{
|
||||
return *heap().allocate<Range>(shape().realm(), const_cast<Node&>(*m_start_container), m_start_offset, const_cast<Node&>(*m_end_container), m_end_offset);
|
||||
return heap().allocate<Range>(shape().realm(), const_cast<Node&>(*m_start_container), m_start_offset, const_cast<Node&>(*m_end_container), m_end_offset);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Range> Range::inverted() const
|
||||
{
|
||||
return *heap().allocate<Range>(shape().realm(), const_cast<Node&>(*m_end_container), m_end_offset, const_cast<Node&>(*m_start_container), m_start_offset);
|
||||
return heap().allocate<Range>(shape().realm(), const_cast<Node&>(*m_end_container), m_end_offset, const_cast<Node&>(*m_start_container), m_start_offset);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Range> Range::normalized() const
|
||||
|
@ -555,11 +555,11 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract_contents(
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract()
|
||||
{
|
||||
// 1. Let fragment be a new DocumentFragment node whose node document is range’s start node’s node document.
|
||||
auto* fragment = heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document()));
|
||||
auto fragment = heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document()));
|
||||
|
||||
// 2. If range is collapsed, then return fragment.
|
||||
if (collapsed())
|
||||
return JS::NonnullGCPtr(*fragment);
|
||||
return fragment;
|
||||
|
||||
// 3. Let original start node, original start offset, original end node, and original end offset
|
||||
// be range’s start node, start offset, end node, and end offset, respectively.
|
||||
|
@ -585,7 +585,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract()
|
|||
TRY(static_cast<CharacterData&>(*original_start_node).replace_data(original_start_offset, original_end_offset - original_start_offset, ""));
|
||||
|
||||
// 5. Return fragment.
|
||||
return JS::NonnullGCPtr(*fragment);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
// 5. Let common ancestor be original start node.
|
||||
|
@ -735,7 +735,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract()
|
|||
TRY(set_end(*new_node, new_offset));
|
||||
|
||||
// 21. Return fragment.
|
||||
return JS::NonnullGCPtr(*fragment);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#contained
|
||||
|
@ -884,11 +884,11 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_contents()
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_the_contents()
|
||||
{
|
||||
// 1. Let fragment be a new DocumentFragment node whose node document is range’s start node’s node document.
|
||||
auto* fragment = heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document()));
|
||||
auto fragment = heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document()));
|
||||
|
||||
// 2. If range is collapsed, then return fragment.
|
||||
if (collapsed())
|
||||
return JS::NonnullGCPtr(*fragment);
|
||||
return fragment;
|
||||
|
||||
// 3. Let original start node, original start offset, original end node, and original end offset
|
||||
// be range’s start node, start offset, end node, and end offset, respectively.
|
||||
|
@ -911,7 +911,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_the_content
|
|||
TRY(fragment->append_child(clone));
|
||||
|
||||
// 4. Return fragment.
|
||||
return JS::NonnullGCPtr(*fragment);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
// 5. Let common ancestor be original start node.
|
||||
|
@ -1033,7 +1033,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_the_content
|
|||
}
|
||||
|
||||
// 18. Return fragment.
|
||||
return JS::NonnullGCPtr(*fragment);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-range-deletecontents
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<NodeList> StaticNodeList::create(JS::Realm& realm, Vector<JS::Handle<Node>> static_nodes)
|
||||
{
|
||||
return *realm.heap().allocate<StaticNodeList>(realm, realm, move(static_nodes));
|
||||
return realm.heap().allocate<StaticNodeList>(realm, realm, move(static_nodes));
|
||||
}
|
||||
|
||||
StaticNodeList::StaticNodeList(JS::Realm& realm, Vector<JS::Handle<Node>> static_nodes)
|
||||
|
|
|
@ -33,7 +33,7 @@ WebIDL::ExceptionOr<StaticRange*> StaticRange::construct_impl(JS::Realm& realm,
|
|||
return WebIDL::InvalidNodeTypeError::create(realm, "endContainer cannot be a DocumentType or Attribute node.");
|
||||
|
||||
// 2. Set this’s start to (init["startContainer"], init["startOffset"]) and end to (init["endContainer"], init["endOffset"]).
|
||||
return realm.heap().allocate<StaticRange>(realm, *init.start_container, init.start_offset, *init.end_container, init.end_offset);
|
||||
return realm.heap().allocate<StaticRange>(realm, *init.start_container, init.start_offset, *init.end_container, init.end_offset).ptr();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ JS::NonnullGCPtr<Text> Text::construct_impl(JS::Realm& realm, DeprecatedString c
|
|||
{
|
||||
// The new Text(data) constructor steps are to set this’s data to data and this’s node document to current global object’s associated Document.
|
||||
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
|
||||
return *realm.heap().allocate<Text>(realm, window.associated_document(), data);
|
||||
return realm.heap().allocate<Text>(realm, window.associated_document(), data);
|
||||
}
|
||||
|
||||
void Text::set_owner_input_element(Badge<HTML::HTMLInputElement>, HTML::HTMLInputElement& input_element)
|
||||
|
@ -63,7 +63,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Text>> Text::split_text(size_t offset)
|
|||
auto new_data = TRY(substring_data(offset, count));
|
||||
|
||||
// 5. Let new node be a new Text node, with the same node document as node. Set new node’s data to new data.
|
||||
auto new_node = JS::NonnullGCPtr(*heap().allocate<Text>(realm(), document(), new_data));
|
||||
auto new_node = heap().allocate<Text>(realm(), document(), new_data);
|
||||
|
||||
// 6. Let parent be node’s parent.
|
||||
JS::GCPtr<Node> parent = this->parent();
|
||||
|
|
|
@ -36,7 +36,7 @@ JS::NonnullGCPtr<TreeWalker> TreeWalker::create(Node& root, unsigned what_to_sho
|
|||
// 1. Let walker be a new TreeWalker object.
|
||||
// 2. Set walker’s root and walker’s current to root.
|
||||
auto& realm = root.realm();
|
||||
auto* walker = realm.heap().allocate<TreeWalker>(realm, root);
|
||||
auto walker = realm.heap().allocate<TreeWalker>(realm, root);
|
||||
|
||||
// 3. Set walker’s whatToShow to whatToShow.
|
||||
walker->m_what_to_show = what_to_show;
|
||||
|
@ -45,7 +45,7 @@ JS::NonnullGCPtr<TreeWalker> TreeWalker::create(Node& root, unsigned what_to_sho
|
|||
walker->m_filter = filter;
|
||||
|
||||
// 5. Return walker.
|
||||
return *walker;
|
||||
return walker;
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-treewalker-currentnode
|
||||
|
|
|
@ -28,7 +28,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOM::DocumentFragment>> parse_fragment(Depr
|
|||
(void)TRY(fragment->append_child(*child));
|
||||
}
|
||||
|
||||
return JS::NonnullGCPtr(*fragment);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Web::DOMParsing {
|
|||
|
||||
JS::NonnullGCPtr<XMLSerializer> XMLSerializer::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
return *realm.heap().allocate<XMLSerializer>(realm, realm);
|
||||
return realm.heap().allocate<XMLSerializer>(realm, realm);
|
||||
}
|
||||
|
||||
XMLSerializer::XMLSerializer(JS::Realm& realm)
|
||||
|
|
|
@ -18,7 +18,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> TextDecoder::construct_impl(J
|
|||
if (!decoder)
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, DeprecatedString::formatted("Invalid encoding {}", encoding) };
|
||||
|
||||
return JS::NonnullGCPtr(*realm.heap().allocate<TextDecoder>(realm, realm, *decoder, move(encoding), false, false));
|
||||
return realm.heap().allocate<TextDecoder>(realm, realm, *decoder, move(encoding), false, false);
|
||||
}
|
||||
|
||||
// https://encoding.spec.whatwg.org/#dom-textdecoder
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::Encoding {
|
|||
|
||||
JS::NonnullGCPtr<TextEncoder> TextEncoder::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
return *realm.heap().allocate<TextEncoder>(realm, realm);
|
||||
return realm.heap().allocate<TextEncoder>(realm, realm);
|
||||
}
|
||||
|
||||
TextEncoder::TextEncoder(JS::Realm& realm)
|
||||
|
|
|
@ -14,12 +14,12 @@ namespace Web::Fetch::Fetching {
|
|||
|
||||
JS::NonnullGCPtr<PendingResponse> PendingResponse::create(JS::VM& vm, JS::NonnullGCPtr<Infrastructure::Request> request)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<PendingResponse>(request) };
|
||||
return vm.heap().allocate_without_realm<PendingResponse>(request);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<PendingResponse> PendingResponse::create(JS::VM& vm, JS::NonnullGCPtr<Infrastructure::Request> request, JS::NonnullGCPtr<Infrastructure::Response> response)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<PendingResponse>(request, response) };
|
||||
return vm.heap().allocate_without_realm<PendingResponse>(request, response);
|
||||
}
|
||||
|
||||
PendingResponse::PendingResponse(JS::NonnullGCPtr<Infrastructure::Request> request, JS::GCPtr<Infrastructure::Response> response)
|
||||
|
|
|
@ -16,7 +16,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Headers>> Headers::construct_impl(JS::Realm
|
|||
auto& vm = realm.vm();
|
||||
|
||||
// The new Headers(init) constructor steps are:
|
||||
auto* headers = realm.heap().allocate<Headers>(realm, realm, Infrastructure::HeaderList::create(vm));
|
||||
auto headers = realm.heap().allocate<Headers>(realm, realm, Infrastructure::HeaderList::create(vm));
|
||||
|
||||
// 1. Set this’s guard to "none".
|
||||
headers->m_guard = Guard::None;
|
||||
|
@ -25,7 +25,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Headers>> Headers::construct_impl(JS::Realm
|
|||
if (init.has_value())
|
||||
TRY(headers->fill(*init));
|
||||
|
||||
return JS::NonnullGCPtr(*headers);
|
||||
return headers;
|
||||
}
|
||||
|
||||
Headers::Headers(JS::Realm& realm, JS::NonnullGCPtr<Infrastructure::HeaderList> header_list)
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Web::Fetch {
|
|||
|
||||
JS::NonnullGCPtr<HeadersIterator> HeadersIterator::create(Headers const& headers, JS::Object::PropertyKind iteration_kind)
|
||||
{
|
||||
return *headers.heap().allocate<HeadersIterator>(headers.realm(), headers, iteration_kind);
|
||||
return headers.heap().allocate<HeadersIterator>(headers.realm(), headers, iteration_kind);
|
||||
}
|
||||
|
||||
HeadersIterator::HeadersIterator(Headers const& headers, JS::Object::PropertyKind iteration_kind)
|
||||
|
|
|
@ -14,7 +14,7 @@ ConnectionTimingInfo::ConnectionTimingInfo() = default;
|
|||
|
||||
JS::NonnullGCPtr<ConnectionTimingInfo> ConnectionTimingInfo::create(JS::VM& vm)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<ConnectionTimingInfo>() };
|
||||
return vm.heap().allocate_without_realm<ConnectionTimingInfo>();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::Fetch::Infrastructure {
|
|||
|
||||
JS::NonnullGCPtr<FetchAlgorithms> FetchAlgorithms::create(JS::VM& vm, Input input)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<FetchAlgorithms>(move(input)) };
|
||||
return vm.heap().allocate_without_realm<FetchAlgorithms>(move(input));
|
||||
}
|
||||
|
||||
FetchAlgorithms::FetchAlgorithms(Input input)
|
||||
|
|
|
@ -15,7 +15,7 @@ FetchController::FetchController() = default;
|
|||
|
||||
JS::NonnullGCPtr<FetchController> FetchController::create(JS::VM& vm)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<FetchController>() };
|
||||
return vm.heap().allocate_without_realm<FetchController>();
|
||||
}
|
||||
|
||||
void FetchController::visit_edges(JS::Cell::Visitor& visitor)
|
||||
|
|
|
@ -23,7 +23,7 @@ JS::NonnullGCPtr<FetchParams> FetchParams::create(JS::VM& vm, JS::NonnullGCPtr<R
|
|||
{
|
||||
auto algorithms = Infrastructure::FetchAlgorithms::create(vm, {});
|
||||
auto controller = Infrastructure::FetchController::create(vm);
|
||||
return { *vm.heap().allocate_without_realm<FetchParams>(request, algorithms, controller, timing_info) };
|
||||
return vm.heap().allocate_without_realm<FetchParams>(request, algorithms, controller, timing_info);
|
||||
}
|
||||
|
||||
void FetchParams::visit_edges(JS::Cell::Visitor& visitor)
|
||||
|
|
|
@ -14,7 +14,7 @@ FetchTimingInfo::FetchTimingInfo() = default;
|
|||
|
||||
JS::NonnullGCPtr<FetchTimingInfo> FetchTimingInfo::create(JS::VM& vm)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<FetchTimingInfo>() };
|
||||
return vm.heap().allocate_without_realm<FetchTimingInfo>();
|
||||
}
|
||||
|
||||
void FetchTimingInfo::visit_edges(JS::Cell::Visitor& visitor)
|
||||
|
|
|
@ -34,7 +34,7 @@ WebIDL::ExceptionOr<Body> Body::clone() const
|
|||
|
||||
// FIXME: 1. Let « out1, out2 » be the result of teeing body’s stream.
|
||||
// FIXME: 2. Set body’s stream to out1.
|
||||
auto* out2 = vm.heap().allocate<Streams::ReadableStream>(realm, realm);
|
||||
auto out2 = vm.heap().allocate<Streams::ReadableStream>(realm, realm);
|
||||
|
||||
// 3. Return a body whose stream is out2 and other members are copied from body.
|
||||
return Body { JS::make_handle(out2), m_source, m_length };
|
||||
|
|
|
@ -48,7 +48,7 @@ ErrorOr<Header> Header::from_string_pair(StringView name, StringView value)
|
|||
|
||||
JS::NonnullGCPtr<HeaderList> HeaderList::create(JS::VM& vm)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<HeaderList>() };
|
||||
return vm.heap().allocate_without_realm<HeaderList>();
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#header-list-contains
|
||||
|
|
|
@ -28,7 +28,7 @@ void Request::visit_edges(JS::Cell::Visitor& visitor)
|
|||
|
||||
JS::NonnullGCPtr<Request> Request::create(JS::VM& vm)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<Request>(HeaderList::create(vm)) };
|
||||
return vm.heap().allocate_without_realm<Request>(HeaderList::create(vm));
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-request-url
|
||||
|
|
|
@ -29,7 +29,7 @@ void Response::visit_edges(JS::Cell::Visitor& visitor)
|
|||
|
||||
JS::NonnullGCPtr<Response> Response::create(JS::VM& vm)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<Response>(HeaderList::create(vm)) };
|
||||
return vm.heap().allocate_without_realm<Response>(HeaderList::create(vm));
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#ref-for-concept-network-error%E2%91%A3
|
||||
|
@ -193,7 +193,7 @@ ErrorOr<JS::NonnullGCPtr<BasicFilteredResponse>> BasicFilteredResponse::create(J
|
|||
TRY(header_list->append(header));
|
||||
}
|
||||
|
||||
return { *vm.heap().allocate_without_realm<BasicFilteredResponse>(internal_response, header_list) };
|
||||
return vm.heap().allocate_without_realm<BasicFilteredResponse>(internal_response, header_list);
|
||||
}
|
||||
|
||||
BasicFilteredResponse::BasicFilteredResponse(JS::NonnullGCPtr<Response> internal_response, JS::NonnullGCPtr<HeaderList> header_list)
|
||||
|
@ -223,7 +223,7 @@ ErrorOr<JS::NonnullGCPtr<CORSFilteredResponse>> CORSFilteredResponse::create(JS:
|
|||
TRY(header_list->append(header));
|
||||
}
|
||||
|
||||
return { *vm.heap().allocate_without_realm<CORSFilteredResponse>(internal_response, header_list) };
|
||||
return vm.heap().allocate_without_realm<CORSFilteredResponse>(internal_response, header_list);
|
||||
}
|
||||
|
||||
CORSFilteredResponse::CORSFilteredResponse(JS::NonnullGCPtr<Response> internal_response, JS::NonnullGCPtr<HeaderList> header_list)
|
||||
|
@ -242,7 +242,7 @@ JS::NonnullGCPtr<OpaqueFilteredResponse> OpaqueFilteredResponse::create(JS::VM&
|
|||
{
|
||||
// An opaque filtered response is a filtered response whose type is "opaque", URL list is the empty list,
|
||||
// status is 0, status message is the empty byte sequence, header list is empty, and body is null.
|
||||
return { *vm.heap().allocate_without_realm<OpaqueFilteredResponse>(internal_response, HeaderList::create(vm)) };
|
||||
return vm.heap().allocate_without_realm<OpaqueFilteredResponse>(internal_response, HeaderList::create(vm));
|
||||
}
|
||||
|
||||
OpaqueFilteredResponse::OpaqueFilteredResponse(JS::NonnullGCPtr<Response> internal_response, JS::NonnullGCPtr<HeaderList> header_list)
|
||||
|
@ -261,7 +261,7 @@ JS::NonnullGCPtr<OpaqueRedirectFilteredResponse> OpaqueRedirectFilteredResponse:
|
|||
{
|
||||
// An opaque-redirect filtered response is a filtered response whose type is "opaqueredirect",
|
||||
// status is 0, status message is the empty byte sequence, header list is empty, and body is null.
|
||||
return { *vm.heap().allocate_without_realm<OpaqueRedirectFilteredResponse>(internal_response, HeaderList::create(vm)) };
|
||||
return vm.heap().allocate_without_realm<OpaqueRedirectFilteredResponse>(internal_response, HeaderList::create(vm));
|
||||
}
|
||||
|
||||
OpaqueRedirectFilteredResponse::OpaqueRedirectFilteredResponse(JS::NonnullGCPtr<Response> internal_response, JS::NonnullGCPtr<HeaderList> header_list)
|
||||
|
|
|
@ -77,7 +77,7 @@ JS::NonnullGCPtr<Request> Request::create(JS::Realm& realm, JS::NonnullGCPtr<Inf
|
|||
{
|
||||
// 1. Let requestObject be a new Request object with realm.
|
||||
// 2. Set requestObject’s request to request.
|
||||
auto* request_object = realm.heap().allocate<Request>(realm, realm, request);
|
||||
auto request_object = realm.heap().allocate<Request>(realm, realm, request);
|
||||
|
||||
// 3. Set requestObject’s headers to a new Headers object with realm, whose headers list is request’s headers list and guard is guard.
|
||||
request_object->m_headers = realm.heap().allocate<Headers>(realm, realm, request->header_list());
|
||||
|
@ -87,7 +87,7 @@ JS::NonnullGCPtr<Request> Request::create(JS::Realm& realm, JS::NonnullGCPtr<Inf
|
|||
request_object->m_signal = realm.heap().allocate<DOM::AbortSignal>(realm, realm);
|
||||
|
||||
// 5. Return requestObject.
|
||||
return JS::NonnullGCPtr { *request_object };
|
||||
return request_object;
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#dom-request
|
||||
|
@ -96,7 +96,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
|
|||
auto& vm = realm.vm();
|
||||
|
||||
// Referred to as 'this' in the spec.
|
||||
auto request_object = JS::NonnullGCPtr { *realm.heap().allocate<Request>(realm, realm, Infrastructure::Request::create(vm)) };
|
||||
auto request_object = realm.heap().allocate<Request>(realm, realm, Infrastructure::Request::create(vm));
|
||||
|
||||
// 1. Let request be null.
|
||||
JS::GCPtr<Infrastructure::Request> input_request;
|
||||
|
|
|
@ -69,14 +69,14 @@ JS::NonnullGCPtr<Response> Response::create(JS::Realm& realm, JS::NonnullGCPtr<I
|
|||
{
|
||||
// 1. Let responseObject be a new Response object with realm.
|
||||
// 2. Set responseObject’s response to response.
|
||||
auto* response_object = realm.heap().allocate<Response>(realm, realm, response);
|
||||
auto response_object = realm.heap().allocate<Response>(realm, realm, response);
|
||||
|
||||
// 3. Set responseObject’s headers to a new Headers object with realm, whose headers list is response’s headers list and guard is guard.
|
||||
response_object->m_headers = realm.heap().allocate<Headers>(realm, realm, response->header_list());
|
||||
response_object->m_headers->set_guard(guard);
|
||||
|
||||
// 4. Return responseObject.
|
||||
return JS::NonnullGCPtr { *response_object };
|
||||
return response_object;
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#initialize-a-response
|
||||
|
@ -126,7 +126,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> Response::construct_impl(JS::Rea
|
|||
auto& vm = realm.vm();
|
||||
|
||||
// Referred to as 'this' in the spec.
|
||||
auto response_object = JS::NonnullGCPtr { *realm.heap().allocate<Response>(realm, realm, Infrastructure::Response::create(vm)) };
|
||||
auto response_object = realm.heap().allocate<Response>(realm, realm, Infrastructure::Response::create(vm));
|
||||
|
||||
// 1. Set this’s response to a new response.
|
||||
// NOTE: This is done at the beginning as the 'this' value Response object
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Web::FileAPI {
|
|||
|
||||
JS::NonnullGCPtr<Blob> Blob::create(JS::Realm& realm, ByteBuffer byte_buffer, DeprecatedString type)
|
||||
{
|
||||
return JS::NonnullGCPtr(*realm.heap().allocate<Blob>(realm, realm, move(byte_buffer), move(type)));
|
||||
return realm.heap().allocate<Blob>(realm, realm, move(byte_buffer), move(type));
|
||||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#convert-line-endings-to-native
|
||||
|
@ -139,7 +139,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::create(JS::Realm& realm, Optio
|
|||
{
|
||||
// 1. If invoked with zero parameters, return a new Blob object consisting of 0 bytes, with size set to 0, and with type set to the empty string.
|
||||
if (!blob_parts.has_value() && !options.has_value())
|
||||
return JS::NonnullGCPtr(*realm.heap().allocate<Blob>(realm, realm));
|
||||
return realm.heap().allocate<Blob>(realm, realm);
|
||||
|
||||
ByteBuffer byte_buffer {};
|
||||
// 2. Let bytes be the result of processing blob parts given blobParts and options.
|
||||
|
@ -164,7 +164,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::create(JS::Realm& realm, Optio
|
|||
}
|
||||
|
||||
// 4. Return a Blob object referring to bytes as its associated byte sequence, with its size set to the length of bytes, and its type set to the value of t from the substeps above.
|
||||
return JS::NonnullGCPtr(*realm.heap().allocate<Blob>(realm, realm, move(byte_buffer), move(type)));
|
||||
return realm.heap().allocate<Blob>(realm, realm, move(byte_buffer), move(type));
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::construct_impl(JS::Realm& realm, Optional<Vector<BlobPart>> const& blob_parts, Optional<BlobPropertyBag> const& options)
|
||||
|
@ -233,7 +233,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::slice(Optional<i64> start, Opt
|
|||
// b. S.size = span.
|
||||
// c. S.type = relativeContentType.
|
||||
auto byte_buffer = TRY_OR_RETURN_OOM(realm(), m_byte_buffer.slice(relative_start, span));
|
||||
return JS::NonnullGCPtr(*heap().allocate<Blob>(realm(), realm(), move(byte_buffer), move(relative_content_type)));
|
||||
return heap().allocate<Blob>(realm(), realm(), move(byte_buffer), move(relative_content_type));
|
||||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#dom-blob-text
|
||||
|
|
|
@ -58,7 +58,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> File::create(JS::Realm& realm, Vecto
|
|||
// 4. F.name is set to n.
|
||||
// 5. F.type is set to t.
|
||||
// 6. F.lastModified is set to d.
|
||||
return JS::NonnullGCPtr(*realm.heap().allocate<File>(realm, realm, move(bytes), move(name), move(type), last_modified));
|
||||
return realm.heap().allocate<File>(realm, realm, move(bytes), move(name), move(type), last_modified);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> File::construct_impl(JS::Realm& realm, Vector<BlobPart> const& file_bits, DeprecatedString const& file_name, Optional<FilePropertyBag> const& options)
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::FileAPI {
|
|||
|
||||
JS::NonnullGCPtr<FileList> FileList::create(JS::Realm& realm, Vector<JS::NonnullGCPtr<File>>&& files)
|
||||
{
|
||||
return *realm.heap().allocate<FileList>(realm, realm, move(files));
|
||||
return realm.heap().allocate<FileList>(realm, realm, move(files));
|
||||
}
|
||||
|
||||
FileList::FileList(JS::Realm& realm, Vector<JS::NonnullGCPtr<File>>&& files)
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::Geometry {
|
|||
|
||||
JS::NonnullGCPtr<DOMPoint> DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
|
||||
{
|
||||
return *realm.heap().allocate<DOMPoint>(realm, realm, x, y, z, w);
|
||||
return realm.heap().allocate<DOMPoint>(realm, realm, x, y, z, w);
|
||||
}
|
||||
|
||||
DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w)
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::Geometry {
|
|||
|
||||
JS::NonnullGCPtr<DOMPointReadOnly> DOMPointReadOnly::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
|
||||
{
|
||||
return *realm.heap().allocate<DOMPointReadOnly>(realm, realm, x, y, z, w);
|
||||
return realm.heap().allocate<DOMPointReadOnly>(realm, realm, x, y, z, w);
|
||||
}
|
||||
|
||||
DOMPointReadOnly::DOMPointReadOnly(JS::Realm& realm, double x, double y, double z, double w)
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Web::Geometry {
|
|||
|
||||
JS::NonnullGCPtr<DOMRect> DOMRect::construct_impl(JS::Realm& realm, double x, double y, double width, double height)
|
||||
{
|
||||
return *realm.heap().allocate<DOMRect>(realm, realm, x, y, width, height);
|
||||
return realm.heap().allocate<DOMRect>(realm, realm, x, y, width, height);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<DOMRect> DOMRect::create(JS::Realm& realm, Gfx::FloatRect const& rect)
|
||||
|
|
|
@ -16,7 +16,7 @@ JS::NonnullGCPtr<DOMRectList> DOMRectList::create(JS::Realm& realm, Vector<JS::H
|
|||
Vector<JS::NonnullGCPtr<DOMRect>> rects;
|
||||
for (auto& rect : rect_handles)
|
||||
rects.append(*rect);
|
||||
return *realm.heap().allocate<DOMRectList>(realm, realm, move(rects));
|
||||
return realm.heap().allocate<DOMRectList>(realm, realm, move(rects));
|
||||
}
|
||||
|
||||
DOMRectList::DOMRectList(JS::Realm& realm, Vector<JS::NonnullGCPtr<DOMRect>> rects)
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Web::Geometry {
|
|||
|
||||
JS::NonnullGCPtr<DOMRectReadOnly> DOMRectReadOnly::construct_impl(JS::Realm& realm, double x, double y, double width, double height)
|
||||
{
|
||||
return *realm.heap().allocate<DOMRectReadOnly>(realm, realm, x, y, width, height);
|
||||
return realm.heap().allocate<DOMRectReadOnly>(realm, realm, x, y, width, height);
|
||||
}
|
||||
|
||||
DOMRectReadOnly::DOMRectReadOnly(JS::Realm& realm, double x, double y, double width, double height)
|
||||
|
|
|
@ -19,7 +19,7 @@ JS::NonnullGCPtr<CanvasGradient> CanvasGradient::create_radial(JS::Realm& realm,
|
|||
(void)x1;
|
||||
(void)y1;
|
||||
(void)r1;
|
||||
return *realm.heap().allocate<CanvasGradient>(realm, realm, Type::Radial);
|
||||
return realm.heap().allocate<CanvasGradient>(realm, realm, Type::Radial);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<CanvasGradient> CanvasGradient::create_linear(JS::Realm& realm, double x0, double y0, double x1, double y1)
|
||||
|
@ -28,7 +28,7 @@ JS::NonnullGCPtr<CanvasGradient> CanvasGradient::create_linear(JS::Realm& realm,
|
|||
(void)y0;
|
||||
(void)x1;
|
||||
(void)y1;
|
||||
return *realm.heap().allocate<CanvasGradient>(realm, realm, Type::Linear);
|
||||
return realm.heap().allocate<CanvasGradient>(realm, realm, Type::Linear);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<CanvasGradient> CanvasGradient::create_conic(JS::Realm& realm, double start_angle, double x, double y)
|
||||
|
@ -36,7 +36,7 @@ JS::NonnullGCPtr<CanvasGradient> CanvasGradient::create_conic(JS::Realm& realm,
|
|||
(void)start_angle;
|
||||
(void)x;
|
||||
(void)y;
|
||||
return *realm.heap().allocate<CanvasGradient>(realm, realm, Type::Conic);
|
||||
return realm.heap().allocate<CanvasGradient>(realm, realm, Type::Conic);
|
||||
}
|
||||
|
||||
CanvasGradient::CanvasGradient(JS::Realm& realm, Type type)
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Web::HTML {
|
|||
|
||||
JS::NonnullGCPtr<CanvasRenderingContext2D> CanvasRenderingContext2D::create(JS::Realm& realm, HTMLCanvasElement& element)
|
||||
{
|
||||
return *realm.heap().allocate<CanvasRenderingContext2D>(realm, realm, element);
|
||||
return realm.heap().allocate<CanvasRenderingContext2D>(realm, realm, element);
|
||||
}
|
||||
|
||||
CanvasRenderingContext2D::CanvasRenderingContext2D(JS::Realm& realm, HTMLCanvasElement& element)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Web::HTML {
|
|||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMParser>> DOMParser::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
return JS::NonnullGCPtr(*realm.heap().allocate<DOMParser>(realm, realm));
|
||||
return realm.heap().allocate<DOMParser>(realm, realm);
|
||||
}
|
||||
|
||||
DOMParser::DOMParser(JS::Realm& realm)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Web::HTML {
|
|||
JS::NonnullGCPtr<DOMStringMap> DOMStringMap::create(DOM::Element& element)
|
||||
{
|
||||
auto& realm = element.realm();
|
||||
return *realm.heap().allocate<DOMStringMap>(realm, element);
|
||||
return realm.heap().allocate<DOMStringMap>(realm, element);
|
||||
}
|
||||
|
||||
DOMStringMap::DOMStringMap(DOM::Element& element)
|
||||
|
|
|
@ -376,7 +376,7 @@ void HTMLInputElement::create_shadow_tree_if_needed()
|
|||
break;
|
||||
}
|
||||
|
||||
auto* shadow_root = heap().allocate<DOM::ShadowRoot>(realm(), document(), *this);
|
||||
auto shadow_root = heap().allocate<DOM::ShadowRoot>(realm(), document(), *this);
|
||||
auto initial_value = m_value;
|
||||
if (initial_value.is_null())
|
||||
initial_value = DeprecatedString::empty();
|
||||
|
@ -390,8 +390,8 @@ void HTMLInputElement::create_shadow_tree_if_needed()
|
|||
m_text_node->set_is_password_input({}, true);
|
||||
|
||||
MUST(element->append_child(*m_text_node));
|
||||
MUST(shadow_root->append_child(move(element)));
|
||||
set_shadow_root(move(shadow_root));
|
||||
MUST(shadow_root->append_child(element));
|
||||
set_shadow_root(shadow_root);
|
||||
}
|
||||
|
||||
void HTMLInputElement::did_receive_focus()
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Web::HTML {
|
|||
|
||||
JS::NonnullGCPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter)
|
||||
{
|
||||
return *root.heap().allocate<HTMLOptionsCollection>(root.realm(), root, move(filter));
|
||||
return root.heap().allocate<HTMLOptionsCollection>(root.realm(), root, move(filter));
|
||||
}
|
||||
|
||||
HTMLOptionsCollection::HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter)
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::HTML {
|
|||
|
||||
JS::NonnullGCPtr<History> History::create(JS::Realm& realm, DOM::Document& document)
|
||||
{
|
||||
return *realm.heap().allocate<History>(realm, realm, document);
|
||||
return realm.heap().allocate<History>(realm, realm, document);
|
||||
}
|
||||
|
||||
History::History(JS::Realm& realm, DOM::Document& document)
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::HTML {
|
|||
|
||||
JS::NonnullGCPtr<MessageChannel> MessageChannel::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
return *realm.heap().allocate<MessageChannel>(realm, realm);
|
||||
return realm.heap().allocate<MessageChannel>(realm, realm);
|
||||
}
|
||||
|
||||
MessageChannel::MessageChannel(JS::Realm& realm)
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Web::HTML {
|
|||
|
||||
JS::NonnullGCPtr<MessagePort> MessagePort::create(JS::Realm& realm)
|
||||
{
|
||||
return *realm.heap().allocate<MessagePort>(realm, realm);
|
||||
return realm.heap().allocate<MessagePort>(realm, realm);
|
||||
}
|
||||
|
||||
MessagePort::MessagePort(JS::Realm& realm)
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Web::HTML {
|
|||
|
||||
JS::NonnullGCPtr<Navigator> Navigator::create(JS::Realm& realm)
|
||||
{
|
||||
return *realm.heap().allocate<Navigator>(realm, realm);
|
||||
return realm.heap().allocate<Navigator>(realm, realm);
|
||||
}
|
||||
|
||||
Navigator::Navigator(JS::Realm& realm)
|
||||
|
|
|
@ -759,7 +759,7 @@ AnythingElse:
|
|||
void HTMLParser::insert_comment(HTMLToken& token)
|
||||
{
|
||||
auto adjusted_insertion_location = find_appropriate_place_for_inserting_node();
|
||||
adjusted_insertion_location.parent->insert_before(*realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment()), adjusted_insertion_location.insert_before_sibling);
|
||||
adjusted_insertion_location.parent->insert_before(realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment()), adjusted_insertion_location.insert_before_sibling);
|
||||
}
|
||||
|
||||
void HTMLParser::handle_in_head(HTMLToken& token)
|
||||
|
@ -1071,7 +1071,7 @@ void HTMLParser::handle_after_body(HTMLToken& token)
|
|||
|
||||
if (token.is_comment()) {
|
||||
auto& insertion_location = m_stack_of_open_elements.first();
|
||||
MUST(insertion_location.append_child(*realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment())));
|
||||
MUST(insertion_location.append_child(realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment())));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3181,8 +3181,8 @@ void HTMLParser::handle_after_frameset(HTMLToken& token)
|
|||
void HTMLParser::handle_after_after_frameset(HTMLToken& token)
|
||||
{
|
||||
if (token.is_comment()) {
|
||||
auto* comment = document().heap().allocate<DOM::Comment>(document().realm(), document(), token.comment());
|
||||
MUST(document().append_child(*comment));
|
||||
auto comment = document().heap().allocate<DOM::Comment>(document().realm(), document(), token.comment());
|
||||
MUST(document().append_child(comment));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3540,21 +3540,21 @@ Vector<JS::Handle<DOM::Node>> HTMLParser::parse_html_fragment(DOM::Element& cont
|
|||
|
||||
JS::NonnullGCPtr<HTMLParser> HTMLParser::create_for_scripting(DOM::Document& document)
|
||||
{
|
||||
return *document.heap().allocate_without_realm<HTMLParser>(document);
|
||||
return document.heap().allocate_without_realm<HTMLParser>(document);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<HTMLParser> HTMLParser::create_with_uncertain_encoding(DOM::Document& document, ByteBuffer const& input)
|
||||
{
|
||||
if (document.has_encoding())
|
||||
return *document.heap().allocate_without_realm<HTMLParser>(document, input, document.encoding().value());
|
||||
return document.heap().allocate_without_realm<HTMLParser>(document, input, document.encoding().value());
|
||||
auto encoding = run_encoding_sniffing_algorithm(document, input);
|
||||
dbgln_if(HTML_PARSER_DEBUG, "The encoding sniffing algorithm returned encoding '{}'", encoding);
|
||||
return *document.heap().allocate_without_realm<HTMLParser>(document, input, encoding);
|
||||
return document.heap().allocate_without_realm<HTMLParser>(document, input, encoding);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<HTMLParser> HTMLParser::create(DOM::Document& document, StringView input, DeprecatedString const& encoding)
|
||||
{
|
||||
return *document.heap().allocate_without_realm<HTMLParser>(document, input, encoding);
|
||||
return document.heap().allocate_without_realm<HTMLParser>(document, input, encoding);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#html-fragment-serialisation-algorithm
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Web::HTML {
|
|||
|
||||
JS::NonnullGCPtr<Path2D> Path2D::construct_impl(JS::Realm& realm, Optional<Variant<JS::Handle<Path2D>, DeprecatedString>> const& path)
|
||||
{
|
||||
return *realm.heap().allocate<Path2D>(realm, realm, path);
|
||||
return realm.heap().allocate<Path2D>(realm, realm, path);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/canvas.html#dom-path2d
|
||||
|
|
|
@ -60,14 +60,14 @@ JS::NonnullGCPtr<ClassicScript> ClassicScript::create(DeprecatedString filename,
|
|||
script->m_error_to_rethrow = parse_error;
|
||||
|
||||
// 2. Return script.
|
||||
return JS::NonnullGCPtr(*script);
|
||||
return script;
|
||||
}
|
||||
|
||||
// 12. Set script's record to result.
|
||||
script->m_script_record = *result.release_value();
|
||||
|
||||
// 13. Return script.
|
||||
return JS::NonnullGCPtr(*script);
|
||||
return script;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#run-a-classic-script
|
||||
|
|
|
@ -38,7 +38,7 @@ JS::GCPtr<JavaScriptModuleScript> JavaScriptModuleScript::create(DeprecatedStrin
|
|||
auto& realm = settings_object.realm();
|
||||
|
||||
// 2. Let script be a new module script that this algorithm will subsequently initialize.
|
||||
auto* script = realm.heap().allocate<JavaScriptModuleScript>(realm, move(base_url), filename, settings_object);
|
||||
auto script = realm.heap().allocate<JavaScriptModuleScript>(realm, move(base_url), filename, settings_object);
|
||||
|
||||
// 3. Set script's settings object to settings.
|
||||
// NOTE: This was already done when constructing.
|
||||
|
|
|
@ -38,7 +38,7 @@ void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, Nonnull
|
|||
|
||||
// 3. Let settings object be a new environment settings object whose algorithms are defined as follows:
|
||||
// NOTE: See the functions defined for this class.
|
||||
auto* settings_object = realm->heap().allocate<WindowEnvironmentSettingsObject>(*realm, window, move(execution_context));
|
||||
auto settings_object = realm->heap().allocate<WindowEnvironmentSettingsObject>(*realm, window, move(execution_context));
|
||||
|
||||
// 4. If reservedEnvironment is non-null, then:
|
||||
if (reserved_environment.has_value()) {
|
||||
|
@ -71,8 +71,8 @@ void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, Nonnull
|
|||
|
||||
// 7. Set realm's [[HostDefined]] field to settings object.
|
||||
// Non-Standard: We store the ESO next to the web intrinsics in a custom HostDefined object
|
||||
auto* intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm);
|
||||
auto host_defined = make<Bindings::HostDefined>(*settings_object, *intrinsics);
|
||||
auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm);
|
||||
auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics);
|
||||
realm->set_host_defined(move(host_defined));
|
||||
|
||||
// Non-Standard: We cannot fully initialize window object until *after* the we set up
|
||||
|
|
|
@ -30,14 +30,14 @@ public:
|
|||
auto settings_object = realm->heap().allocate<WorkerEnvironmentSettingsObject>(*realm, move(execution_context));
|
||||
settings_object->target_browsing_context = nullptr;
|
||||
|
||||
auto* intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm);
|
||||
auto host_defined = make<Bindings::HostDefined>(*settings_object, *intrinsics);
|
||||
auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm);
|
||||
auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics);
|
||||
realm->set_host_defined(move(host_defined));
|
||||
|
||||
// FIXME: Shared workers should use the shared worker method
|
||||
Bindings::add_dedicated_worker_exposed_interfaces(realm->global_object(), *realm);
|
||||
|
||||
return *settings_object;
|
||||
return settings_object;
|
||||
}
|
||||
|
||||
virtual ~WorkerEnvironmentSettingsObject() override = default;
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::HTML {
|
|||
|
||||
JS::NonnullGCPtr<Storage> Storage::create(JS::Realm& realm)
|
||||
{
|
||||
return *realm.heap().allocate<Storage>(realm, realm);
|
||||
return realm.heap().allocate<Storage>(realm, realm);
|
||||
}
|
||||
|
||||
Storage::Storage(JS::Realm& realm)
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Web::HTML {
|
|||
|
||||
JS::NonnullGCPtr<TextMetrics> TextMetrics::create(JS::Realm& realm)
|
||||
{
|
||||
return *realm.heap().allocate<TextMetrics>(realm, realm);
|
||||
return realm.heap().allocate<TextMetrics>(realm, realm);
|
||||
}
|
||||
|
||||
TextMetrics::TextMetrics(JS::Realm& realm)
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::HTML {
|
|||
|
||||
JS::NonnullGCPtr<Timer> Timer::create(Window& window, i32 milliseconds, Function<void()> callback, i32 id)
|
||||
{
|
||||
return *window.heap().allocate_without_realm<Timer>(window, milliseconds, move(callback), id);
|
||||
return window.heap().allocate_without_realm<Timer>(window, milliseconds, move(callback), id);
|
||||
}
|
||||
|
||||
Timer::Timer(Window& window, i32 milliseconds, Function<void()> callback, i32 id)
|
||||
|
|
|
@ -86,7 +86,7 @@ private:
|
|||
|
||||
JS::NonnullGCPtr<Window> Window::create(JS::Realm& realm)
|
||||
{
|
||||
return *realm.heap().allocate<Window>(realm, realm);
|
||||
return realm.heap().allocate<Window>(realm, realm);
|
||||
}
|
||||
|
||||
Window::Window(JS::Realm& realm)
|
||||
|
@ -1340,7 +1340,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::request_animation_frame)
|
|||
auto* callback_object = TRY(vm.argument(0).to_object(vm));
|
||||
if (!callback_object->is_function())
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAFunctionNoParam);
|
||||
auto* callback = vm.heap().allocate_without_realm<WebIDL::CallbackType>(*callback_object, HTML::incumbent_settings_object());
|
||||
auto callback = vm.heap().allocate_without_realm<WebIDL::CallbackType>(*callback_object, HTML::incumbent_settings_object());
|
||||
return JS::Value(impl->request_animation_frame_impl(*callback));
|
||||
}
|
||||
|
||||
|
@ -1363,7 +1363,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::queue_microtask)
|
|||
if (!callback_object->is_function())
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAFunctionNoParam);
|
||||
|
||||
auto* callback = vm.heap().allocate_without_realm<WebIDL::CallbackType>(*callback_object, HTML::incumbent_settings_object());
|
||||
auto callback = vm.heap().allocate_without_realm<WebIDL::CallbackType>(*callback_object, HTML::incumbent_settings_object());
|
||||
|
||||
impl->queue_microtask_impl(*callback);
|
||||
return JS::js_undefined();
|
||||
|
@ -1379,7 +1379,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::request_idle_callback)
|
|||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAFunctionNoParam);
|
||||
// FIXME: accept options object
|
||||
|
||||
auto* callback = vm.heap().allocate_without_realm<WebIDL::CallbackType>(*callback_object, HTML::incumbent_settings_object());
|
||||
auto callback = vm.heap().allocate_without_realm<WebIDL::CallbackType>(*callback_object, HTML::incumbent_settings_object());
|
||||
|
||||
return JS::Value(impl->request_idle_callback_impl(*callback));
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> Worker::create(FlyString const& sc
|
|||
worker->run_a_worker(url, outside_settings, *outside_port, options);
|
||||
|
||||
// 10. Return worker
|
||||
return JS::NonnullGCPtr(*worker);
|
||||
return worker;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/workers.html#run-a-worker
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::HTML {
|
|||
|
||||
JS::NonnullGCPtr<WorkerNavigator> WorkerNavigator::create(WorkerGlobalScope& global_scope)
|
||||
{
|
||||
return *global_scope.heap().allocate<WorkerNavigator>(global_scope.realm(), global_scope);
|
||||
return global_scope.heap().allocate<WorkerNavigator>(global_scope.realm(), global_scope);
|
||||
}
|
||||
|
||||
WorkerNavigator::WorkerNavigator(WorkerGlobalScope& global_scope)
|
||||
|
|
|
@ -17,7 +17,7 @@ JS::NonnullGCPtr<IntersectionObserver> IntersectionObserver::construct_impl(JS::
|
|||
(void)callback;
|
||||
(void)options;
|
||||
|
||||
return *realm.heap().allocate<IntersectionObserver>(realm, realm);
|
||||
return realm.heap().allocate<IntersectionObserver>(realm, realm);
|
||||
}
|
||||
|
||||
IntersectionObserver::IntersectionObserver(JS::Realm& realm)
|
||||
|
|
|
@ -170,7 +170,7 @@ ErrorOr<void> TreeBuilder::create_pseudo_element_if_needed(DOM::Element& element
|
|||
pseudo_element_node->set_generated(true);
|
||||
// FIXME: Handle images, and multiple values
|
||||
if (pseudo_element_content.type == CSS::ContentData::Type::String) {
|
||||
auto* text = document.heap().allocate<DOM::Text>(document.realm(), document, pseudo_element_content.data);
|
||||
auto text = document.heap().allocate<DOM::Text>(document.realm(), document, pseudo_element_content.data);
|
||||
auto text_node = document.heap().allocate_without_realm<Layout::TextNode>(document, *text);
|
||||
text_node->set_generated(true);
|
||||
push_parent(verify_cast<NodeWithStyle>(*pseudo_element_node));
|
||||
|
@ -301,8 +301,8 @@ ErrorOr<void> TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::
|
|||
auto placeholder_style = TRY(style_computer.compute_style(input_element, CSS::Selector::PseudoElement::Placeholder));
|
||||
auto placeholder = DOM::Element::create_layout_node_for_display_type(document, placeholder_style->display(), placeholder_style, nullptr);
|
||||
|
||||
auto* text = document.heap().allocate<DOM::Text>(document.realm(), document, *placeholder_value);
|
||||
auto* text_node = document.heap().allocate_without_realm<Layout::TextNode>(document, *text);
|
||||
auto text = document.heap().allocate<DOM::Text>(document.realm(), document, *placeholder_value);
|
||||
auto text_node = document.heap().allocate_without_realm<Layout::TextNode>(document, *text);
|
||||
text_node->set_generated(true);
|
||||
|
||||
push_parent(verify_cast<NodeWithStyle>(*layout_node));
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Web::RequestIdleCallback {
|
|||
|
||||
JS::NonnullGCPtr<IdleDeadline> IdleDeadline::create(JS::Realm& realm, bool did_timeout)
|
||||
{
|
||||
return *realm.heap().allocate<IdleDeadline>(realm, realm, did_timeout);
|
||||
return realm.heap().allocate<IdleDeadline>(realm, realm, did_timeout);
|
||||
}
|
||||
|
||||
IdleDeadline::IdleDeadline(JS::Realm& realm, bool did_timeout)
|
||||
|
|
|
@ -15,7 +15,7 @@ JS::NonnullGCPtr<ResizeObserver> ResizeObserver::construct_impl(JS::Realm& realm
|
|||
{
|
||||
// FIXME: Implement
|
||||
(void)callback;
|
||||
return *realm.heap().allocate<ResizeObserver>(realm, realm);
|
||||
return realm.heap().allocate<ResizeObserver>(realm, realm);
|
||||
}
|
||||
|
||||
ResizeObserver::ResizeObserver(JS::Realm& realm)
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Web::SVG {
|
|||
|
||||
JS::NonnullGCPtr<SVGAnimatedLength> SVGAnimatedLength::create(JS::Realm& realm, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val)
|
||||
{
|
||||
return *realm.heap().allocate<SVGAnimatedLength>(realm, realm, move(base_val), move(anim_val));
|
||||
return realm.heap().allocate<SVGAnimatedLength>(realm, realm, move(base_val), move(anim_val));
|
||||
}
|
||||
|
||||
SVGAnimatedLength::SVGAnimatedLength(JS::Realm& realm, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val)
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Web::SVG {
|
|||
|
||||
JS::NonnullGCPtr<SVGLength> SVGLength::create(JS::Realm& realm, u8 unit_type, float value)
|
||||
{
|
||||
return *realm.heap().allocate<SVGLength>(realm, realm, unit_type, value);
|
||||
return realm.heap().allocate<SVGLength>(realm, realm, unit_type, value);
|
||||
}
|
||||
|
||||
SVGLength::SVGLength(JS::Realm& realm, u8 unit_type, float value)
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::Selection {
|
|||
|
||||
JS::NonnullGCPtr<Selection> Selection::create(JS::NonnullGCPtr<JS::Realm> realm, JS::NonnullGCPtr<DOM::Document> document)
|
||||
{
|
||||
return *realm->heap().allocate<Selection>(realm, realm, document);
|
||||
return realm->heap().allocate<Selection>(realm, realm, document);
|
||||
}
|
||||
|
||||
Selection::Selection(JS::NonnullGCPtr<JS::Realm> realm, JS::NonnullGCPtr<DOM::Document> document)
|
||||
|
|
|
@ -14,9 +14,7 @@ namespace Web::Streams {
|
|||
// https://streams.spec.whatwg.org/#rs-constructor
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStream>> ReadableStream::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
auto* readable_stream = realm.heap().allocate<ReadableStream>(realm, realm);
|
||||
|
||||
return JS::NonnullGCPtr { *readable_stream };
|
||||
return realm.heap().allocate<ReadableStream>(realm, realm);
|
||||
}
|
||||
|
||||
ReadableStream::ReadableStream(JS::Realm& realm)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Web::URL {
|
|||
|
||||
JS::NonnullGCPtr<URL> URL::create(JS::Realm& realm, AK::URL url, JS::NonnullGCPtr<URLSearchParams> query)
|
||||
{
|
||||
return *realm.heap().allocate<URL>(realm, realm, move(url), move(query));
|
||||
return realm.heap().allocate<URL>(realm, realm, move(url), move(query));
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<URL>> URL::construct_impl(JS::Realm& realm, DeprecatedString const& url, DeprecatedString const& base)
|
||||
|
|
|
@ -84,7 +84,7 @@ Vector<QueryParam> url_decode(StringView input)
|
|||
|
||||
JS::NonnullGCPtr<URLSearchParams> URLSearchParams::create(JS::Realm& realm, Vector<QueryParam> list)
|
||||
{
|
||||
return *realm.heap().allocate<URLSearchParams>(realm, realm, move(list));
|
||||
return realm.heap().allocate<URLSearchParams>(realm, realm, move(list));
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Web::URL {
|
|||
|
||||
JS::NonnullGCPtr<URLSearchParamsIterator> URLSearchParamsIterator::create(URLSearchParams const& url_search_params, JS::Object::PropertyKind iteration_kind)
|
||||
{
|
||||
return *url_search_params.heap().allocate<URLSearchParamsIterator>(url_search_params.realm(), url_search_params, iteration_kind);
|
||||
return url_search_params.heap().allocate<URLSearchParamsIterator>(url_search_params.realm(), url_search_params, iteration_kind);
|
||||
}
|
||||
|
||||
URLSearchParamsIterator::URLSearchParamsIterator(URLSearchParams const& url_search_params, JS::Object::PropertyKind iteration_kind)
|
||||
|
|
|
@ -36,7 +36,7 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyInstanceConstructor::construct(Fun
|
|||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "WebAssembly.Module");
|
||||
auto& module_object = static_cast<WebAssemblyModuleObject&>(*module_argument);
|
||||
auto result = TRY(WebAssemblyObject::instantiate_module(vm, module_object.module()));
|
||||
return heap().allocate<WebAssemblyInstanceObject>(realm, realm, result);
|
||||
return heap().allocate<WebAssemblyInstanceObject>(realm, realm, result).ptr();
|
||||
}
|
||||
|
||||
void WebAssemblyInstanceConstructor::initialize(JS::Realm& realm)
|
||||
|
|
|
@ -46,7 +46,7 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyMemoryConstructor::construct(Funct
|
|||
if (!address.has_value())
|
||||
return vm.throw_completion<JS::TypeError>("Wasm Memory allocation failed");
|
||||
|
||||
return vm.heap().allocate<WebAssemblyMemoryObject>(realm, realm, *address);
|
||||
return vm.heap().allocate<WebAssemblyMemoryObject>(realm, realm, *address).ptr();
|
||||
}
|
||||
|
||||
void WebAssemblyMemoryConstructor::initialize(JS::Realm& realm)
|
||||
|
|
|
@ -33,7 +33,7 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyModuleConstructor::construct(Funct
|
|||
auto* buffer_object = TRY(vm.argument(0).to_object(vm));
|
||||
auto result = TRY(parse_module(vm, buffer_object));
|
||||
|
||||
return heap().allocate<WebAssemblyModuleObject>(realm, realm, result);
|
||||
return heap().allocate<WebAssemblyModuleObject>(realm, realm, result).ptr();
|
||||
}
|
||||
|
||||
void WebAssemblyModuleConstructor::initialize(JS::Realm& realm)
|
||||
|
|
|
@ -77,7 +77,7 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyTableConstructor::construct(Functi
|
|||
for (auto& element : table.elements())
|
||||
element = reference;
|
||||
|
||||
return vm.heap().allocate<WebAssemblyTableObject>(realm, realm, *address);
|
||||
return vm.heap().allocate<WebAssemblyTableObject>(realm, realm, *address).ptr();
|
||||
}
|
||||
|
||||
void WebAssemblyTableConstructor::initialize(JS::Realm& realm)
|
||||
|
|
|
@ -11,12 +11,12 @@ namespace Web::WebIDL {
|
|||
|
||||
JS::NonnullGCPtr<DOMException> DOMException::create(JS::Realm& realm, FlyString const& name, FlyString const& message)
|
||||
{
|
||||
return *realm.heap().allocate<DOMException>(realm, realm, name, message);
|
||||
return realm.heap().allocate<DOMException>(realm, realm, name, message);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<DOMException> DOMException::construct_impl(JS::Realm& realm, FlyString const& message, FlyString const& name)
|
||||
{
|
||||
return *realm.heap().allocate<DOMException>(realm, realm, name, message);
|
||||
return realm.heap().allocate<DOMException>(realm, realm, name, message);
|
||||
}
|
||||
|
||||
DOMException::DOMException(JS::Realm& realm, FlyString const& name, FlyString const& message)
|
||||
|
|
|
@ -57,7 +57,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebSocket>> WebSocket::construct_impl(JS::R
|
|||
return WebIDL::SyntaxError::create(realm, "Presence of URL fragment is invalid");
|
||||
// 5. If `protocols` is a string, set `protocols` to a sequence consisting of just that string
|
||||
// 6. If any of the values in `protocols` occur more than once or otherwise fail to match the requirements, throw SyntaxError
|
||||
return JS::NonnullGCPtr(*realm.heap().allocate<WebSocket>(realm, window, url_record));
|
||||
return realm.heap().allocate<WebSocket>(realm, window, url_record);
|
||||
}
|
||||
|
||||
WebSocket::WebSocket(HTML::Window& window, AK::URL& url)
|
||||
|
|
|
@ -44,7 +44,7 @@ JS::NonnullGCPtr<XMLHttpRequest> XMLHttpRequest::construct_impl(JS::Realm& realm
|
|||
{
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
auto author_request_headers = Fetch::Infrastructure::HeaderList::create(realm.vm());
|
||||
return *realm.heap().allocate<XMLHttpRequest>(realm, window, *author_request_headers);
|
||||
return realm.heap().allocate<XMLHttpRequest>(realm, window, *author_request_headers);
|
||||
}
|
||||
|
||||
XMLHttpRequest::XMLHttpRequest(HTML::Window& window, Fetch::Infrastructure::HeaderList& author_request_headers)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue