mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:27:35 +00:00
LibJS: Make Heap::allocate<T>() infallible
Stop worrying about tiny OOMs. Work towards #20449. While going through these, I also changed the function signature in many places where returning ThrowCompletionOr<T> is no longer necessary.
This commit is contained in:
parent
980e7164fe
commit
72c9f56c66
337 changed files with 1229 additions and 1251 deletions
|
@ -13,7 +13,7 @@ namespace Web::DOM {
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AbortController>> AbortController::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
auto signal = TRY(AbortSignal::construct_impl(realm));
|
||||
return MUST_OR_THROW_OOM(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 {
|
|||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AbortSignal>> AbortSignal::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<AbortSignal>(realm, realm));
|
||||
return realm.heap().allocate<AbortSignal>(realm, realm);
|
||||
}
|
||||
|
||||
AbortSignal::AbortSignal(JS::Realm& realm)
|
||||
|
@ -60,7 +60,7 @@ void AbortSignal::signal_abort(JS::Value reason)
|
|||
m_abort_algorithms.clear();
|
||||
|
||||
// 5. Fire an event named abort at signal.
|
||||
dispatch_event(Event::create(realm(), HTML::EventNames::abort).release_value_but_fixme_should_propagate_errors());
|
||||
dispatch_event(Event::create(realm(), HTML::EventNames::abort));
|
||||
}
|
||||
|
||||
void AbortSignal::set_onabort(WebIDL::CallbackType* event_handler)
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AccessibilityTreeNode>> AccessibilityTreeNode::create(Document* document, DOM::Node const* value)
|
||||
JS::NonnullGCPtr<AccessibilityTreeNode> AccessibilityTreeNode::create(Document* document, DOM::Node const* value)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(document->heap().allocate<AccessibilityTreeNode>(document->realm(), value));
|
||||
return document->heap().allocate<AccessibilityTreeNode>(document->realm(), value);
|
||||
}
|
||||
|
||||
AccessibilityTreeNode::AccessibilityTreeNode(JS::GCPtr<DOM::Node const> value)
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Web::DOM {
|
|||
class AccessibilityTreeNode final : public JS::Cell {
|
||||
JS_CELL(AccessibilityTreeNode, JS::Cell)
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<AccessibilityTreeNode>> create(Document*, DOM::Node const*);
|
||||
static JS::NonnullGCPtr<AccessibilityTreeNode> create(Document*, DOM::Node const*);
|
||||
virtual ~AccessibilityTreeNode() override = default;
|
||||
|
||||
JS::GCPtr<DOM::Node const> value() const { return m_value; }
|
||||
|
|
|
@ -15,19 +15,19 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Attr>> Attr::create(Document& document, DeprecatedFlyString local_name, DeprecatedString value, Element* owner_element)
|
||||
JS::NonnullGCPtr<Attr> Attr::create(Document& document, DeprecatedFlyString local_name, DeprecatedString value, Element* owner_element)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(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);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Attr>> Attr::create(Document& document, QualifiedName qualified_name, DeprecatedString value, Element* owner_element)
|
||||
JS::NonnullGCPtr<Attr> Attr::create(Document& document, QualifiedName qualified_name, DeprecatedString value, Element* owner_element)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(document.heap().allocate<Attr>(document.realm(), document, move(qualified_name), move(value), owner_element));
|
||||
return document.heap().allocate<Attr>(document.realm(), document, move(qualified_name), move(value), owner_element);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Attr> Attr::clone(Document& document)
|
||||
{
|
||||
return *heap().allocate<Attr>(realm(), document, m_qualified_name, m_value, nullptr).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
return *heap().allocate<Attr>(realm(), document, m_qualified_name, m_value, nullptr);
|
||||
}
|
||||
|
||||
Attr::Attr(Document& document, QualifiedName qualified_name, DeprecatedString value, Element* owner_element)
|
||||
|
|
|
@ -18,8 +18,8 @@ class Attr final : public Node {
|
|||
WEB_PLATFORM_OBJECT(Attr, Node);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Attr>> create(Document&, QualifiedName, DeprecatedString value = "", Element* = nullptr);
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Attr>> create(Document&, DeprecatedFlyString local_name, DeprecatedString value = "", Element* = nullptr);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Attr> create(Document&, QualifiedName, DeprecatedString value = "", Element* = nullptr);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Attr> create(Document&, DeprecatedFlyString local_name, DeprecatedString value = "", Element* = nullptr);
|
||||
JS::NonnullGCPtr<Attr> clone(Document&);
|
||||
|
||||
virtual ~Attr() override = default;
|
||||
|
|
|
@ -20,7 +20,7 @@ Comment::Comment(Document& document, DeprecatedString const& data)
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Comment>> Comment::construct_impl(JS::Realm& realm, DeprecatedString const& data)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<Comment>(realm, window.associated_document(), data));
|
||||
return realm.heap().allocate<Comment>(realm, window.associated_document(), data);
|
||||
}
|
||||
|
||||
void Comment::initialize(JS::Realm& realm)
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> CustomEvent::create(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init)
|
||||
JS::NonnullGCPtr<CustomEvent> CustomEvent::create(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<CustomEvent>(realm, realm, event_name, event_init));
|
||||
return realm.heap().allocate<CustomEvent>(realm, realm, event_name, event_init);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> CustomEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init)
|
||||
|
|
|
@ -21,8 +21,8 @@ class CustomEvent : public Event {
|
|||
WEB_PLATFORM_OBJECT(CustomEvent, Event);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> create(JS::Realm&, FlyString const& event_name, CustomEventInit const& event_init = {});
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> construct_impl(JS::Realm&, FlyString const& event_name, CustomEventInit const& event_init);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CustomEvent> create(JS::Realm&, FlyString const& event_name, CustomEventInit const& = {});
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> construct_impl(JS::Realm&, FlyString const& event_name, CustomEventInit const&);
|
||||
|
||||
virtual ~CustomEvent() override;
|
||||
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMImplementation>> DOMImplementation::create(Document& document)
|
||||
JS::NonnullGCPtr<DOMImplementation> DOMImplementation::create(Document& document)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<DOMImplementation>(realm, document));
|
||||
return realm.heap().allocate<DOMImplementation>(realm, document);
|
||||
}
|
||||
|
||||
DOMImplementation::DOMImplementation(Document& document)
|
||||
|
@ -47,7 +47,7 @@ void DOMImplementation::visit_edges(Cell::Visitor& visitor)
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> DOMImplementation::create_document(DeprecatedString const& namespace_, DeprecatedString const& qualified_name, JS::GCPtr<DocumentType> doctype) const
|
||||
{
|
||||
// FIXME: This should specifically be an XML document.
|
||||
auto xml_document = TRY(Document::create(realm()));
|
||||
auto xml_document = Document::create(realm());
|
||||
|
||||
xml_document->set_ready_for_post_load_tasks(true);
|
||||
|
||||
|
@ -77,12 +77,12 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> DOMImplementation::create_docume
|
|||
// https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
||||
JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(DeprecatedString const& title) const
|
||||
{
|
||||
auto html_document = Document::create(realm()).release_value_but_fixme_should_propagate_errors();
|
||||
auto html_document = Document::create(realm());
|
||||
|
||||
html_document->set_content_type("text/html");
|
||||
html_document->set_ready_for_post_load_tasks(true);
|
||||
|
||||
auto doctype = heap().allocate<DocumentType>(realm(), html_document).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
auto doctype = heap().allocate<DocumentType>(realm(), html_document);
|
||||
doctype->set_name("html");
|
||||
MUST(html_document->append_child(*doctype));
|
||||
|
||||
|
@ -96,7 +96,7 @@ JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(DeprecatedStr
|
|||
auto title_element = create_element(html_document, HTML::TagNames::title, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||
MUST(head_element->append_child(title_element));
|
||||
|
||||
auto text_node = heap().allocate<Text>(realm(), html_document, title).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
auto text_node = heap().allocate<Text>(realm(), html_document, title);
|
||||
MUST(title_element->append_child(*text_node));
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(DeprecatedStr
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentType>> DOMImplementation::create_document_type(DeprecatedString const& qualified_name, DeprecatedString const& public_id, DeprecatedString const& system_id)
|
||||
{
|
||||
TRY(Document::validate_qualified_name(realm(), qualified_name));
|
||||
auto document_type = TRY(DocumentType::create(document()));
|
||||
auto document_type = DocumentType::create(document());
|
||||
document_type->set_name(qualified_name);
|
||||
document_type->set_public_id(public_id);
|
||||
document_type->set_system_id(system_id);
|
||||
|
|
|
@ -17,7 +17,7 @@ class DOMImplementation final : public Bindings::PlatformObject {
|
|||
WEB_PLATFORM_OBJECT(DOMImplementation, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMImplementation>> create(Document&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<DOMImplementation> create(Document&);
|
||||
virtual ~DOMImplementation();
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> create_document(DeprecatedString const&, DeprecatedString const&, JS::GCPtr<DocumentType>) const;
|
||||
|
|
|
@ -52,10 +52,10 @@ inline void replace_in_ordered_set(Vector<DeprecatedString>& set, StringView ite
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMTokenList>> DOMTokenList::create(Element& associated_element, DeprecatedFlyString associated_attribute)
|
||||
JS::NonnullGCPtr<DOMTokenList> DOMTokenList::create(Element& associated_element, DeprecatedFlyString associated_attribute)
|
||||
{
|
||||
auto& realm = associated_element.realm();
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<DOMTokenList>(realm, associated_element, move(associated_attribute)));
|
||||
return realm.heap().allocate<DOMTokenList>(realm, associated_element, move(associated_attribute));
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#ref-for-domtokenlist%E2%91%A0%E2%91%A2
|
||||
|
|
|
@ -24,7 +24,7 @@ class DOMTokenList final : public Bindings::LegacyPlatformObject {
|
|||
WEB_PLATFORM_OBJECT(DOMTokenList, Bindings::LegacyPlatformObject);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMTokenList>> create(Element& associated_element, DeprecatedFlyString associated_attribute);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<DOMTokenList> create(Element& associated_element, DeprecatedFlyString associated_attribute);
|
||||
~DOMTokenList() = default;
|
||||
|
||||
void associated_attribute_changed(StringView value);
|
||||
|
|
|
@ -200,7 +200,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> Document::create_and_initialize(
|
|||
Bindings::main_thread_vm(),
|
||||
[&](JS::Realm& realm) -> JS::Object* {
|
||||
// - For the global object, create a new Window object.
|
||||
window = HTML::Window::create(realm).release_value_but_fixme_should_propagate_errors();
|
||||
window = HTML::Window::create(realm);
|
||||
return window;
|
||||
},
|
||||
[&](JS::Realm&) -> JS::Object* {
|
||||
|
@ -232,12 +232,12 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> Document::create_and_initialize(
|
|||
|
||||
// FIXME: Why do we assume `creation_url` is non-empty here? Is this a spec bug?
|
||||
// FIXME: Why do we assume `top_level_creation_url` is non-empty here? Is this a spec bug?
|
||||
TRY(HTML::WindowEnvironmentSettingsObject::setup(
|
||||
HTML::WindowEnvironmentSettingsObject::setup(
|
||||
creation_url.value(),
|
||||
move(realm_execution_context),
|
||||
navigation_params.reserved_environment,
|
||||
top_level_creation_url.value(),
|
||||
top_level_origin));
|
||||
top_level_origin);
|
||||
}
|
||||
|
||||
// FIXME: 7. Let loadTimingInfo be a new document load timing info with its navigation start time set to response's timing info's start time.
|
||||
|
@ -252,7 +252,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> Document::create_and_initialize(
|
|||
// FIXME: and cross-origin opener policy is navigationParams's cross-origin opener policy,
|
||||
// FIXME: load timing info is loadTimingInfo,
|
||||
// and navigation id is navigationParams's id.
|
||||
auto document = TRY(HTML::HTMLDocument::create(window->realm()));
|
||||
auto document = HTML::HTMLDocument::create(window->realm());
|
||||
document->m_type = type;
|
||||
document->m_content_type = move(content_type);
|
||||
document->set_origin(navigation_params.origin);
|
||||
|
@ -310,9 +310,9 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> Document::construct_impl(JS::Rea
|
|||
return Document::create(realm);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> Document::create(JS::Realm& realm, AK::URL const& url)
|
||||
JS::NonnullGCPtr<Document> Document::create(JS::Realm& realm, AK::URL const& url)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<Document>(realm, realm, url));
|
||||
return realm.heap().allocate<Document>(realm, realm, url);
|
||||
}
|
||||
|
||||
Document::Document(JS::Realm& realm, const AK::URL& url)
|
||||
|
@ -341,7 +341,7 @@ void Document::initialize(JS::Realm& realm)
|
|||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::DocumentPrototype>(realm, "Document"));
|
||||
|
||||
m_selection = MUST(heap().allocate<Selection::Selection>(realm, realm, *this));
|
||||
m_selection = heap().allocate<Selection::Selection>(realm, realm, *this);
|
||||
|
||||
m_list_of_available_images = make<HTML::ListOfAvailableImages>();
|
||||
}
|
||||
|
@ -1162,7 +1162,7 @@ void Document::set_hovered_node(Node* node)
|
|||
// FIXME: Check if we need to dispatch these events in a specific order.
|
||||
for (auto target = old_hovered_node; target && target.ptr() != common_ancestor; target = target->parent()) {
|
||||
// FIXME: Populate the event with mouse coordinates, etc.
|
||||
target->dispatch_event(UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseleave).release_value_but_fixme_should_propagate_errors());
|
||||
target->dispatch_event(UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseleave));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1171,7 +1171,7 @@ void Document::set_hovered_node(Node* node)
|
|||
// FIXME: Check if we need to dispatch these events in a specific order.
|
||||
for (auto target = m_hovered_node; target && target.ptr() != common_ancestor; target = target->parent()) {
|
||||
// FIXME: Populate the event with mouse coordinates, etc.
|
||||
target->dispatch_event(UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseenter).release_value_but_fixme_should_propagate_errors());
|
||||
target->dispatch_event(UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseenter));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1180,7 +1180,7 @@ JS::NonnullGCPtr<HTMLCollection> Document::get_elements_by_name(DeprecatedString
|
|||
{
|
||||
return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [name](Element const& element) {
|
||||
return element.name() == name;
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<HTMLCollection> Document::get_elements_by_class_name(DeprecatedFlyString const& class_names)
|
||||
|
@ -1195,14 +1195,14 @@ JS::NonnullGCPtr<HTMLCollection> Document::get_elements_by_class_name(Deprecated
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-applets
|
||||
JS::NonnullGCPtr<HTMLCollection> Document::applets()
|
||||
{
|
||||
if (!m_applets)
|
||||
m_applets = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](auto&) { return false; }).release_value_but_fixme_should_propagate_errors();
|
||||
m_applets = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](auto&) { return false; });
|
||||
return *m_applets;
|
||||
}
|
||||
|
||||
|
@ -1212,7 +1212,7 @@ JS::NonnullGCPtr<HTMLCollection> Document::anchors()
|
|||
if (!m_anchors) {
|
||||
m_anchors = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const& element) {
|
||||
return is<HTML::HTMLAnchorElement>(element) && element.has_attribute(HTML::AttributeNames::name);
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
return *m_anchors;
|
||||
}
|
||||
|
@ -1223,7 +1223,7 @@ JS::NonnullGCPtr<HTMLCollection> Document::images()
|
|||
if (!m_images) {
|
||||
m_images = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const& element) {
|
||||
return is<HTML::HTMLImageElement>(element);
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
return *m_images;
|
||||
}
|
||||
|
@ -1234,7 +1234,7 @@ JS::NonnullGCPtr<HTMLCollection> Document::embeds()
|
|||
if (!m_embeds) {
|
||||
m_embeds = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const& element) {
|
||||
return is<HTML::HTMLEmbedElement>(element);
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
return *m_embeds;
|
||||
}
|
||||
|
@ -1251,7 +1251,7 @@ JS::NonnullGCPtr<HTMLCollection> Document::links()
|
|||
if (!m_links) {
|
||||
m_links = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const& element) {
|
||||
return (is<HTML::HTMLAnchorElement>(element) || is<HTML::HTMLAreaElement>(element)) && element.has_attribute(HTML::AttributeNames::href);
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
return *m_links;
|
||||
}
|
||||
|
@ -1262,7 +1262,7 @@ JS::NonnullGCPtr<HTMLCollection> Document::forms()
|
|||
if (!m_forms) {
|
||||
m_forms = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const& element) {
|
||||
return is<HTML::HTMLFormElement>(element);
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
return *m_forms;
|
||||
}
|
||||
|
@ -1273,7 +1273,7 @@ JS::NonnullGCPtr<HTMLCollection> Document::scripts()
|
|||
if (!m_scripts) {
|
||||
m_scripts = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const& element) {
|
||||
return is<HTML::HTMLScriptElement>(element);
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
return *m_scripts;
|
||||
}
|
||||
|
@ -1284,7 +1284,7 @@ JS::NonnullGCPtr<HTMLCollection> Document::all()
|
|||
if (!m_all) {
|
||||
m_all = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const&) {
|
||||
return true;
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
return *m_all;
|
||||
}
|
||||
|
@ -1417,17 +1417,17 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element_ns(Depre
|
|||
|
||||
JS::NonnullGCPtr<DocumentFragment> Document::create_document_fragment()
|
||||
{
|
||||
return heap().allocate<DocumentFragment>(realm(), *this).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
return heap().allocate<DocumentFragment>(realm(), *this);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Text> Document::create_text_node(DeprecatedString const& data)
|
||||
{
|
||||
return heap().allocate<Text>(realm(), *this, data).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
return heap().allocate<Text>(realm(), *this, data);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Comment> Document::create_comment(DeprecatedString const& data)
|
||||
{
|
||||
return heap().allocate<Comment>(realm(), *this, data).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
return heap().allocate<Comment>(realm(), *this, data);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
|
||||
|
@ -1438,12 +1438,12 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<ProcessingInstruction>> Document::create_pr
|
|||
// FIXME: 2. If data contains the string "?>", then throw an "InvalidCharacterError" DOMException.
|
||||
|
||||
// 3. Return a new ProcessingInstruction node, with target set to target, data set to data, and node document set to this.
|
||||
return MUST_OR_THROW_OOM(heap().allocate<ProcessingInstruction>(realm(), *this, data, target));
|
||||
return heap().allocate<ProcessingInstruction>(realm(), *this, data, target);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Range> Document::create_range()
|
||||
{
|
||||
return Range::create(*this).release_value_but_fixme_should_propagate_errors();
|
||||
return Range::create(*this);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-createevent
|
||||
|
@ -1458,44 +1458,44 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Document::create_event(DeprecatedSt
|
|||
// 2. If interface is an ASCII case-insensitive match for any of the strings in the first column in the following table,
|
||||
// then set constructor to the interface in the second column on the same row as the matching string:
|
||||
if (Infra::is_ascii_case_insensitive_match(interface, "beforeunloadevent"sv)) {
|
||||
event = TRY(Event::create(realm, FlyString {})); // FIXME: Create BeforeUnloadEvent
|
||||
event = Event::create(realm, FlyString {}); // FIXME: Create BeforeUnloadEvent
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "compositionevent"sv)) {
|
||||
event = TRY(Event::create(realm, FlyString {})); // FIXME: Create CompositionEvent
|
||||
event = Event::create(realm, FlyString {}); // FIXME: Create CompositionEvent
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "customevent"sv)) {
|
||||
event = TRY(CustomEvent::create(realm, FlyString {}));
|
||||
event = CustomEvent::create(realm, FlyString {});
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "devicemotionevent"sv)) {
|
||||
event = TRY(Event::create(realm, FlyString {})); // FIXME: Create DeviceMotionEvent
|
||||
event = Event::create(realm, FlyString {}); // FIXME: Create DeviceMotionEvent
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "deviceorientationevent"sv)) {
|
||||
event = TRY(Event::create(realm, FlyString {})); // FIXME: Create DeviceOrientationEvent
|
||||
event = Event::create(realm, FlyString {}); // FIXME: Create DeviceOrientationEvent
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "dragevent"sv)) {
|
||||
event = TRY(Event::create(realm, FlyString {})); // FIXME: Create DragEvent
|
||||
event = Event::create(realm, FlyString {}); // FIXME: Create DragEvent
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "event"sv)
|
||||
|| Infra::is_ascii_case_insensitive_match(interface, "events"sv)) {
|
||||
event = TRY(Event::create(realm, FlyString {}));
|
||||
event = Event::create(realm, FlyString {});
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "focusevent"sv)) {
|
||||
event = TRY(UIEvents::FocusEvent::create(realm, FlyString {}));
|
||||
event = UIEvents::FocusEvent::create(realm, FlyString {});
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "hashchangeevent"sv)) {
|
||||
event = TRY(Event::create(realm, FlyString {})); // FIXME: Create HashChangeEvent
|
||||
event = Event::create(realm, FlyString {}); // FIXME: Create HashChangeEvent
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "htmlevents"sv)) {
|
||||
event = TRY(Event::create(realm, FlyString {}));
|
||||
event = Event::create(realm, FlyString {});
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "keyboardevent"sv)) {
|
||||
event = TRY(UIEvents::KeyboardEvent::create(realm, String {}));
|
||||
event = UIEvents::KeyboardEvent::create(realm, String {});
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "messageevent"sv)) {
|
||||
event = TRY(HTML::MessageEvent::create(realm, String {}));
|
||||
event = HTML::MessageEvent::create(realm, String {});
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "mouseevent"sv)
|
||||
|| Infra::is_ascii_case_insensitive_match(interface, "mouseevents"sv)) {
|
||||
event = TRY(UIEvents::MouseEvent::create(realm, FlyString {}));
|
||||
event = UIEvents::MouseEvent::create(realm, FlyString {});
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "storageevent"sv)) {
|
||||
event = TRY(Event::create(realm, FlyString {})); // FIXME: Create StorageEvent
|
||||
event = Event::create(realm, FlyString {}); // FIXME: Create StorageEvent
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "svgevents"sv)) {
|
||||
event = TRY(Event::create(realm, FlyString {}));
|
||||
event = Event::create(realm, FlyString {});
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "textevent"sv)) {
|
||||
event = TRY(Event::create(realm, FlyString {})); // FIXME: Create CompositionEvent
|
||||
event = Event::create(realm, FlyString {}); // FIXME: Create CompositionEvent
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "touchevent"sv)) {
|
||||
event = TRY(Event::create(realm, FlyString {})); // FIXME: Create TouchEvent
|
||||
event = Event::create(realm, FlyString {}); // FIXME: Create TouchEvent
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "uievent"sv)
|
||||
|| Infra::is_ascii_case_insensitive_match(interface, "uievents"sv)) {
|
||||
event = TRY(UIEvents::UIEvent::create(realm, FlyString {}));
|
||||
event = UIEvents::UIEvent::create(realm, FlyString {});
|
||||
}
|
||||
|
||||
// 3. If constructor is null, then throw a "NotSupportedError" DOMException.
|
||||
|
@ -1896,7 +1896,7 @@ void Document::update_readiness(HTML::DocumentReadyState readiness_value)
|
|||
}
|
||||
|
||||
// 4. Fire an event named readystatechange at document.
|
||||
dispatch_event(Event::create(realm(), HTML::EventNames::readystatechange).release_value_but_fixme_should_propagate_errors());
|
||||
dispatch_event(Event::create(realm(), HTML::EventNames::readystatechange));
|
||||
}
|
||||
|
||||
Page* Document::page()
|
||||
|
@ -1948,7 +1948,7 @@ void Document::completely_finish_loading()
|
|||
// 5. Otherwise, if container is non-null, then queue an element task on the DOM manipulation task source given container to fire an event named load at container.
|
||||
else if (container) {
|
||||
container->queue_an_element_task(HTML::Task::Source::DOMManipulation, [container] {
|
||||
container->dispatch_event(DOM::Event::create(container->realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
|
||||
container->dispatch_event(DOM::Event::create(container->realm(), HTML::EventNames::load));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2037,7 +2037,7 @@ bool Document::is_active() const
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/history.html#dom-document-location
|
||||
WebIDL::ExceptionOr<JS::GCPtr<HTML::Location>> Document::location()
|
||||
JS::GCPtr<HTML::Location> Document::location()
|
||||
{
|
||||
// The Document object's location attribute's getter must return this Document object's relevant global object's Location object,
|
||||
// if this Document object is fully active, and null otherwise.
|
||||
|
@ -2045,7 +2045,7 @@ WebIDL::ExceptionOr<JS::GCPtr<HTML::Location>> Document::location()
|
|||
if (!is_fully_active())
|
||||
return nullptr;
|
||||
|
||||
return TRY(window().location());
|
||||
return window().location();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-document-hidden
|
||||
|
@ -2084,7 +2084,7 @@ void Document::update_the_visibility_state(HTML::VisibilityState visibility_stat
|
|||
// FIXME: 3. Run any page visibility change steps which may be defined in other specifications, with visibility state and document.
|
||||
|
||||
// 4. Fire an event named visibilitychange at document, with its bubbles attribute initialized to true.
|
||||
auto event = DOM::Event::create(realm(), HTML::EventNames::visibilitychange).release_value_but_fixme_should_propagate_errors();
|
||||
auto event = DOM::Event::create(realm(), HTML::EventNames::visibilitychange);
|
||||
event->set_bubbles(true);
|
||||
dispatch_event(event);
|
||||
}
|
||||
|
@ -2105,7 +2105,7 @@ void Document::run_the_resize_steps()
|
|||
return;
|
||||
m_last_viewport_size = viewport_size;
|
||||
|
||||
window().dispatch_event(DOM::Event::create(realm(), UIEvents::EventNames::resize).release_value_but_fixme_should_propagate_errors());
|
||||
window().dispatch_event(DOM::Event::create(realm(), UIEvents::EventNames::resize));
|
||||
|
||||
schedule_layout_update();
|
||||
}
|
||||
|
@ -2117,14 +2117,14 @@ void Document::run_the_scroll_steps()
|
|||
for (auto& target : m_pending_scroll_event_targets) {
|
||||
// 1. If target is a Document, fire an event named scroll that bubbles at target and fire an event named scroll at the VisualViewport that is associated with target.
|
||||
if (is<Document>(*target)) {
|
||||
auto event = DOM::Event::create(realm(), HTML::EventNames::scroll).release_value_but_fixme_should_propagate_errors();
|
||||
auto event = DOM::Event::create(realm(), HTML::EventNames::scroll);
|
||||
event->set_bubbles(true);
|
||||
target->dispatch_event(event);
|
||||
// FIXME: Fire at the associated VisualViewport
|
||||
}
|
||||
// 2. Otherwise, fire an event named scroll at target.
|
||||
else {
|
||||
auto event = DOM::Event::create(realm(), HTML::EventNames::scroll).release_value_but_fixme_should_propagate_errors();
|
||||
auto event = DOM::Event::create(realm(), HTML::EventNames::scroll);
|
||||
target->dispatch_event(event);
|
||||
}
|
||||
}
|
||||
|
@ -2164,7 +2164,7 @@ void Document::evaluate_media_queries_and_report_changes()
|
|||
CSS::MediaQueryListEventInit init;
|
||||
init.media = String::from_deprecated_string(media_query_list->media()).release_value_but_fixme_should_propagate_errors();
|
||||
init.matches = now_matches;
|
||||
auto event = CSS::MediaQueryListEvent::create(realm(), HTML::EventNames::change, init).release_value_but_fixme_should_propagate_errors();
|
||||
auto event = CSS::MediaQueryListEvent::create(realm(), HTML::EventNames::change, init);
|
||||
event->set_is_trusted(true);
|
||||
media_query_list->dispatch_event(*event);
|
||||
}
|
||||
|
@ -2191,7 +2191,7 @@ void Document::evaluate_media_rules()
|
|||
DOMImplementation* Document::implementation()
|
||||
{
|
||||
if (!m_implementation)
|
||||
m_implementation = DOMImplementation::create(*this).release_value_but_fixme_should_propagate_errors();
|
||||
m_implementation = DOMImplementation::create(*this);
|
||||
return m_implementation;
|
||||
}
|
||||
|
||||
|
@ -2323,7 +2323,7 @@ JS::NonnullGCPtr<NodeIterator> Document::create_node_iterator(Node& root, unsign
|
|||
// https://dom.spec.whatwg.org/#dom-document-createtreewalker
|
||||
JS::NonnullGCPtr<TreeWalker> Document::create_tree_walker(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter> filter)
|
||||
{
|
||||
return TreeWalker::create(root, what_to_show, filter).release_value_but_fixme_should_propagate_errors();
|
||||
return TreeWalker::create(root, what_to_show, filter);
|
||||
}
|
||||
|
||||
void Document::register_node_iterator(Badge<NodeIterator>, NodeIterator& node_iterator)
|
||||
|
@ -2386,7 +2386,7 @@ void Document::check_favicon_after_loading_link_resource()
|
|||
return false;
|
||||
|
||||
return static_cast<HTML::HTMLLinkElement const&>(element).has_loaded_icon();
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
|
||||
if (favicon_link_elements->length() == 0) {
|
||||
dbgln_if(SPAM_DEBUG, "No favicon found to be used");
|
||||
|
@ -2437,7 +2437,7 @@ JS::GCPtr<HTML::CustomElementDefinition> Document::lookup_custom_element_definit
|
|||
return nullptr;
|
||||
|
||||
// 3. Let registry be document's relevant global object's CustomElementRegistry object.
|
||||
auto registry = window().custom_elements().release_value_but_fixme_should_propagate_errors();
|
||||
auto registry = window().custom_elements();
|
||||
|
||||
// 4. If there is custom element definition in registry with name and local name both equal to localName, return that custom element definition.
|
||||
auto converted_local_name = String::from_deprecated_string(local_name).release_value_but_fixme_should_propagate_errors();
|
||||
|
@ -2458,7 +2458,7 @@ JS::GCPtr<HTML::CustomElementDefinition> Document::lookup_custom_element_definit
|
|||
CSS::StyleSheetList& Document::style_sheets()
|
||||
{
|
||||
if (!m_style_sheets)
|
||||
m_style_sheets = CSS::StyleSheetList::create(*this).release_value_but_fixme_should_propagate_errors();
|
||||
m_style_sheets = CSS::StyleSheetList::create(*this);
|
||||
return *m_style_sheets;
|
||||
}
|
||||
|
||||
|
@ -2470,7 +2470,7 @@ CSS::StyleSheetList const& Document::style_sheets() const
|
|||
JS::NonnullGCPtr<HTML::History> Document::history()
|
||||
{
|
||||
if (!m_history)
|
||||
m_history = HTML::History::create(realm(), *this).release_value_but_fixme_should_propagate_errors();
|
||||
m_history = HTML::History::create(realm(), *this);
|
||||
return *m_history;
|
||||
}
|
||||
|
||||
|
@ -2747,7 +2747,7 @@ void Document::unload(bool recursive_flag, Optional<DocumentUnloadTimingInfo> un
|
|||
// then fire an event named unload at document's relevant global object, with legacy target override flag set.
|
||||
// FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
|
||||
// We should reorganize this so that the flag appears explicitly here instead.
|
||||
auto event = DOM::Event::create(realm(), HTML::EventNames::unload).release_value_but_fixme_should_propagate_errors();
|
||||
auto event = DOM::Event::create(realm(), HTML::EventNames::unload);
|
||||
global_object().dispatch_event(event);
|
||||
}
|
||||
|
||||
|
@ -2860,7 +2860,7 @@ JS::NonnullGCPtr<DOM::Document> Document::appropriate_template_contents_owner_do
|
|||
// 1. If doc does not yet have an associated inert template document, then:
|
||||
if (!m_associated_inert_template_document) {
|
||||
// 1. Let new doc be a new Document (whose browsing context is null). This is "a Document created by this algorithm" for the purposes of the step above.
|
||||
auto new_document = HTML::HTMLDocument::create(realm()).release_value_but_fixme_should_propagate_errors();
|
||||
auto new_document = HTML::HTMLDocument::create(realm());
|
||||
new_document->m_created_for_appropriate_template_contents = true;
|
||||
|
||||
// 2. If doc is an HTML document, mark new doc as an HTML document also.
|
||||
|
@ -2880,7 +2880,7 @@ JS::NonnullGCPtr<DOM::Document> Document::appropriate_template_contents_owner_do
|
|||
DeprecatedString Document::dump_accessibility_tree_as_json()
|
||||
{
|
||||
StringBuilder builder;
|
||||
auto accessibility_tree = AccessibilityTreeNode::create(this, nullptr).release_value_but_fixme_should_propagate_errors();
|
||||
auto accessibility_tree = AccessibilityTreeNode::create(this, nullptr);
|
||||
build_accessibility_tree(*&accessibility_tree);
|
||||
auto json = MUST(JsonObjectSerializer<>::try_create(builder));
|
||||
|
||||
|
@ -2950,7 +2950,7 @@ HTML::ListOfAvailableImages const& Document::list_of_available_images() const
|
|||
JS::NonnullGCPtr<CSS::VisualViewport> Document::visual_viewport()
|
||||
{
|
||||
if (!m_visual_viewport)
|
||||
m_visual_viewport = CSS::VisualViewport::create(*this).release_value_but_fixme_should_propagate_errors();
|
||||
m_visual_viewport = CSS::VisualViewport::create(*this);
|
||||
return *m_visual_viewport;
|
||||
}
|
||||
|
||||
|
@ -3025,7 +3025,7 @@ void Document::queue_an_intersection_observer_entry(IntersectionObserver::Inters
|
|||
auto& realm = this->realm();
|
||||
|
||||
// 1. Construct an IntersectionObserverEntry, passing in time, rootBounds, boundingClientRect, intersectionRect, isIntersecting, and target.
|
||||
auto entry = realm.heap().allocate<IntersectionObserver::IntersectionObserverEntry>(realm, realm, time, root_bounds, bounding_client_rect, intersection_rect, is_intersecting, intersection_ratio, target).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
auto entry = realm.heap().allocate<IntersectionObserver::IntersectionObserverEntry>(realm, realm, time, root_bounds, bounding_client_rect, intersection_rect, is_intersecting, intersection_ratio, target);
|
||||
|
||||
// 2. Append it to observer’s internal [[QueuedEntries]] slot.
|
||||
observer.queue_entry({}, entry);
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> create_and_initialize(Type, DeprecatedString content_type, HTML::NavigationParams);
|
||||
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> create(JS::Realm&, AK::URL const& url = "about:blank"sv);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Document> create(JS::Realm&, AK::URL const& url = "about:blank"sv);
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> construct_impl(JS::Realm&);
|
||||
virtual ~Document() override;
|
||||
|
||||
|
@ -362,7 +362,7 @@ public:
|
|||
JS::NonnullGCPtr<HTML::History> history();
|
||||
JS::NonnullGCPtr<HTML::History> history() const;
|
||||
|
||||
WebIDL::ExceptionOr<JS::GCPtr<HTML::Location>> location();
|
||||
[[nodiscard]] JS::GCPtr<HTML::Location> location();
|
||||
|
||||
size_t number_of_things_delaying_the_load_event() { return m_number_of_things_delaying_the_load_event; }
|
||||
void increment_number_of_things_delaying_the_load_event(Badge<DocumentLoadEventDelayer>);
|
||||
|
|
|
@ -35,7 +35,7 @@ void DocumentFragment::set_host(Web::DOM::Element* element)
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> DocumentFragment::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<DocumentFragment>(realm, window.associated_document()));
|
||||
return realm.heap().allocate<DocumentFragment>(realm, window.associated_document());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ static bool build_image_document(DOM::Document& document, ByteBuffer const& data
|
|||
MUST(head_element->append_child(title_element));
|
||||
|
||||
auto basename = LexicalPath::basename(document.url().serialize_path());
|
||||
auto title_text = document.heap().allocate<DOM::Text>(document.realm(), document, DeprecatedString::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height())).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
auto title_text = document.heap().allocate<DOM::Text>(document.realm(), document, DeprecatedString::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height()));
|
||||
MUST(title_element->append_child(*title_text));
|
||||
|
||||
auto body_element = DOM::create_element(document, HTML::TagNames::body, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentType>> DocumentType::create(Document& document)
|
||||
JS::NonnullGCPtr<DocumentType> DocumentType::create(Document& document)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(document.heap().allocate<DocumentType>(document.realm(), document));
|
||||
return document.heap().allocate<DocumentType>(document.realm(), document);
|
||||
}
|
||||
|
||||
DocumentType::DocumentType(Document& document)
|
||||
|
|
|
@ -18,7 +18,7 @@ class DocumentType final
|
|||
WEB_PLATFORM_OBJECT(DocumentType, Node);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentType>> create(Document&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<DocumentType> create(Document&);
|
||||
|
||||
virtual ~DocumentType() override = default;
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ void Element::initialize(JS::Realm& realm)
|
|||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::ElementPrototype>(realm, "Element"));
|
||||
|
||||
m_attributes = MUST(NamedNodeMap::create(*this));
|
||||
m_attributes = NamedNodeMap::create(*this);
|
||||
}
|
||||
|
||||
void Element::visit_edges(Cell::Visitor& visitor)
|
||||
|
@ -130,7 +130,7 @@ WebIDL::ExceptionOr<void> Element::set_attribute(DeprecatedFlyString const& name
|
|||
|
||||
// 4. If attribute is null, create an attribute whose local name is qualifiedName, value is value, and node document is this’s node document, then append this attribute to this, and then return.
|
||||
if (!attribute) {
|
||||
auto new_attribute = TRY(Attr::create(document(), insert_as_lowercase ? name.to_lowercase() : name, value));
|
||||
auto new_attribute = Attr::create(document(), insert_as_lowercase ? name.to_lowercase() : name, value);
|
||||
m_attributes->append_attribute(new_attribute);
|
||||
|
||||
attribute = new_attribute.ptr();
|
||||
|
@ -264,7 +264,7 @@ WebIDL::ExceptionOr<bool> Element::toggle_attribute(DeprecatedFlyString const& n
|
|||
if (!attribute) {
|
||||
// 1. If force is not given or is true, create an attribute whose local name is qualifiedName, value is the empty string, and node document is this’s node document, then append this attribute to this, and then return true.
|
||||
if (!force.has_value() || force.value()) {
|
||||
auto new_attribute = TRY(Attr::create(document(), insert_as_lowercase ? name.to_lowercase() : name, ""));
|
||||
auto new_attribute = Attr::create(document(), insert_as_lowercase ? name.to_lowercase() : name, "");
|
||||
m_attributes->append_attribute(new_attribute);
|
||||
|
||||
attribute_changed(new_attribute->local_name(), "");
|
||||
|
@ -476,7 +476,7 @@ Element::RequiredInvalidationAfterStyleChange Element::recompute_style()
|
|||
|
||||
NonnullRefPtr<CSS::StyleProperties> Element::resolved_css_values()
|
||||
{
|
||||
auto element_computed_style = CSS::ResolvedCSSStyleDeclaration::create(*this).release_value_but_fixme_should_propagate_errors();
|
||||
auto element_computed_style = CSS::ResolvedCSSStyleDeclaration::create(*this);
|
||||
auto properties = CSS::StyleProperties::create();
|
||||
|
||||
for (auto i = to_underlying(CSS::first_property_id); i <= to_underlying(CSS::last_property_id); ++i) {
|
||||
|
@ -493,7 +493,7 @@ NonnullRefPtr<CSS::StyleProperties> Element::resolved_css_values()
|
|||
DOMTokenList* Element::class_list()
|
||||
{
|
||||
if (!m_class_list)
|
||||
m_class_list = DOMTokenList::create(*this, HTML::AttributeNames::class_).release_value_but_fixme_should_propagate_errors();
|
||||
m_class_list = DOMTokenList::create(*this, HTML::AttributeNames::class_);
|
||||
return m_class_list;
|
||||
}
|
||||
|
||||
|
@ -528,7 +528,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<ShadowRoot>> Element::attach_shadow(ShadowR
|
|||
return WebIDL::NotSupportedError::create(realm(), "Element already is a shadow host");
|
||||
|
||||
// 5. Let shadow be a new shadow root whose node document is this’s node document, host is this, and mode is init["mode"].
|
||||
auto shadow = MUST_OR_THROW_OOM(heap().allocate<ShadowRoot>(realm(), document(), *this, init.mode));
|
||||
auto shadow = heap().allocate<ShadowRoot>(realm(), document(), *this, init.mode);
|
||||
|
||||
// 6. Set shadow’s delegates focus to init["delegatesFocus"].
|
||||
shadow->set_delegates_focus(init.delegates_focus);
|
||||
|
@ -651,7 +651,7 @@ JS::NonnullGCPtr<HTMLCollection> Element::get_elements_by_class_name(DeprecatedF
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#element-shadow-host
|
||||
|
@ -676,7 +676,7 @@ void Element::set_shadow_root(JS::GCPtr<ShadowRoot> shadow_root)
|
|||
CSS::CSSStyleDeclaration* Element::style_for_bindings()
|
||||
{
|
||||
if (!m_inline_style)
|
||||
m_inline_style = CSS::ElementInlineCSSStyleDeclaration::create(*this, {}, {}).release_value_but_fixme_should_propagate_errors();
|
||||
m_inline_style = CSS::ElementInlineCSSStyleDeclaration::create(*this, {}, {});
|
||||
return m_inline_style;
|
||||
}
|
||||
|
||||
|
@ -723,7 +723,7 @@ JS::NonnullGCPtr<Geometry::DOMRect> Element::get_bounding_client_rect() const
|
|||
VERIFY(document().browsing_context());
|
||||
auto viewport_offset = document().browsing_context()->viewport_scroll_offset();
|
||||
|
||||
return Geometry::DOMRect::create(realm(), paintable_box->absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()).to_type<float>()).release_value_but_fixme_should_propagate_errors();
|
||||
return Geometry::DOMRect::create(realm(), paintable_box->absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()).to_type<float>());
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects
|
||||
|
@ -736,7 +736,7 @@ JS::NonnullGCPtr<Geometry::DOMRectList> Element::get_client_rects() const
|
|||
|
||||
// 1. If the element on which it was invoked does not have an associated layout box return an empty DOMRectList object and stop this algorithm.
|
||||
if (!layout_node() || !layout_node()->is_box())
|
||||
return Geometry::DOMRectList::create(realm(), move(rects)).release_value_but_fixme_should_propagate_errors();
|
||||
return Geometry::DOMRectList::create(realm(), move(rects));
|
||||
|
||||
// FIXME: 2. If the element has an associated SVG layout box return a DOMRectList object containing a single DOMRect object that describes
|
||||
// the bounding box of the element as defined by the SVG specification, applying the transforms that apply to the element and its ancestors.
|
||||
|
@ -750,7 +750,7 @@ JS::NonnullGCPtr<Geometry::DOMRectList> Element::get_client_rects() const
|
|||
|
||||
auto bounding_rect = get_bounding_client_rect();
|
||||
rects.append(*bounding_rect);
|
||||
return Geometry::DOMRectList::create(realm(), move(rects)).release_value_but_fixme_should_propagate_errors();
|
||||
return Geometry::DOMRectList::create(realm(), move(rects));
|
||||
}
|
||||
|
||||
int Element::client_top() const
|
||||
|
@ -1364,7 +1364,7 @@ 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.
|
||||
auto text = MUST_OR_THROW_OOM(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.
|
||||
|
|
|
@ -270,221 +270,221 @@ bool is_unknown_html_element(DeprecatedFlyString const& tag_name)
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#elements-in-the-dom:element-interface
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_html_element(JS::Realm& realm, Document& document, QualifiedName qualified_name)
|
||||
static JS::NonnullGCPtr<Element> create_html_element(JS::Realm& realm, Document& document, QualifiedName qualified_name)
|
||||
{
|
||||
auto lowercase_tag_name = qualified_name.local_name().to_lowercase();
|
||||
|
||||
if (lowercase_tag_name == HTML::TagNames::a)
|
||||
return MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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::summary)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLSummaryElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<HTML::HTMLSummaryElement>(realm, document, move(qualified_name));
|
||||
if (lowercase_tag_name == HTML::TagNames::caption)
|
||||
return MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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 MUST_OR_THROW_OOM(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::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 MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<HTML::HTMLElement>(realm, document, move(qualified_name));
|
||||
if (HTML::is_valid_custom_element_name(qualified_name.local_name()))
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<HTML::HTMLElement>(realm, document, move(qualified_name));
|
||||
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLUnknownElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<HTML::HTMLUnknownElement>(realm, document, move(qualified_name));
|
||||
}
|
||||
|
||||
static WebIDL::ExceptionOr<JS::GCPtr<SVG::SVGElement>> create_svg_element(JS::Realm& realm, Document& document, QualifiedName qualified_name)
|
||||
static JS::GCPtr<SVG::SVGElement> create_svg_element(JS::Realm& realm, Document& document, QualifiedName qualified_name)
|
||||
{
|
||||
auto const& local_name = qualified_name.local_name();
|
||||
|
||||
if (local_name == SVG::TagNames::svg)
|
||||
return MUST_OR_THROW_OOM(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 (local_name.equals_ignoring_ascii_case(SVG::TagNames::clipPath))
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGClipPathElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGClipPathElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::circle)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGCircleElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGCircleElement>(realm, document, move(qualified_name));
|
||||
if (local_name.equals_ignoring_ascii_case(SVG::TagNames::defs))
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGDefsElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGDefsElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::ellipse)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGEllipseElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGEllipseElement>(realm, document, move(qualified_name));
|
||||
if (local_name.equals_ignoring_ascii_case(SVG::TagNames::foreignObject))
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGForeignObjectElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGForeignObjectElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::line)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGLineElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGLineElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::linearGradient)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGLinearGradientElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGLinearGradientElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::mask)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGMaskElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGMaskElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::path)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGPathElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGPathElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::polygon)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGPolygonElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGPolygonElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::polyline)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGPolylineElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGPolylineElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::radialGradient)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGRadialGradientElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGRadialGradientElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::rect)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGRectElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGRectElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::g)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGGElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGGElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::stop)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGStopElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGStopElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::style)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGStyleElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGStyleElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::symbol)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGSymbolElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGSymbolElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::text)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGTextElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGTextElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::title)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGTitleElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGTitleElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::tspan)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGTSpanElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGTSpanElement>(realm, document, move(qualified_name));
|
||||
if (local_name == SVG::TagNames::use)
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGUseElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<SVG::SVGUseElement>(realm, document, move(qualified_name));
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static WebIDL::ExceptionOr<JS::GCPtr<MathML::MathMLElement>> create_mathml_element(JS::Realm& realm, Document& document, QualifiedName qualified_name)
|
||||
static JS::GCPtr<MathML::MathMLElement> create_mathml_element(JS::Realm& realm, Document& document, QualifiedName qualified_name)
|
||||
{
|
||||
auto const& local_name = TRY_OR_THROW_OOM(realm.vm(), FlyString::from_deprecated_fly_string(qualified_name.local_name()));
|
||||
auto const& local_name = MUST(FlyString::from_deprecated_fly_string(qualified_name.local_name()));
|
||||
|
||||
if (local_name.is_one_of(MathML::TagNames::annotation, MathML::TagNames::annotation_xml, MathML::TagNames::maction, MathML::TagNames::math, MathML::TagNames::merror, MathML::TagNames::mfrac, MathML::TagNames::mi, MathML::TagNames::mmultiscripts, MathML::TagNames::mn, MathML::TagNames::mo, MathML::TagNames::mover, MathML::TagNames::mpadded, MathML::TagNames::mphantom, MathML::TagNames::mprescripts, MathML::TagNames::mroot, MathML::TagNames::mrow, MathML::TagNames::ms, MathML::TagNames::mspace, MathML::TagNames::msqrt, MathML::TagNames::mstyle, MathML::TagNames::msub, MathML::TagNames::msubsup, MathML::TagNames::msup, MathML::TagNames::mtable, MathML::TagNames::mtd, MathML::TagNames::mtext, MathML::TagNames::mtr, MathML::TagNames::munder, MathML::TagNames::munderover, MathML::TagNames::semantics))
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<MathML::MathMLElement>(realm, document, move(qualified_name)));
|
||||
return realm.heap().allocate<MathML::MathMLElement>(realm, document, move(qualified_name));
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document
|
|||
// 2. Set result to a new element that implements interface, with no attributes, namespace set to the HTML namespace,
|
||||
// namespace prefix set to prefix, local name set to localName, custom element state set to "undefined", custom element definition set to null,
|
||||
// is value set to is, and node document set to document.
|
||||
auto element = TRY(create_html_element(realm, document, QualifiedName { local_name, prefix, Namespace::HTML }));
|
||||
auto element = create_html_element(realm, document, QualifiedName { local_name, prefix, Namespace::HTML });
|
||||
|
||||
// 3. If the synchronous custom elements flag is set, then run this step while catching any exceptions:
|
||||
if (synchronous_custom_elements_flag) {
|
||||
|
@ -596,7 +596,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document
|
|||
|
||||
// 2. Set result to a new element that implements the HTMLUnknownElement interface, with no attributes, namespace set to the HTML namespace, namespace prefix set to prefix,
|
||||
// local name set to localName, custom element state set to "failed", custom element definition set to null, is value set to null, and node document set to document.
|
||||
JS::NonnullGCPtr<Element> element = realm.heap().allocate<HTML::HTMLUnknownElement>(realm, document, QualifiedName { local_name, prefix, Namespace::HTML }).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
JS::NonnullGCPtr<Element> element = realm.heap().allocate<HTML::HTMLUnknownElement>(realm, document, QualifiedName { local_name, prefix, Namespace::HTML });
|
||||
element->set_custom_element_state(CustomElementState::Failed);
|
||||
return element;
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document
|
|||
// 2. Otherwise:
|
||||
// 1. Set result to a new element that implements the HTMLElement interface, with no attributes, namespace set to the HTML namespace, namespace prefix set to prefix,
|
||||
// local name set to localName, custom element state set to "undefined", custom element definition set to null, is value set to null, and node document set to document.
|
||||
JS::NonnullGCPtr<Element> element = realm.heap().allocate<HTML::HTMLElement>(realm, document, QualifiedName { local_name, prefix, Namespace::HTML }).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
auto element = realm.heap().allocate<HTML::HTMLElement>(realm, document, QualifiedName { local_name, prefix, Namespace::HTML });
|
||||
element->set_custom_element_state(CustomElementState::Undefined);
|
||||
|
||||
// 2. Enqueue a custom element upgrade reaction given result and definition.
|
||||
|
@ -624,7 +624,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document
|
|||
auto qualified_name = QualifiedName { local_name, prefix, namespace_ };
|
||||
|
||||
if (namespace_ == Namespace::HTML) {
|
||||
auto element = TRY(create_html_element(realm, document, move(qualified_name)));
|
||||
auto element = create_html_element(realm, document, move(qualified_name));
|
||||
element->set_is_value(move(is_value));
|
||||
element->set_custom_element_state(CustomElementState::Uncustomized);
|
||||
|
||||
|
@ -637,7 +637,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document
|
|||
}
|
||||
|
||||
if (namespace_ == Namespace::SVG) {
|
||||
auto element = TRY(create_svg_element(realm, document, qualified_name));
|
||||
auto element = create_svg_element(realm, document, qualified_name);
|
||||
if (element) {
|
||||
element->set_is_value(move(is_value));
|
||||
element->set_custom_element_state(CustomElementState::Uncustomized);
|
||||
|
@ -646,7 +646,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document
|
|||
}
|
||||
|
||||
if (namespace_ == Namespace::MathML) {
|
||||
auto element = TRY(create_mathml_element(realm, document, qualified_name));
|
||||
auto element = create_mathml_element(realm, document, qualified_name);
|
||||
if (element) {
|
||||
element->set_is_value(move(is_value));
|
||||
element->set_custom_element_state(CustomElementState::Uncustomized);
|
||||
|
@ -660,7 +660,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document
|
|||
// https://dom.spec.whatwg.org/#concept-element-interface
|
||||
// The element interface for any name and namespace is Element, unless stated otherwise.
|
||||
dbgln("Potential FIXME: Creating unknown generic element '{}' in namespace '{}'", local_name, namespace_);
|
||||
JS::NonnullGCPtr<Element> element = realm.heap().allocate<DOM::Element>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
auto element = realm.heap().allocate<DOM::Element>(realm, document, move(qualified_name));
|
||||
element->set_is_value(move(is_value));
|
||||
element->set_custom_element_state(CustomElementState::Uncustomized);
|
||||
return element;
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Event::create(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init)
|
||||
JS::NonnullGCPtr<Event> Event::create(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<Event>(realm, realm, event_name, event_init));
|
||||
return realm.heap().allocate<Event>(realm, realm, event_name, event_init);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Event::construct_impl(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init)
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
using Path = Vector<PathEntry>;
|
||||
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> create(JS::Realm&, FlyString const& event_name, EventInit const& event_init = {});
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Event> create(JS::Realm&, FlyString const& event_name, EventInit const& event_init = {});
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> construct_impl(JS::Realm&, FlyString const& event_name, EventInit const& event_init);
|
||||
|
||||
Event(JS::Realm&, FlyString const& type);
|
||||
|
|
|
@ -49,7 +49,7 @@ EventTarget::~EventTarget() = default;
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<EventTarget>> EventTarget::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
// The new EventTarget() constructor steps are to do nothing.
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<EventTarget>(realm, realm));
|
||||
return realm.heap().allocate<EventTarget>(realm, realm);
|
||||
}
|
||||
|
||||
void EventTarget::initialize(JS::Realm& realm)
|
||||
|
@ -581,7 +581,7 @@ void EventTarget::activate_event_handler(FlyString const& name, HTML::EventHandl
|
|||
// 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>();
|
||||
listener->type = name;
|
||||
listener->callback = IDLEventListener::create(realm, *callback).release_value_but_fixme_should_propagate_errors();
|
||||
listener->callback = IDLEventListener::create(realm, *callback);
|
||||
|
||||
// 6. Add an event listener with eventTarget and listener.
|
||||
add_an_event_listener(*listener);
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLCollection>> HTMLCollection::create(ParentNode& root, Scope scope, Function<bool(Element const&)> filter)
|
||||
JS::NonnullGCPtr<HTMLCollection> HTMLCollection::create(ParentNode& root, Scope scope, Function<bool(Element const&)> filter)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(root.heap().allocate<HTMLCollection>(root.realm(), root, scope, move(filter)));
|
||||
return root.heap().allocate<HTMLCollection>(root.realm(), root, scope, move(filter));
|
||||
}
|
||||
|
||||
HTMLCollection::HTMLCollection(ParentNode& root, Scope scope, Function<bool(Element const&)> filter)
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
Children,
|
||||
Descendants,
|
||||
};
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLCollection>> create(ParentNode& root, Scope, Function<bool(Element const&)> filter);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<HTMLCollection> create(ParentNode& root, Scope, Function<bool(Element const&)> filter);
|
||||
|
||||
virtual ~HTMLCollection() override;
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<IDLEventListener>> IDLEventListener::create(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::CallbackType> callback)
|
||||
JS::NonnullGCPtr<IDLEventListener> IDLEventListener::create(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::CallbackType> callback)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(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)
|
||||
|
|
|
@ -28,7 +28,7 @@ class IDLEventListener final : public JS::Object {
|
|||
JS_OBJECT(IDLEventListener, JS::Object);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<IDLEventListener>> create(JS::Realm&, JS::NonnullGCPtr<WebIDL::CallbackType>);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<IDLEventListener> create(JS::Realm&, JS::NonnullGCPtr<WebIDL::CallbackType>);
|
||||
IDLEventListener(JS::Realm&, JS::NonnullGCPtr<WebIDL::CallbackType>);
|
||||
|
||||
virtual ~IDLEventListener() = default;
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<NodeList>> LiveNodeList::create(JS::Realm& realm, Node& root, Scope scope, Function<bool(Node const&)> filter)
|
||||
JS::NonnullGCPtr<NodeList> LiveNodeList::create(JS::Realm& realm, Node& root, Scope scope, Function<bool(Node const&)> filter)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<LiveNodeList>(realm, realm, root, scope, move(filter)));
|
||||
return realm.heap().allocate<LiveNodeList>(realm, realm, root, scope, move(filter));
|
||||
}
|
||||
|
||||
LiveNodeList::LiveNodeList(JS::Realm& realm, Node& root, Scope scope, Function<bool(Node const&)> filter)
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
Descendants,
|
||||
};
|
||||
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<NodeList>> create(JS::Realm&, Node& root, Scope, Function<bool(Node const&)> filter);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<NodeList> create(JS::Realm&, Node& root, Scope, Function<bool(Node const&)> filter);
|
||||
virtual ~LiveNodeList() override;
|
||||
|
||||
virtual u32 length() const override;
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::DOM {
|
|||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationObserver>> MutationObserver::construct_impl(JS::Realm& realm, JS::GCPtr<WebIDL::CallbackType> callback)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<MutationObserver>(realm, realm, callback));
|
||||
return realm.heap().allocate<MutationObserver>(realm, realm, callback);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-mutationobserver-mutationobserver
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationRecord>> MutationRecord::create(JS::Realm& realm, FlyString const& type, Node const& 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)
|
||||
JS::NonnullGCPtr<MutationRecord> MutationRecord::create(JS::Realm& realm, FlyString const& type, Node const& 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 MUST_OR_THROW_OOM(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 const& 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)
|
||||
|
|
|
@ -16,7 +16,7 @@ class MutationRecord : public Bindings::PlatformObject {
|
|||
WEB_PLATFORM_OBJECT(MutationRecord, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationRecord>> create(JS::Realm&, FlyString const& type, Node const& 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);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<MutationRecord> create(JS::Realm&, FlyString const& type, Node const& 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);
|
||||
|
||||
virtual ~MutationRecord() override;
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<NamedNodeMap>> NamedNodeMap::create(Element& element)
|
||||
JS::NonnullGCPtr<NamedNodeMap> NamedNodeMap::create(Element& element)
|
||||
{
|
||||
auto& realm = element.realm();
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<NamedNodeMap>(realm, element));
|
||||
return realm.heap().allocate<NamedNodeMap>(realm, element);
|
||||
}
|
||||
|
||||
NamedNodeMap::NamedNodeMap(Element& element)
|
||||
|
|
|
@ -22,7 +22,7 @@ class NamedNodeMap : public Bindings::LegacyPlatformObject {
|
|||
WEB_PLATFORM_OBJECT(NamedNodeMap, Bindings::LegacyPlatformObject);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<NamedNodeMap>> create(Element&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<NamedNodeMap> create(Element&);
|
||||
~NamedNodeMap() = default;
|
||||
|
||||
virtual bool is_supported_property_index(u32 index) const override;
|
||||
|
|
|
@ -777,7 +777,7 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
|
|||
else if (is<Document>(this)) {
|
||||
// Document
|
||||
auto document_ = verify_cast<Document>(this);
|
||||
auto document_copy = Document::create(this->realm(), document_->url()).release_value_but_fixme_should_propagate_errors();
|
||||
auto document_copy = Document::create(this->realm(), document_->url());
|
||||
|
||||
// Set copy’s encoding, content type, URL, origin, type, and mode to those of node.
|
||||
document_copy->set_encoding(document_->encoding());
|
||||
|
@ -790,7 +790,7 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
|
|||
} else if (is<DocumentType>(this)) {
|
||||
// DocumentType
|
||||
auto document_type = verify_cast<DocumentType>(this);
|
||||
auto document_type_copy = heap().allocate<DocumentType>(realm(), *document).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
auto document_type_copy = heap().allocate<DocumentType>(realm(), *document);
|
||||
|
||||
// Set copy’s name, public ID, and system ID to those of node.
|
||||
document_type_copy->set_name(document_type->name());
|
||||
|
@ -807,26 +807,26 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
|
|||
auto text = verify_cast<Text>(this);
|
||||
|
||||
// Set copy’s data to that of node.
|
||||
auto text_copy = heap().allocate<Text>(realm(), *document, text->data()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
auto text_copy = heap().allocate<Text>(realm(), *document, text->data());
|
||||
copy = move(text_copy);
|
||||
} else if (is<Comment>(this)) {
|
||||
// Comment
|
||||
auto comment = verify_cast<Comment>(this);
|
||||
|
||||
// Set copy’s data to that of node.
|
||||
auto comment_copy = heap().allocate<Comment>(realm(), *document, comment->data()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
auto comment_copy = heap().allocate<Comment>(realm(), *document, comment->data());
|
||||
copy = move(comment_copy);
|
||||
} else if (is<ProcessingInstruction>(this)) {
|
||||
// ProcessingInstruction
|
||||
auto processing_instruction = verify_cast<ProcessingInstruction>(this);
|
||||
|
||||
// Set copy’s target and data to those of node.
|
||||
auto processing_instruction_copy = heap().allocate<ProcessingInstruction>(realm(), *document, processing_instruction->data(), processing_instruction->target()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
auto processing_instruction_copy = heap().allocate<ProcessingInstruction>(realm(), *document, processing_instruction->data(), processing_instruction->target());
|
||||
copy = processing_instruction_copy;
|
||||
}
|
||||
// Otherwise, Do nothing.
|
||||
else if (is<DocumentFragment>(this)) {
|
||||
copy = heap().allocate<DocumentFragment>(realm(), *document).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
copy = heap().allocate<DocumentFragment>(realm(), *document);
|
||||
}
|
||||
|
||||
// FIXME: 4. Set copy’s node document and document to copy, if copy is a document, and set copy’s node document to document otherwise.
|
||||
|
@ -937,7 +937,7 @@ JS::NonnullGCPtr<NodeList> Node::child_nodes()
|
|||
if (!m_child_nodes) {
|
||||
m_child_nodes = LiveNodeList::create(realm(), *this, LiveNodeList::Scope::Children, [](auto&) {
|
||||
return true;
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
return *m_child_nodes;
|
||||
}
|
||||
|
@ -1259,7 +1259,7 @@ void Node::string_replace_all(DeprecatedString const& string)
|
|||
|
||||
// 2. If string is not the empty string, then set node to a new Text node whose data is string and node document is parent’s node document.
|
||||
if (!string.is_empty())
|
||||
node = heap().allocate<Text>(realm(), document(), string).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
node = heap().allocate<Text>(realm(), document(), string);
|
||||
|
||||
// 3. Replace all with node within parent.
|
||||
replace_all(node);
|
||||
|
@ -1517,14 +1517,14 @@ void Node::queue_mutation_record(FlyString const& type, DeprecatedString attribu
|
|||
if (interested_observers.is_empty())
|
||||
return;
|
||||
|
||||
auto added_nodes_list = StaticNodeList::create(realm(), move(added_nodes)).release_value_but_fixme_should_propagate_errors();
|
||||
auto removed_nodes_list = StaticNodeList::create(realm(), move(removed_nodes)).release_value_but_fixme_should_propagate_errors();
|
||||
auto added_nodes_list = StaticNodeList::create(realm(), move(added_nodes));
|
||||
auto removed_nodes_list = StaticNodeList::create(realm(), move(removed_nodes));
|
||||
|
||||
// 4. For each observer → mappedOldValue of interestedObservers:
|
||||
for (auto& interested_observer : interested_observers) {
|
||||
// 1. Let record be a new MutationRecord object with its type set to type, target set to target, attributeName set to name, attributeNamespace set to namespace, oldValue set to mappedOldValue,
|
||||
// addedNodes set to addedNodes, removedNodes set to removedNodes, previousSibling set to previousSibling, and nextSibling set to nextSibling.
|
||||
auto record = MutationRecord::create(realm(), type, *this, added_nodes_list, removed_nodes_list, previous_sibling, next_sibling, attribute_name, attribute_namespace, /* mappedOldValue */ interested_observer.value).release_value_but_fixme_should_propagate_errors();
|
||||
auto record = MutationRecord::create(realm(), type, *this, added_nodes_list, removed_nodes_list, previous_sibling, next_sibling, attribute_name, attribute_namespace, /* mappedOldValue */ interested_observer.value);
|
||||
|
||||
// 2. Enqueue record to observer’s record queue.
|
||||
interested_observer.key->enqueue_record({}, move(record));
|
||||
|
@ -1661,7 +1661,7 @@ void Node::build_accessibility_tree(AccessibilityTreeNode& parent)
|
|||
return;
|
||||
|
||||
if (element->include_in_accessibility_tree()) {
|
||||
auto current_node = AccessibilityTreeNode::create(&document(), this).release_value_but_fixme_should_propagate_errors();
|
||||
auto current_node = AccessibilityTreeNode::create(&document(), this);
|
||||
parent.append_child(current_node);
|
||||
if (has_child_nodes()) {
|
||||
for_each_child([¤t_node](DOM::Node& child) {
|
||||
|
@ -1674,7 +1674,7 @@ void Node::build_accessibility_tree(AccessibilityTreeNode& parent)
|
|||
});
|
||||
}
|
||||
} else if (is_text()) {
|
||||
parent.append_child(AccessibilityTreeNode::create(&document(), this).release_value_but_fixme_should_propagate_errors());
|
||||
parent.append_child(AccessibilityTreeNode::create(&document(), this));
|
||||
if (has_child_nodes()) {
|
||||
for_each_child([&parent](DOM::Node& child) {
|
||||
child.build_accessibility_tree(parent);
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<NodeFilter>> NodeFilter::create(JS::Realm& realm, WebIDL::CallbackType& callback)
|
||||
JS::NonnullGCPtr<NodeFilter> NodeFilter::create(JS::Realm& realm, WebIDL::CallbackType& callback)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<NodeFilter>(realm, realm, callback));
|
||||
return realm.heap().allocate<NodeFilter>(realm, realm, callback);
|
||||
}
|
||||
|
||||
NodeFilter::NodeFilter(JS::Realm& realm, WebIDL::CallbackType& callback)
|
||||
|
|
|
@ -15,7 +15,7 @@ class NodeFilter final : public Bindings::PlatformObject {
|
|||
WEB_PLATFORM_OBJECT(NodeFilter, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<NodeFilter>> create(JS::Realm&, WebIDL::CallbackType&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<NodeFilter> create(JS::Realm&, WebIDL::CallbackType&);
|
||||
|
||||
virtual ~NodeFilter() = default;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<NodeIterator>> NodeIterator::create(Node& r
|
|||
// 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 = MUST_OR_THROW_OOM(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;
|
||||
|
|
|
@ -22,19 +22,19 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> convert_nodes_to_single_node(Vector<
|
|||
// 4. Otherwise, set node to a new DocumentFragment node whose node document is document, and then append each node in nodes, if any, to it.
|
||||
// 5. Return node.
|
||||
|
||||
auto potentially_convert_string_to_text_node = [&document](Variant<JS::Handle<Node>, DeprecatedString> const& node) -> JS::ThrowCompletionOr<JS::NonnullGCPtr<Node>> {
|
||||
auto potentially_convert_string_to_text_node = [&document](Variant<JS::Handle<Node>, DeprecatedString> const& node) -> JS::NonnullGCPtr<Node> {
|
||||
if (node.has<JS::Handle<Node>>())
|
||||
return *node.get<JS::Handle<Node>>();
|
||||
|
||||
return MUST_OR_THROW_OOM(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 TRY(potentially_convert_string_to_text_node(nodes.first()));
|
||||
return potentially_convert_string_to_text_node(nodes.first());
|
||||
|
||||
auto document_fragment = MUST_OR_THROW_OOM(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 = TRY(potentially_convert_string_to_text_node(unconverted_node));
|
||||
auto node = potentially_convert_string_to_text_node(unconverted_node);
|
||||
(void)TRY(document_fragment->append_child(node));
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ JS::NonnullGCPtr<HTMLCollection> ParentNode::children()
|
|||
if (!m_children) {
|
||||
m_children = HTMLCollection::create(*this, HTMLCollection::Scope::Children, [](Element const&) {
|
||||
return true;
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
return *m_children;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ JS::NonnullGCPtr<HTMLCollection> ParentNode::get_elements_by_tag_name(Deprecated
|
|||
if (qualified_name == "*") {
|
||||
return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const&) {
|
||||
return true;
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
|
||||
// 2. Otherwise, if root’s node document is an HTML document, return a HTMLCollection rooted at root, whose filter matches the following descendant elements:
|
||||
|
@ -140,13 +140,13 @@ JS::NonnullGCPtr<HTMLCollection> ParentNode::get_elements_by_tag_name(Deprecated
|
|||
|
||||
// - Whose namespace is not the HTML namespace and whose qualified name is qualifiedName.
|
||||
return element.qualified_name() == qualified_name;
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
|
||||
// 3. Otherwise, return a HTMLCollection rooted at root, whose filter matches descendant elements whose qualified name is qualifiedName.
|
||||
return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [qualified_name](Element const& element) {
|
||||
return element.qualified_name() == qualified_name;
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-getelementsbytagnamens
|
||||
|
@ -162,27 +162,27 @@ JS::NonnullGCPtr<HTMLCollection> ParentNode::get_elements_by_tag_name_ns(Depreca
|
|||
if (namespace_ == "*" && local_name == "*") {
|
||||
return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const&) {
|
||||
return true;
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
|
||||
// 3. Otherwise, if namespace is "*" (U+002A), return a HTMLCollection rooted at root, whose filter matches descendant elements whose local name is localName.
|
||||
if (namespace_ == "*") {
|
||||
return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [local_name](Element const& element) {
|
||||
return element.local_name() == local_name;
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
|
||||
// 4. Otherwise, if localName is "*" (U+002A), return a HTMLCollection rooted at root, whose filter matches descendant elements whose namespace is namespace.
|
||||
if (local_name == "*") {
|
||||
return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [namespace_](Element const& element) {
|
||||
return element.namespace_() == namespace_;
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
|
||||
// 5. Otherwise, return a HTMLCollection rooted at root, whose filter matches descendant elements whose namespace is namespace and local name is localName.
|
||||
return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [namespace_, local_name](Element const& element) {
|
||||
return element.namespace_() == namespace_ && element.local_name() == local_name;
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-prepend
|
||||
|
|
|
@ -31,21 +31,21 @@ HashTable<Range*>& Range::live_ranges()
|
|||
return ranges;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Range>> Range::create(HTML::Window& window)
|
||||
JS::NonnullGCPtr<Range> Range::create(HTML::Window& window)
|
||||
{
|
||||
return Range::create(window.associated_document());
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Range>> Range::create(Document& document)
|
||||
JS::NonnullGCPtr<Range> Range::create(Document& document)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<Range>(realm, document));
|
||||
return realm.heap().allocate<Range>(realm, document);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Range>> Range::create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset)
|
||||
JS::NonnullGCPtr<Range> Range::create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset)
|
||||
{
|
||||
auto& realm = start_container.realm();
|
||||
return MUST_OR_THROW_OOM(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);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Range>> Range::construct_impl(JS::Realm& realm)
|
||||
|
@ -430,12 +430,12 @@ WebIDL::ExceptionOr<void> Range::select_node_contents(Node& 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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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
|
||||
|
@ -589,7 +589,7 @@ 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 = MUST_OR_THROW_OOM(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())
|
||||
|
@ -717,7 +717,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract()
|
|||
TRY(fragment->append_child(clone));
|
||||
|
||||
// 3. Let subrange be a new live range whose start is (original start node, original start offset) and whose end is (first partially contained child, first partially contained child’s length).
|
||||
auto subrange = TRY(Range::create(original_start_node, original_start_offset, *first_partially_contained_child, first_partially_contained_child->length()));
|
||||
auto subrange = Range::create(original_start_node, original_start_offset, *first_partially_contained_child, first_partially_contained_child->length());
|
||||
|
||||
// 4. Let subfragment be the result of extracting subrange.
|
||||
auto subfragment = TRY(subrange->extract());
|
||||
|
@ -755,7 +755,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract()
|
|||
TRY(fragment->append_child(clone));
|
||||
|
||||
// 3. Let subrange be a new live range whose start is (last partially contained child, 0) and whose end is (original end node, original end offset).
|
||||
auto subrange = TRY(Range::create(*last_partially_contained_child, 0, original_end_node, original_end_offset));
|
||||
auto subrange = Range::create(*last_partially_contained_child, 0, original_end_node, original_end_offset);
|
||||
|
||||
// 4. Let subfragment be the result of extracting subrange.
|
||||
auto subfragment = TRY(subrange->extract());
|
||||
|
@ -918,7 +918,7 @@ 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 = MUST_OR_THROW_OOM(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())
|
||||
|
@ -1018,7 +1018,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_the_content
|
|||
TRY(fragment->append_child(clone));
|
||||
|
||||
// 3. Let subrange be a new live range whose start is (original start node, original start offset) and whose end is (first partially contained child, first partially contained child’s length).
|
||||
auto subrange = TRY(Range::create(original_start_node, original_start_offset, *first_partially_contained_child, first_partially_contained_child->length()));
|
||||
auto subrange = Range::create(original_start_node, original_start_offset, *first_partially_contained_child, first_partially_contained_child->length());
|
||||
|
||||
// 4. Let subfragment be the result of cloning the contents of subrange.
|
||||
auto subfragment = TRY(subrange->clone_the_contents());
|
||||
|
@ -1057,7 +1057,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_the_content
|
|||
TRY(fragment->append_child(clone));
|
||||
|
||||
// 3. Let subrange be a new live range whose start is (last partially contained child, 0) and whose end is (original end node, original end offset).
|
||||
auto subrange = TRY(Range::create(*last_partially_contained_child, 0, original_end_node, original_end_offset));
|
||||
auto subrange = Range::create(*last_partially_contained_child, 0, original_end_node, original_end_offset);
|
||||
|
||||
// 4. Let subfragment be the result of cloning the contents of subrange.
|
||||
auto subfragment = TRY(subrange->clone_the_contents());
|
||||
|
|
|
@ -26,9 +26,9 @@ class Range final : public AbstractRange {
|
|||
WEB_PLATFORM_OBJECT(Range, AbstractRange);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Range>> create(Document&);
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Range>> create(HTML::Window&);
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Range>> create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Range> create(Document&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Range> create(HTML::Window&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Range> create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset);
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Range>> construct_impl(JS::Realm&);
|
||||
|
||||
virtual ~Range() override;
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<NodeList>> StaticNodeList::create(JS::Realm& realm, Vector<JS::Handle<Node>> static_nodes)
|
||||
JS::NonnullGCPtr<NodeList> StaticNodeList::create(JS::Realm& realm, Vector<JS::Handle<Node>> static_nodes)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(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)
|
||||
|
|
|
@ -15,7 +15,7 @@ class StaticNodeList final : public NodeList {
|
|||
WEB_PLATFORM_OBJECT(StaticNodeList, NodeList);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<NodeList>> create(JS::Realm&, Vector<JS::Handle<Node>>);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<NodeList> create(JS::Realm&, Vector<JS::Handle<Node>>);
|
||||
|
||||
virtual ~StaticNodeList() override;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<StaticRange>> StaticRange::construct_impl(J
|
|||
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 MUST_OR_THROW_OOM(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);
|
||||
}
|
||||
|
||||
void StaticRange::initialize(JS::Realm& realm)
|
||||
|
|
|
@ -41,7 +41,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Text>> Text::construct_impl(JS::Realm& real
|
|||
{
|
||||
// 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 MUST_OR_THROW_OOM(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)
|
||||
|
@ -67,7 +67,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 = MUST_OR_THROW_OOM(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();
|
||||
|
|
|
@ -37,12 +37,12 @@ void TreeWalker::visit_edges(Cell::Visitor& visitor)
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-createtreewalker
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<TreeWalker>> TreeWalker::create(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter> filter)
|
||||
JS::NonnullGCPtr<TreeWalker> TreeWalker::create(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter> filter)
|
||||
{
|
||||
// 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 = MUST_OR_THROW_OOM(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;
|
||||
|
|
|
@ -15,7 +15,7 @@ class TreeWalker final : public Bindings::PlatformObject {
|
|||
WEB_PLATFORM_OBJECT(TreeWalker, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TreeWalker>> create(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter>);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<TreeWalker> create(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter>);
|
||||
|
||||
virtual ~TreeWalker() override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue