1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:27:45 +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:
Andreas Kling 2023-08-13 13:05:26 +02:00
parent 980e7164fe
commit 72c9f56c66
337 changed files with 1229 additions and 1251 deletions

View file

@ -102,7 +102,7 @@ void AudioTrack::set_enabled(bool enabled)
// is disabled, the user agent must queue a media element task given the media element to fire an event named
// change at the AudioTrackList object.
m_media_element->queue_a_media_element_task([this]() {
m_audio_track_list->dispatch_event(DOM::Event::create(realm(), HTML::EventNames::change).release_value_but_fixme_should_propagate_errors());
m_audio_track_list->dispatch_event(DOM::Event::create(realm(), HTML::EventNames::change));
});
}

View file

@ -150,10 +150,10 @@ JS::NonnullGCPtr<BrowsingContext> BrowsingContext::create_a_new_browsing_context
auto realm_execution_context = Bindings::create_a_new_javascript_realm(
Bindings::main_thread_vm(),
[&](JS::Realm& realm) -> JS::Object* {
browsing_context->m_window_proxy = realm.heap().allocate<WindowProxy>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
browsing_context->m_window_proxy = realm.heap().allocate<WindowProxy>(realm, realm);
// - 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.ptr();
},
[&](JS::Realm&) -> JS::Object* {
@ -173,8 +173,7 @@ JS::NonnullGCPtr<BrowsingContext> BrowsingContext::create_a_new_browsing_context
move(realm_execution_context),
{},
top_level_creation_url,
top_level_origin)
.release_value_but_fixme_should_propagate_errors();
top_level_origin);
// 12. Let loadTimingInfo be a new document load timing info with its navigation start time set to the result of calling
// coarsen time with unsafeContextCreationTime and the new environment settings object's cross-origin isolated capability.
@ -204,7 +203,7 @@ JS::NonnullGCPtr<BrowsingContext> BrowsingContext::create_a_new_browsing_context
// load timing info is loadTimingInfo,
// FIXME: navigation id is null,
// and which is ready for post-load tasks.
auto document = HTML::HTMLDocument::create(window->realm()).release_value_but_fixme_should_propagate_errors();
auto document = HTML::HTMLDocument::create(window->realm());
// Non-standard
document->set_window(*window);
@ -329,10 +328,10 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
Bindings::main_thread_vm(),
[&](JS::Realm& realm) -> JS::Object* {
auto window_proxy = realm.heap().allocate<WindowProxy>(realm, realm);
browsing_context->set_window_proxy(window_proxy.release_allocated_value_but_fixme_should_propagate_errors());
browsing_context->set_window_proxy(window_proxy);
// - For the global object, create a new Window object.
window = Window::create(realm).release_value_but_fixme_should_propagate_errors();
window = Window::create(realm);
return window.ptr();
},
[&](JS::Realm&) -> JS::Object* {
@ -347,12 +346,12 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
auto top_level_origin = !embedder ? origin : relevant_settings_object(*embedder).origin();
// 12. Set up a window environment settings object with about:blank, realm execution context, null, topLevelCreationURL, and topLevelOrigin.
TRY(WindowEnvironmentSettingsObject::setup(
WindowEnvironmentSettingsObject::setup(
AK::URL("about:blank"),
move(realm_execution_context),
{},
top_level_creation_url,
top_level_origin));
top_level_origin);
// 13. Let loadTimingInfo be a new document load timing info with its navigation start time set to the result of calling
// coarsen time with unsafeContextCreationTime and the new environment settings object's cross-origin isolated capability.
@ -362,7 +361,7 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
verify_cast<WindowEnvironmentSettingsObject>(Bindings::host_defined_environment_settings_object(window->realm())).cross_origin_isolated_capability() == CanUseCrossOriginIsolatedAPIs::Yes);
// 14. Let document be a new Document, with:
auto document = TRY(HTML::HTMLDocument::create(window->realm()));
auto document = HTML::HTMLDocument::create(window->realm());
// Non-standard
document->set_window(*window);
@ -1435,7 +1434,7 @@ WebIDL::ExceptionOr<void> BrowsingContext::traverse_the_history(size_t entry_ind
// and the newURL attribute initialized to newURL.
// FIXME: Implement a proper HashChangeEvent class.
auto event = DOM::Event::create(verify_cast<HTML::Window>(relevant_global_object(*new_document)).realm(), HTML::EventNames::hashchange).release_value_but_fixme_should_propagate_errors();
auto event = DOM::Event::create(verify_cast<HTML::Window>(relevant_global_object(*new_document)).realm(), HTML::EventNames::hashchange);
new_document->dispatch_event(event);
});
}

View file

@ -22,21 +22,21 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> CanvasGradient::create_rad
return WebIDL::IndexSizeError::create(realm, "The r1 passed is less than 0");
auto radial_gradient = TRY_OR_THROW_OOM(realm.vm(), Gfx::CanvasRadialGradientPaintStyle::create(Gfx::FloatPoint { x0, y0 }, r0, Gfx::FloatPoint { x1, y1 }, r1));
return MUST_OR_THROW_OOM(realm.heap().allocate<CanvasGradient>(realm, realm, *radial_gradient));
return realm.heap().allocate<CanvasGradient>(realm, realm, *radial_gradient);
}
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createlineargradient
WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> CanvasGradient::create_linear(JS::Realm& realm, double x0, double y0, double x1, double y1)
{
auto linear_gradient = TRY_OR_THROW_OOM(realm.vm(), Gfx::CanvasLinearGradientPaintStyle::create(Gfx::FloatPoint { x0, y0 }, Gfx::FloatPoint { x1, y1 }));
return MUST_OR_THROW_OOM(realm.heap().allocate<CanvasGradient>(realm, realm, *linear_gradient));
return realm.heap().allocate<CanvasGradient>(realm, realm, *linear_gradient);
}
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createconicgradient
WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> CanvasGradient::create_conic(JS::Realm& realm, double start_angle, double x, double y)
{
auto conic_gradient = TRY_OR_THROW_OOM(realm.vm(), Gfx::CanvasConicGradientPaintStyle::create(Gfx::FloatPoint { x, y }, start_angle));
return MUST_OR_THROW_OOM(realm.heap().allocate<CanvasGradient>(realm, realm, *conic_gradient));
return realm.heap().allocate<CanvasGradient>(realm, realm, *conic_gradient);
}
CanvasGradient::CanvasGradient(JS::Realm& realm, Gfx::GradientPaintStyle& gradient)

View file

@ -130,7 +130,7 @@ WebIDL::ExceptionOr<JS::GCPtr<CanvasPattern>> CanvasPattern::create(JS::Realm& r
// FIXME: 7. If image is not origin-clean, then mark pattern as not origin-clean.
// 8. Return pattern.
return MUST_OR_THROW_OOM(realm.heap().allocate<CanvasPattern>(realm, realm, *pattern));
return realm.heap().allocate<CanvasPattern>(realm, realm, *pattern);
}
void CanvasPattern::initialize(JS::Realm& realm)

View file

@ -26,9 +26,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasRenderingContext2D>> CanvasRenderingContext2D::create(JS::Realm& realm, HTMLCanvasElement& element)
JS::NonnullGCPtr<CanvasRenderingContext2D> CanvasRenderingContext2D::create(JS::Realm& realm, HTMLCanvasElement& element)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<CanvasRenderingContext2D>(realm, realm, element));
return realm.heap().allocate<CanvasRenderingContext2D>(realm, realm, element);
}
CanvasRenderingContext2D::CanvasRenderingContext2D(JS::Realm& realm, HTMLCanvasElement& element)
@ -394,7 +394,7 @@ JS::NonnullGCPtr<TextMetrics> CanvasRenderingContext2D::measure_text(DeprecatedS
// TextMetrics object with members behaving as described in the following
// list:
auto prepared_text = prepare_text(text);
auto metrics = TextMetrics::create(realm()).release_value_but_fixme_should_propagate_errors();
auto metrics = TextMetrics::create(realm());
// FIXME: Use the font that was used to create the glyphs in prepared_text.
auto font = current_font();

View file

@ -60,7 +60,7 @@ class CanvasRenderingContext2D
WEB_PLATFORM_OBJECT(CanvasRenderingContext2D, Bindings::PlatformObject);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasRenderingContext2D>> create(JS::Realm&, HTMLCanvasElement&);
[[nodiscard]] static JS::NonnullGCPtr<CanvasRenderingContext2D> create(JS::Realm&, HTMLCanvasElement&);
virtual ~CanvasRenderingContext2D() override;
virtual void fill_rect(float x, float y, float width, float height) override;

View file

@ -9,9 +9,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<CloseEvent>> CloseEvent::create(JS::Realm& realm, FlyString const& event_name, CloseEventInit const& event_init)
JS::NonnullGCPtr<CloseEvent> CloseEvent::create(JS::Realm& realm, FlyString const& event_name, CloseEventInit const& event_init)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<CloseEvent>(realm, realm, event_name, event_init));
return realm.heap().allocate<CloseEvent>(realm, realm, event_name, event_init);
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<CloseEvent>> CloseEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, CloseEventInit const& event_init)

View file

@ -22,7 +22,7 @@ class CloseEvent : public DOM::Event {
WEB_PLATFORM_OBJECT(CloseEvent, DOM::Event);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CloseEvent>> create(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init = {});
[[nodiscard]] static JS::NonnullGCPtr<CloseEvent> create(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CloseEvent>> construct_impl(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init);
virtual ~CloseEvent() override;

View file

@ -24,7 +24,7 @@ class CustomElementDefinition : public JS::Cell {
static JS::NonnullGCPtr<CustomElementDefinition> create(JS::Realm& realm, String const& name, String const& local_name, WebIDL::CallbackType& constructor, Vector<String>&& observed_attributes, LifecycleCallbacksStorage&& lifecycle_callbacks, bool form_associated, bool disable_internals, bool disable_shadow)
{
return realm.heap().allocate<CustomElementDefinition>(realm, name, local_name, constructor, move(observed_attributes), move(lifecycle_callbacks), form_associated, disable_internals, disable_shadow).release_allocated_value_but_fixme_should_propagate_errors();
return realm.heap().allocate<CustomElementDefinition>(realm, name, local_name, constructor, move(observed_attributes), move(lifecycle_callbacks), form_associated, disable_internals, disable_shadow);
}
~CustomElementDefinition() = default;

View file

@ -16,7 +16,7 @@ namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMParser>> DOMParser::construct_impl(JS::Realm& realm)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<DOMParser>(realm, realm));
return realm.heap().allocate<DOMParser>(realm, realm);
}
DOMParser::DOMParser(JS::Realm& realm)
@ -42,7 +42,7 @@ JS::NonnullGCPtr<DOM::Document> DOMParser::parse_from_string(DeprecatedString co
if (type == Bindings::DOMParserSupportedType::Text_Html) {
// -> "text/html"
// 1. Set document's type to "html".
document = HTML::HTMLDocument::create(realm(), verify_cast<HTML::Window>(relevant_global_object(*this)).associated_document().url()).release_value_but_fixme_should_propagate_errors();
document = HTML::HTMLDocument::create(realm(), verify_cast<HTML::Window>(relevant_global_object(*this)).associated_document().url());
document->set_content_type(Bindings::idl_enum_to_deprecated_string(type));
document->set_document_type(DOM::Document::Type::HTML);
@ -56,7 +56,7 @@ JS::NonnullGCPtr<DOM::Document> DOMParser::parse_from_string(DeprecatedString co
parser->run("about:blank"sv);
} else {
// -> Otherwise
document = DOM::Document::create(realm(), verify_cast<HTML::Window>(relevant_global_object(*this)).associated_document().url()).release_value_but_fixme_should_propagate_errors();
document = DOM::Document::create(realm(), verify_cast<HTML::Window>(relevant_global_object(*this)).associated_document().url());
document->set_content_type(Bindings::idl_enum_to_deprecated_string(type));
// 1. Create an XML parser parse, associated with document, and with XML scripting support disabled.

View file

@ -12,10 +12,10 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMStringMap>> DOMStringMap::create(DOM::Element& element)
JS::NonnullGCPtr<DOMStringMap> DOMStringMap::create(DOM::Element& element)
{
auto& realm = element.realm();
return MUST_OR_THROW_OOM(realm.heap().allocate<DOMStringMap>(realm, element));
return realm.heap().allocate<DOMStringMap>(realm, element);
}
DOMStringMap::DOMStringMap(DOM::Element& element)

View file

@ -17,7 +17,7 @@ class DOMStringMap final : public Bindings::LegacyPlatformObject {
WEB_PLATFORM_OBJECT(DOMStringMap, Bindings::LegacyPlatformObject);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMStringMap>> create(DOM::Element&);
[[nodiscard]] static JS::NonnullGCPtr<DOMStringMap> create(DOM::Element&);
virtual ~DOMStringMap() override;

View file

@ -9,9 +9,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> ErrorEvent::create(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
JS::NonnullGCPtr<ErrorEvent> ErrorEvent::create(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<ErrorEvent>(realm, realm, event_name, event_init));
return realm.heap().allocate<ErrorEvent>(realm, realm, event_name, event_init);
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> ErrorEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)

View file

@ -25,7 +25,7 @@ class ErrorEvent final : public DOM::Event {
WEB_PLATFORM_OBJECT(ErrorEvent, DOM::Event);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> create(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init = {});
[[nodiscard]] static JS::NonnullGCPtr<ErrorEvent> create(JS::Realm&, FlyString const& event_name, ErrorEventInit const& = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> construct_impl(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init);
virtual ~ErrorEvent() override;

View file

@ -65,7 +65,7 @@ static void run_focus_update_steps(Vector<JS::Handle<DOM::Node>> old_chain, Vect
// with related blur target as the related target.
if (blur_event_target) {
// FIXME: Implement the "fire a focus event" spec operation.
auto blur_event = UIEvents::FocusEvent::create(blur_event_target->realm(), HTML::EventNames::blur).release_value_but_fixme_should_propagate_errors();
auto blur_event = UIEvents::FocusEvent::create(blur_event_target->realm(), HTML::EventNames::blur);
blur_event->set_related_target(related_blur_target);
blur_event_target->dispatch_event(blur_event);
}
@ -108,7 +108,7 @@ static void run_focus_update_steps(Vector<JS::Handle<DOM::Node>> old_chain, Vect
// with related focus target as the related target.
if (focus_event_target) {
// FIXME: Implement the "fire a focus event" spec operation.
auto focus_event = UIEvents::FocusEvent::create(focus_event_target->realm(), HTML::EventNames::focus).release_value_but_fixme_should_propagate_errors();
auto focus_event = UIEvents::FocusEvent::create(focus_event_target->realm(), HTML::EventNames::focus);
focus_event->set_related_target(related_focus_target);
focus_event_target->dispatch_event(focus_event);
}

View file

@ -12,7 +12,7 @@ namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<FormDataEvent>> FormDataEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, FormDataEventInit const& event_init)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<FormDataEvent>(realm, realm, event_name, event_init));
return realm.heap().allocate<FormDataEvent>(realm, realm, event_name, event_init);
}
FormDataEvent::FormDataEvent(JS::Realm& realm, FlyString const& event_name, FormDataEventInit const& event_init)

View file

@ -101,7 +101,7 @@ HTMLCanvasElement::HasOrCreatedContext HTMLCanvasElement::create_2d_context()
if (!m_context.has<Empty>())
return m_context.has<JS::NonnullGCPtr<CanvasRenderingContext2D>>() ? HasOrCreatedContext::Yes : HasOrCreatedContext::No;
m_context = CanvasRenderingContext2D::create(realm(), *this).release_value_but_fixme_should_propagate_errors();
m_context = CanvasRenderingContext2D::create(realm(), *this);
return HasOrCreatedContext::Yes;
}
@ -266,7 +266,7 @@ WebIDL::ExceptionOr<void> HTMLCanvasElement::to_blob(JS::NonnullGCPtr<WebIDL::Ca
// 1. If result is non-null, then set result to a new Blob object, created in the relevant realm of this canvas element, representing result. [FILEAPI]
JS::GCPtr<FileAPI::Blob> blob_result;
if (file_result.has_value())
blob_result = TRY(FileAPI::Blob::create(realm(), file_result->buffer, TRY_OR_THROW_OOM(vm(), String::from_utf8(file_result->mime_type))));
blob_result = FileAPI::Blob::create(realm(), file_result->buffer, TRY_OR_THROW_OOM(vm(), String::from_utf8(file_result->mime_type)));
// 2. Invoke callback with « result ».
TRY(WebIDL::invoke_callback(*callback, {}, move(blob_result)));

View file

@ -48,7 +48,7 @@ void HTMLDetailsElement::run_details_notification_task_steps()
// 1. FIXME: If another task has been queued to run the details notification task steps for this details element, then return.
// 2. Fire an event named toggle at the details element.
dispatch_event(Web::DOM::Event::create(realm(), HTML::EventNames::toggle).release_value_but_fixme_should_propagate_errors());
dispatch_event(Web::DOM::Event::create(realm(), HTML::EventNames::toggle));
});
}

View file

@ -20,9 +20,9 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLDocument>> HTMLDocument::construct_impl
return HTMLDocument::create(realm);
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLDocument>> HTMLDocument::create(JS::Realm& realm, AK::URL const& url)
JS::NonnullGCPtr<HTMLDocument> HTMLDocument::create(JS::Realm& realm, AK::URL const& url)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<HTMLDocument>(realm, realm, url));
return realm.heap().allocate<HTMLDocument>(realm, realm, url);
}
}

View file

@ -20,7 +20,7 @@ class HTMLDocument final : public DOM::Document {
public:
virtual ~HTMLDocument() override;
static WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLDocument>> create(JS::Realm&, AK::URL const& url = "about:blank"sv);
[[nodiscard]] static JS::NonnullGCPtr<HTMLDocument> create(JS::Realm&, AK::URL const& url = "about:blank"sv);
WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLDocument>> construct_impl(JS::Realm&);
private:

View file

@ -48,7 +48,7 @@ void HTMLElement::initialize(JS::Realm& realm)
Base::initialize(realm);
set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLElementPrototype>(realm, "HTMLElement"));
m_dataset = MUST(DOMStringMap::create(*this));
m_dataset = DOMStringMap::create(*this);
}
void HTMLElement::visit_edges(Cell::Visitor& visitor)
@ -283,7 +283,7 @@ bool HTMLElement::fire_a_synthetic_pointer_event(FlyString const& type, DOM::Ele
// 1. Let event be the result of creating an event using PointerEvent.
// 2. Initialize event's type attribute to e.
// FIXME: Actually create a PointerEvent!
auto event = UIEvents::MouseEvent::create(realm(), type).release_value_but_fixme_should_propagate_errors();
auto event = UIEvents::MouseEvent::create(realm(), type);
// 3. Initialize event's bubbles and cancelable attributes to true.
event->set_bubbles(true);

View file

@ -101,7 +101,7 @@ WebIDL::ExceptionOr<void> HTMLFormElement::submit_form(JS::NonnullGCPtr<HTMLElem
// cancelable attribute initialized to true.
SubmitEventInit event_init {};
event_init.submitter = submitter_button;
auto submit_event = SubmitEvent::create(realm, EventNames::submit, event_init).release_value_but_fixme_should_propagate_errors();
auto submit_event = SubmitEvent::create(realm, EventNames::submit, event_init);
submit_event->set_bubbles(true);
submit_event->set_cancelable(true);
bool should_continue = dispatch_event(*submit_event);
@ -258,7 +258,7 @@ WebIDL::ExceptionOr<void> HTMLFormElement::submit_form(JS::NonnullGCPtr<HTMLElem
void HTMLFormElement::reset_form()
{
// 1. Let reset be the result of firing an event named reset at form, with the bubbles and cancelable attributes initialized to true.
auto reset_event = DOM::Event::create(realm(), HTML::EventNames::reset).release_value_but_fixme_should_propagate_errors();
auto reset_event = DOM::Event::create(realm(), HTML::EventNames::reset);
reset_event->set_bubbles(true);
reset_event->set_cancelable(true);
@ -411,7 +411,7 @@ JS::NonnullGCPtr<DOM::HTMLCollection> HTMLFormElement::elements() const
if (!m_elements) {
m_elements = DOM::HTMLCollection::create(const_cast<HTMLFormElement&>(*this), DOM::HTMLCollection::Scope::Descendants, [](Element const& element) {
return is_form_control(element);
}).release_value_but_fixme_should_propagate_errors();
});
}
return *m_elements;
}

View file

@ -163,7 +163,7 @@ void run_iframe_load_event_steps(HTML::HTMLIFrameElement& element)
// FIXME: 4. Set childDocument's iframe load in progress flag.
// 5. Fire an event named load at element.
element.dispatch_event(DOM::Event::create(element.realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
element.dispatch_event(DOM::Event::create(element.realm(), HTML::EventNames::load));
// FIXME: 6. Unset childDocument's iframe load in progress flag.
}

View file

@ -391,7 +391,7 @@ ErrorOr<void> HTMLImageElement::update_the_image_data(bool restart_animations, b
// 3. If maybe omit events is not set or previousURL is not equal to urlString, then fire an event named load at the img element.
if (!maybe_omit_events || previous_url != url_string)
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load));
});
// 8. Abort the update the image data algorithm.
@ -434,7 +434,7 @@ after_step_7:
if (
(has_attribute(HTML::AttributeNames::src) || uses_srcset_or_picture())
&& (!maybe_omit_events || m_current_request->current_url() != ""sv)) {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error));
}
});
@ -463,7 +463,7 @@ after_step_7:
// 2. If maybe omit events is not set or previousURL is not equal to selected source, then fire an event named error at the img element.
if (!maybe_omit_events || previous_url != selected_source.value().url)
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error));
});
// 5. Return.
@ -585,7 +585,7 @@ void HTMLImageElement::add_callbacks_to_image_request(NonnullRefPtr<ImageRequest
// 4. If maybe omit events is not set or previousURL is not equal to urlString, then fire an event named load at the img element.
if (!maybe_omit_events || previous_url != url_string)
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load));
set_needs_style_update(true);
document().set_needs_layout();
@ -617,7 +617,7 @@ void HTMLImageElement::add_callbacks_to_image_request(NonnullRefPtr<ImageRequest
// queue an element task on the DOM manipulation task source given the img element
// to fire an event named error at the img element.
if (!maybe_omit_events || previous_url != url_string)
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error));
m_load_event_delayer.clear();
});
@ -726,7 +726,7 @@ void HTMLImageElement::react_to_changes_in_the_environment()
document().set_needs_layout();
// 7. Fire an event named load at the img element.
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load));
});
};
@ -803,7 +803,7 @@ void HTMLImageElement::upgrade_pending_request_to_current_request()
void HTMLImageElement::handle_failed_fetch()
{
// AD-HOC
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error));
}
// https://html.spec.whatwg.org/multipage/rendering.html#restart-the-animation

View file

@ -135,7 +135,7 @@ JS::GCPtr<FileAPI::FileList> HTMLInputElement::files()
return nullptr;
if (!m_selected_files)
m_selected_files = FileAPI::FileList::create(realm(), {}).release_value_but_fixme_should_propagate_errors();
m_selected_files = FileAPI::FileList::create(realm(), {});
return m_selected_files;
}
@ -159,11 +159,11 @@ void HTMLInputElement::update_the_file_selection(JS::NonnullGCPtr<FileAPI::FileL
this->set_files(files.ptr());
// 2. Fire an event named input at the input element, with the bubbles and composed attributes initialized to true.
auto input_event = DOM::Event::create(this->realm(), EventNames::input, { .bubbles = true, .composed = true }).release_value_but_fixme_should_propagate_errors();
auto input_event = DOM::Event::create(this->realm(), EventNames::input, { .bubbles = true, .composed = true });
this->dispatch_event(input_event);
// 3. Fire an event named change at the input element, with the bubbles attribute initialized to true.
auto change_event = DOM::Event::create(this->realm(), EventNames::change, { .bubbles = true }).release_value_but_fixme_should_propagate_errors();
auto change_event = DOM::Event::create(this->realm(), EventNames::change, { .bubbles = true });
this->dispatch_event(change_event);
});
}
@ -250,13 +250,13 @@ WebIDL::ExceptionOr<void> HTMLInputElement::run_input_activation_behavior()
return {};
// 2. Fire an event named input at the element with the bubbles and composed attributes initialized to true.
auto input_event = DOM::Event::create(realm(), HTML::EventNames::input).release_value_but_fixme_should_propagate_errors();
auto input_event = DOM::Event::create(realm(), HTML::EventNames::input);
input_event->set_bubbles(true);
input_event->set_composed(true);
dispatch_event(input_event);
// 3. Fire an event named change at the element with the bubbles attribute initialized to true.
auto change_event = DOM::Event::create(realm(), HTML::EventNames::change).release_value_but_fixme_should_propagate_errors();
auto change_event = DOM::Event::create(realm(), HTML::EventNames::change);
change_event->set_bubbles(true);
dispatch_event(*change_event);
} else if (type_state() == TypeAttributeState::SubmitButton) {
@ -274,7 +274,7 @@ WebIDL::ExceptionOr<void> HTMLInputElement::run_input_activation_behavior()
} else if (type_state() == TypeAttributeState::FileUpload) {
show_the_picker_if_applicable(*this);
} else {
dispatch_event(DOM::Event::create(realm(), EventNames::change).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), EventNames::change));
}
return {};
@ -291,7 +291,7 @@ void HTMLInputElement::did_edit_text_node(Badge<BrowsingContext>)
// NOTE: This is a bit ad-hoc, but basically implements part of "4.10.5.5 Common event behaviors"
// https://html.spec.whatwg.org/multipage/input.html#common-input-element-events
queue_an_element_task(HTML::Task::Source::UserInteraction, [this] {
auto input_event = DOM::Event::create(realm(), HTML::EventNames::input).release_value_but_fixme_should_propagate_errors();
auto input_event = DOM::Event::create(realm(), HTML::EventNames::input);
input_event->set_bubbles(true);
input_event->set_composed(true);
dispatch_event(*input_event);
@ -431,7 +431,7 @@ void HTMLInputElement::create_shadow_tree_if_needed()
break;
}
auto shadow_root = heap().allocate<DOM::ShadowRoot>(realm(), document(), *this, Bindings::ShadowRootMode::Closed).release_allocated_value_but_fixme_should_propagate_errors();
auto shadow_root = heap().allocate<DOM::ShadowRoot>(realm(), document(), *this, Bindings::ShadowRootMode::Closed);
auto initial_value = m_value;
if (initial_value.is_null())
initial_value = DeprecatedString::empty();
@ -445,10 +445,10 @@ void HTMLInputElement::create_shadow_tree_if_needed()
padding: 1px 2px;
)~~~"));
m_placeholder_element = heap().allocate<PlaceholderElement>(realm(), document()).release_allocated_value_but_fixme_should_propagate_errors();
m_placeholder_element = heap().allocate<PlaceholderElement>(realm(), document());
MUST(m_placeholder_element->style_for_bindings()->set_property(CSS::PropertyID::Height, "1lh"sv));
m_placeholder_text_node = heap().allocate<DOM::Text>(realm(), document(), initial_value).release_allocated_value_but_fixme_should_propagate_errors();
m_placeholder_text_node = heap().allocate<DOM::Text>(realm(), document(), initial_value);
m_placeholder_text_node->set_data(attribute(HTML::AttributeNames::placeholder));
m_placeholder_text_node->set_owner_input_element({}, *this);
MUST(m_placeholder_element->append_child(*m_placeholder_text_node));
@ -457,7 +457,7 @@ void HTMLInputElement::create_shadow_tree_if_needed()
m_inner_text_element = DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(m_inner_text_element->style_for_bindings()->set_property(CSS::PropertyID::Height, "1lh"sv));
m_text_node = heap().allocate<DOM::Text>(realm(), document(), initial_value).release_allocated_value_but_fixme_should_propagate_errors();
m_text_node = heap().allocate<DOM::Text>(realm(), document(), initial_value);
m_text_node->set_always_editable(m_type != TypeAttributeState::FileUpload);
m_text_node->set_owner_input_element({}, *this);
@ -485,7 +485,7 @@ void HTMLInputElement::did_lose_focus()
// The change event fires when the value is committed, if that makes sense for the control,
// or else when the control loses focus
queue_an_element_task(HTML::Task::Source::UserInteraction, [this] {
auto change_event = DOM::Event::create(realm(), HTML::EventNames::change).release_value_but_fixme_should_propagate_errors();
auto change_event = DOM::Event::create(realm(), HTML::EventNames::change);
change_event->set_bubbles(true);
dispatch_event(change_event);
});
@ -842,7 +842,7 @@ void HTMLInputElement::reset_algorithm()
m_checked = has_attribute(AttributeNames::checked);
// empty the list of selected files,
m_selected_files = FileAPI::FileList::create(realm(), {}).release_value_but_fixme_should_propagate_errors();
m_selected_files = FileAPI::FileList::create(realm(), {});
// and then invoke the value sanitization algorithm, if the type attribute's current state defines one.
m_value = value_sanitization_algorithm(m_value);

View file

@ -133,7 +133,7 @@ void HTMLLinkElement::resource_did_fail()
{
dbgln_if(CSS_LOADER_DEBUG, "HTMLLinkElement: Resource did fail. URL: {}", resource()->url());
if (m_relationship & Relationship::Preload) {
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error));
}
}
@ -145,7 +145,7 @@ void HTMLLinkElement::resource_did_load()
m_document_load_event_delayer.clear();
}
if (m_relationship & Relationship::Preload) {
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::load));
}
}
@ -353,13 +353,13 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru
if (!decoder.has_value()) {
// If we don't support the encoding yet, let's error out instead of trying to decode it as something it's most likely not.
dbgln("FIXME: Style sheet encoding '{}' is not supported yet", encoding);
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error));
} else {
auto const& encoded_string = body_bytes.get<ByteBuffer>();
auto maybe_decoded_string = TextCodec::convert_input_to_utf8_using_given_decoder_unless_there_is_a_byte_order_mark(*decoder, encoded_string);
if (maybe_decoded_string.is_error()) {
dbgln("Style sheet {} claimed to be '{}' but decoding failed", response.url().value_or(AK::URL()), encoding);
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error));
} else {
auto const decoded_string = maybe_decoded_string.release_value();
m_loaded_style_sheet = parse_css_stylesheet(CSS::Parser::ParsingContext(document(), *response.url()), decoded_string);
@ -373,13 +373,13 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru
}
// 2. Fire an event named load at el.
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::load));
}
}
}
// 5. Otherwise, fire an event named error at el.
else {
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error));
}
// FIXME: 6. If el contributes a script-blocking style sheet, then:

View file

@ -52,9 +52,9 @@ void HTMLMediaElement::initialize(JS::Realm& realm)
Base::initialize(realm);
set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLMediaElementPrototype>(realm, "HTMLMediaElement"));
m_audio_tracks = MUST(realm.heap().allocate<AudioTrackList>(realm, realm));
m_video_tracks = MUST(realm.heap().allocate<VideoTrackList>(realm, realm));
m_document_observer = MUST(realm.heap().allocate<DOM::DocumentObserver>(realm, realm, document()));
m_audio_tracks = realm.heap().allocate<AudioTrackList>(realm, realm);
m_video_tracks = realm.heap().allocate<VideoTrackList>(realm, realm);
m_document_observer = realm.heap().allocate<DOM::DocumentObserver>(realm, realm, document());
// https://html.spec.whatwg.org/multipage/media.html#playing-the-media-resource:media-element-82
m_document_observer->document_became_inactive = [this]() {
@ -136,7 +136,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::set_decoder_error(String error_messa
m_fetch_controller->stop_fetch();
// 2. Set the error attribute to the result of creating a MediaError with MEDIA_ERR_DECODE.
m_error = TRY(vm.heap().allocate<MediaError>(realm, realm, MediaError::Code::Decode, move(error_message)));
m_error = vm.heap().allocate<MediaError>(realm, realm, MediaError::Code::Decode, move(error_message));
// 3. Set the element's networkState attribute to the NETWORK_IDLE value.
m_network_state = NetworkState::Idle;
@ -145,7 +145,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::set_decoder_error(String error_messa
m_delaying_the_load_event.clear();
// 5. Fire an event named error at the media element.
dispatch_event(TRY(DOM::Event::create(realm, HTML::EventNames::error)));
dispatch_event(DOM::Event::create(realm, HTML::EventNames::error));
// FIXME: 6. Abort the overall resource selection algorithm.
@ -153,7 +153,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::set_decoder_error(String error_messa
}
// https://html.spec.whatwg.org/multipage/media.html#dom-media-buffered
WebIDL::ExceptionOr<JS::NonnullGCPtr<TimeRanges>> HTMLMediaElement::buffered() const
JS::NonnullGCPtr<TimeRanges> HTMLMediaElement::buffered() const
{
auto& realm = this->realm();
auto& vm = realm.vm();
@ -162,7 +162,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<TimeRanges>> HTMLMediaElement::buffered() c
// media resource, if any, that the user agent has buffered, at the time the attribute is evaluated. Users agents
// must accurately determine the ranges available, even for media streams where this can only be determined by
// tedious inspection.
return TRY(vm.heap().allocate<TimeRanges>(realm, realm));
return vm.heap().allocate<TimeRanges>(realm, realm);
}
// https://html.spec.whatwg.org/multipage/media.html#dom-navigator-canplaytype
@ -286,7 +286,7 @@ void HTMLMediaElement::set_current_playback_position(double playback_position)
// NOTE: Invoking the following steps is not listed in the spec. Rather, the spec just describes the scenario in
// which these steps should be invoked, which is when we've reached the end of the media playback.
if (m_current_playback_position == m_duration)
reached_end_of_media_playback().release_value_but_fixme_should_propagate_errors();
reached_end_of_media_playback();
}
// https://html.spec.whatwg.org/multipage/media.html#dom-media-duration
@ -319,7 +319,7 @@ void HTMLMediaElement::set_duration(double duration)
// ends up being greater than the time of the end of the media resource, then the user agent must also seek to the time of the end of the media resource.
if (!isnan(duration)) {
queue_a_media_element_task([this] {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::durationchange).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::durationchange));
});
if (m_current_playback_position > duration)
@ -422,7 +422,7 @@ void HTMLMediaElement::volume_or_muted_attribute_changed()
// agent must queue a media element task given the media element to fire an event named volumechange at the media
// element.
queue_a_media_element_task([this] {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::volumechange).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::volumechange));
});
// FIXME: Then, if the media element is not allowed to play, the user agent must run the internal pause steps for the media element.
@ -477,7 +477,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::load_element()
// fire an event named abort at the media element.
if (m_network_state == NetworkState::Loading || m_network_state == NetworkState::Idle) {
queue_a_media_element_task([this] {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::abort).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::abort));
});
}
@ -485,7 +485,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::load_element()
if (m_network_state != NetworkState::Empty) {
// 1. Queue a media element task given the media element to fire an event named emptied at the media element.
queue_a_media_element_task([this] {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::emptied).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::emptied));
});
// 2. If a fetching process is in progress for the media element, the user agent should stop it.
@ -525,7 +525,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::load_element()
// If this changed the official playback position, then queue a media element task given the media element to fire an
// event named timeupdate at the media element.
queue_a_media_element_task([this] {
dispatch_time_update_event().release_value_but_fixme_should_propagate_errors();
dispatch_time_update_event();
});
}
@ -632,7 +632,7 @@ private:
{
// 9. Failed with elements: Queue a media element task given the media element to fire an event named error at candidate.
m_media_element->queue_a_media_element_task([this]() {
m_candidate->dispatch_event(DOM::Event::create(m_candidate->realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
m_candidate->dispatch_event(DOM::Event::create(m_candidate->realm(), HTML::EventNames::error));
});
// FIXME: 10. Await a stable state. The synchronous section consists of all the remaining steps of this algorithm until
@ -788,7 +788,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::select_resource()
// 8. ⌛ Queue a media element task given the media element to fire an event named loadstart at the media element.
queue_a_media_element_task([this] {
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::loadstart).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::loadstart));
});
// 9. Run the appropriate steps from the following list:
@ -878,7 +878,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::select_resource()
// NOTE: We do not bother with maintaining this pointer. We inspect the DOM tree on the fly, rather than dealing
// with the headache of auto-updating this pointer as the DOM changes.
m_source_element_selector = TRY(vm.heap().allocate<SourceElementSelector>(realm, *this, *candidate));
m_source_element_selector = vm.heap().allocate<SourceElementSelector>(realm, *this, *candidate);
TRY(m_source_element_selector->process_candidate());
break;
@ -1081,7 +1081,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
// -> If the media resource is found to have an audio track
if (!audio_loader.is_error()) {
// 1. Create an AudioTrack object to represent the audio track.
audio_track = TRY(vm.heap().allocate<AudioTrack>(realm, realm, *this, audio_loader.release_value()));
audio_track = vm.heap().allocate<AudioTrack>(realm, realm, *this, audio_loader.release_value());
// 2. Update the media element's audioTracks attribute's AudioTrackList object with the new AudioTrack object.
TRY_OR_THROW_OOM(vm, m_audio_tracks->add_track({}, *audio_track));
@ -1106,14 +1106,14 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
TrackEventInit event_init {};
event_init.track = JS::make_handle(audio_track);
auto event = TRY(TrackEvent::create(realm, HTML::EventNames::addtrack, move(event_init)));
auto event = TrackEvent::create(realm, HTML::EventNames::addtrack, move(event_init));
m_audio_tracks->dispatch_event(event);
}
// -> If the media resource is found to have a video track
if (!playback_manager.is_error()) {
// 1. Create a VideoTrack object to represent the video track.
video_track = TRY(vm.heap().allocate<VideoTrack>(realm, realm, *this, playback_manager.release_value()));
video_track = vm.heap().allocate<VideoTrack>(realm, realm, *this, playback_manager.release_value());
// 2. Update the media element's videoTracks attribute's VideoTrackList object with the new VideoTrack object.
TRY_OR_THROW_OOM(vm, m_video_tracks->add_track({}, *video_track));
@ -1139,7 +1139,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
TrackEventInit event_init {};
event_init.track = JS::make_handle(video_track);
auto event = TRY(TrackEvent::create(realm, HTML::EventNames::addtrack, move(event_init)));
auto event = TrackEvent::create(realm, HTML::EventNames::addtrack, move(event_init));
m_video_tracks->dispatch_event(event);
}
@ -1170,7 +1170,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
video_element.set_video_height(video_track->pixel_height());
queue_a_media_element_task([this] {
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::resize).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::resize));
});
} else {
auto duration = audio_track ? audio_track->duration() : video_track->duration();
@ -1208,11 +1208,11 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
// -> Once the entire media resource has been fetched (but potentially before any of it has been decoded)
if (audio_track != nullptr || video_track != nullptr) {
// Fire an event named progress at the media element.
dispatch_event(TRY(DOM::Event::create(this->realm(), HTML::EventNames::progress)));
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::progress));
// Set the networkState to NETWORK_IDLE and fire an event named suspend at the media element.
m_network_state = NetworkState::Idle;
dispatch_event(TRY(DOM::Event::create(this->realm(), HTML::EventNames::suspend)));
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::suspend));
// If the user agent ever discards any media data and then needs to resume the network activity to obtain it again, then it must queue a media
// element task given the media element to set the networkState to NETWORK_LOADING.
@ -1234,7 +1234,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::handle_media_source_failure(Span<JS:
auto& vm = realm.vm();
// 1. Set the error attribute to the result of creating a MediaError with MEDIA_ERR_SRC_NOT_SUPPORTED.
m_error = TRY(vm.heap().allocate<MediaError>(realm, realm, MediaError::Code::SrcNotSupported, move(error_message)));
m_error = vm.heap().allocate<MediaError>(realm, realm, MediaError::Code::SrcNotSupported, move(error_message));
// 2. Forget the media element's media-resource-specific tracks.
forget_media_resource_specific_tracks();
@ -1246,7 +1246,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::handle_media_source_failure(Span<JS:
set_show_poster(true);
// 5. Fire an event named error at the media element.
dispatch_event(TRY(DOM::Event::create(realm, HTML::EventNames::error)));
dispatch_event(DOM::Event::create(realm, HTML::EventNames::error));
// 6. Reject pending play promises with promises and a "NotSupportedError" DOMException.
reject_pending_play_promises<WebIDL::NotSupportedError>(promises, "Media is not supported"_fly_string);
@ -1286,7 +1286,7 @@ void HTMLMediaElement::set_ready_state(ReadyState ready_state)
if (m_ready_state == ReadyState::HaveNothing && ready_state == ReadyState::HaveMetadata) {
// Queue a media element task given the media element to fire an event named loadedmetadata at the element.
queue_a_media_element_task([this] {
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::loadedmetadata).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::loadedmetadata));
});
return;
@ -1300,7 +1300,7 @@ void HTMLMediaElement::set_ready_state(ReadyState ready_state)
m_first_data_load_event_since_load_start = false;
queue_a_media_element_task([this] {
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::loadeddata).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::loadeddata));
});
}
@ -1327,7 +1327,7 @@ void HTMLMediaElement::set_ready_state(ReadyState ready_state)
if (m_ready_state <= ReadyState::HaveCurrentData && ready_state == ReadyState::HaveFutureData) {
// The user agent must queue a media element task given the media element to fire an event named canplay at the element.
queue_a_media_element_task([this] {
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::canplay).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::canplay));
});
// If the element's paused attribute is false, the user agent must notify about playing for the element.
@ -1343,7 +1343,7 @@ void HTMLMediaElement::set_ready_state(ReadyState ready_state)
// named canplay at the element, and, if the element's paused attribute is false, notify about playing for the element.
if (m_ready_state <= ReadyState::HaveCurrentData) {
queue_a_media_element_task([this] {
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::canplay).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::canplay));
});
if (!paused())
@ -1352,7 +1352,7 @@ void HTMLMediaElement::set_ready_state(ReadyState ready_state)
// The user agent must queue a media element task given the media element to fire an event named canplaythrough at the element.
queue_a_media_element_task([this] {
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::canplaythrough).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::canplaythrough));
});
// If the element is not eligible for autoplay, then the user agent must abort these substeps.
@ -1372,7 +1372,7 @@ void HTMLMediaElement::set_ready_state(ReadyState ready_state)
// Queue a media element task given the element to fire an event named play at the element.
queue_a_media_element_task([this]() {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::play).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::play));
});
// Notify about playing for the element.
@ -1416,14 +1416,14 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::play_element()
// 3. Queue a media element task given the media element to fire an event named play at the element.
queue_a_media_element_task([this]() {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::play).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::play));
});
// 4. If the media element's readyState attribute has the value HAVE_NOTHING, HAVE_METADATA, or HAVE_CURRENT_DATA,
// queue a media element task given the media element to fire an event named waiting at the element.
if (m_ready_state == ReadyState::HaveNothing || m_ready_state == ReadyState::HaveMetadata || m_ready_state == ReadyState::HaveCurrentData) {
queue_a_media_element_task([this]() {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::waiting).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::waiting));
});
}
// Otherwise, the media element's readyState attribute has the value HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA:
@ -1469,10 +1469,10 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::pause_element()
auto& realm = this->realm();
// 1. Fire an event named timeupdate at the element.
dispatch_time_update_event().release_value_but_fixme_should_propagate_errors();
dispatch_time_update_event();
// 2. Fire an event named pause at the element.
dispatch_event(DOM::Event::create(realm, HTML::EventNames::pause).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm, HTML::EventNames::pause));
// 3. Reject pending play promises with promises and an "AbortError" DOMException.
reject_pending_play_promises<WebIDL::AbortError>(promises, "Media playback was paused"_fly_string);
@ -1529,7 +1529,7 @@ void HTMLMediaElement::seek_element(double playback_position, MediaSeekMode seek
// 10. Queue a media element task given the media element to fire an event named seeking at the element.
queue_a_media_element_task([this]() {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::seeking).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::seeking));
});
// 11. Set the current playback position to the new playback position.
@ -1552,12 +1552,12 @@ void HTMLMediaElement::seek_element(double playback_position, MediaSeekMode seek
// 16. ⌛ Queue a media element task given the media element to fire an event named timeupdate at the element.
queue_a_media_element_task([this]() {
dispatch_time_update_event().release_value_but_fixme_should_propagate_errors();
dispatch_time_update_event();
});
// 17. ⌛ Queue a media element task given the media element to fire an event named seeked at the element.
queue_a_media_element_task([this]() {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::seeked).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::seeked));
});
}
@ -1570,7 +1570,7 @@ void HTMLMediaElement::notify_about_playing()
// 2. Queue a media element task given the element and the following steps:
queue_a_media_element_task([this, promises = move(promises)]() {
// 1. Fire an event named playing at the element.
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::playing).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::playing));
// 2. Resolve pending play promises with promises.
resolve_pending_play_promises(promises);
@ -1690,7 +1690,7 @@ bool HTMLMediaElement::has_ended_playback() const
}
// https://html.spec.whatwg.org/multipage/media.html#reaches-the-end
WebIDL::ExceptionOr<void> HTMLMediaElement::reached_end_of_media_playback()
void HTMLMediaElement::reached_end_of_media_playback()
{
// 1. If the media element has a loop attribute specified, then seek to the earliest possible position of the media resource and return.
if (has_attribute(HTML::AttributeNames::loop)) {
@ -1700,8 +1700,6 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::reached_end_of_media_playback()
// playing manually to actually loop. Note that we don't need to update any HTMLMediaElement state as
// it hasn't left the playing state by this point.
on_playing();
return {};
}
// 2. As defined above, the ended IDL attribute starts returning true once the event loop returns to step 1.
@ -1709,7 +1707,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::reached_end_of_media_playback()
// 3. Queue a media element task given the media element and the following steps:
queue_a_media_element_task([this]() mutable {
// 1. Fire an event named timeupdate at the media element.
dispatch_time_update_event().release_value_but_fixme_should_propagate_errors();
dispatch_time_update_event();
// 2. If the media element has ended playback, the direction of playback is forwards, and paused is false, then:
// FIXME: Detect playback direction.
@ -1718,7 +1716,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::reached_end_of_media_playback()
set_paused(true);
// 2. Fire an event named pause at the media element.
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::pause).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::pause));
// 3. Take pending play promises and reject pending play promises with the result and an "AbortError" DOMException.
auto promises = take_pending_play_promises();
@ -1727,20 +1725,17 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::reached_end_of_media_playback()
});
// 4. Fire an event named ended at the media element.
dispatch_event(TRY(DOM::Event::create(realm(), HTML::EventNames::ended)));
return {};
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::ended));
}
WebIDL::ExceptionOr<void> HTMLMediaElement::dispatch_time_update_event()
void HTMLMediaElement::dispatch_time_update_event()
{
ScopeGuard guard { [this] { m_running_time_update_event_handler = false; } };
m_running_time_update_event_handler = true;
m_last_time_update_event_time = MonotonicTime::now();
dispatch_event(TRY(DOM::Event::create(realm(), HTML::EventNames::timeupdate)));
return {};
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::timeupdate));
}
// https://html.spec.whatwg.org/multipage/media.html#time-marches-on
@ -1775,7 +1770,7 @@ void HTMLMediaElement::time_marches_on(TimeMarchesOnReason reason)
if (dispatch_event) {
queue_a_media_element_task([this]() {
dispatch_time_update_event().release_value_but_fixme_should_propagate_errors();
dispatch_time_update_event();
});
}
}

View file

@ -56,7 +56,7 @@ public:
};
NetworkState network_state() const { return m_network_state; }
WebIDL::ExceptionOr<JS::NonnullGCPtr<TimeRanges>> buffered() const;
[[nodiscard]] JS::NonnullGCPtr<TimeRanges> buffered() const;
WebIDL::ExceptionOr<Bindings::CanPlayTypeResult> can_play_type(DeprecatedString const& type) const;
@ -177,9 +177,9 @@ private:
bool is_eligible_for_autoplay() const;
bool has_ended_playback() const;
WebIDL::ExceptionOr<void> reached_end_of_media_playback();
void reached_end_of_media_playback();
WebIDL::ExceptionOr<void> dispatch_time_update_event();
void dispatch_time_update_event();
enum class TimeMarchesOnReason {
NormalPlayback,

View file

@ -125,7 +125,7 @@ void HTMLObjectElement::queue_element_task_to_run_object_representation_steps()
// 3. If that failed, fire an event named error at the element, then jump to the step below labeled fallback.
if (!url.is_valid()) {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error));
return run_object_representation_fallback_steps();
}
@ -152,7 +152,7 @@ void HTMLObjectElement::queue_element_task_to_run_object_representation_steps()
void HTMLObjectElement::resource_did_fail()
{
// 4.7. If the load failed (e.g. there was an HTTP 404 error, there was a DNS error), fire an event named error at the element, then jump to the step below labeled fallback.
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error));
run_object_representation_fallback_steps();
}
@ -290,7 +290,7 @@ void HTMLObjectElement::run_object_representation_completed_steps(Representation
// 4.11. If the object element does not represent its nested browsing context, then once the resource is completely loaded, queue an element task on the DOM manipulation task source given the object element to fire an event named load at the element.
if (representation != Representation::NestedBrowsingContext) {
queue_an_element_task(HTML::Task::Source::DOMManipulation, [&]() {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load));
});
}

View file

@ -13,9 +13,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLOptionsCollection>> HTMLOptionsCollection::create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter)
JS::NonnullGCPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter)
{
return MUST_OR_THROW_OOM(root.heap().allocate<HTMLOptionsCollection>(root.realm(), root, move(filter)));
return root.heap().allocate<HTMLOptionsCollection>(root.realm(), root, move(filter));
}
HTMLOptionsCollection::HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter)

View file

@ -19,7 +19,7 @@ class HTMLOptionsCollection final : public DOM::HTMLCollection {
WEB_PLATFORM_OBJECT(HTMLOptionsCollection, DOM::HTMLCollection);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLOptionsCollection>> create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);
[[nodiscard]] static JS::NonnullGCPtr<HTMLOptionsCollection> create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);
virtual ~HTMLOptionsCollection() override;
WebIDL::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {});

View file

@ -86,7 +86,7 @@ void HTMLScriptElement::execute_script()
// 3. If el's result is null, then fire an event named error at el, and return.
if (m_result.has<ResultState::Null>()) {
dbgln("HTMLScriptElement: Refusing to run script because the element's result is null.");
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error));
return;
}
@ -137,7 +137,7 @@ void HTMLScriptElement::execute_script()
// 8. If el's from an external file is true, then fire an event named load at el.
if (m_from_an_external_file)
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load));
}
// https://html.spec.whatwg.org/multipage/scripting.html#prepare-a-script
@ -340,7 +340,7 @@ void HTMLScriptElement::prepare_script()
if (m_script_type == ScriptType::ImportMap) {
// then queue an element task on the DOM manipulation task source given el to fire an event named error at el, and return.
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error));
});
return;
}
@ -352,7 +352,7 @@ void HTMLScriptElement::prepare_script()
if (src.is_empty()) {
dbgln("HTMLScriptElement: Refusing to run script because the src attribute is empty.");
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error));
});
return;
}
@ -367,7 +367,7 @@ void HTMLScriptElement::prepare_script()
if (!url.is_valid()) {
dbgln("HTMLScriptElement: Refusing to run script because the src URL '{}' is invalid.", url);
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] {
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error));
});
return;
}

View file

@ -42,7 +42,7 @@ JS::GCPtr<HTMLOptionsCollection> const& HTMLSelectElement::options()
// the select element, and all the option element children of all the optgroup element children
// of the select element, in tree order.
return is<HTMLOptionElement>(element);
}).release_value_but_fixme_should_propagate_errors();
});
}
return m_options;
}

View file

@ -272,7 +272,7 @@ JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableElement::t_bodies()
if (!m_t_bodies) {
m_t_bodies = DOM::HTMLCollection::create(*this, DOM::HTMLCollection::Scope::Children, [](DOM::Element const& element) {
return element.local_name() == TagNames::tbody;
}).release_value_but_fixme_should_propagate_errors();
});
}
return *m_t_bodies;
}
@ -329,7 +329,7 @@ JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableElement::rows()
}
return false;
}).release_value_but_fixme_should_propagate_errors();
});
}
return *m_rows;
}

View file

@ -65,7 +65,7 @@ JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableRowElement::cells() const
if (!m_cells) {
m_cells = DOM::HTMLCollection::create(const_cast<HTMLTableRowElement&>(*this), DOM::HTMLCollection::Scope::Children, [](Element const& element) {
return is<HTMLTableCellElement>(element);
}).release_value_but_fixme_should_propagate_errors();
});
}
return *m_cells;
}

View file

@ -41,7 +41,7 @@ JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableSectionElement::rows() const
if (!m_rows) {
m_rows = DOM::HTMLCollection::create(const_cast<HTMLTableSectionElement&>(*this), DOM::HTMLCollection::Scope::Children, [](Element const& element) {
return is<HTMLTableRowElement>(element);
}).release_value_but_fixme_should_propagate_errors();
});
}
return *m_rows;
}

View file

@ -22,7 +22,7 @@ void HTMLTemplateElement::initialize(JS::Realm& realm)
Base::initialize(realm);
set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTemplateElementPrototype>(realm, "HTMLTemplateElement"));
m_content = MUST(heap().allocate<DOM::DocumentFragment>(realm, m_document->appropriate_template_contents_owner_document()));
m_content = heap().allocate<DOM::DocumentFragment>(realm, m_document->appropriate_template_contents_owner_document());
m_content->set_host(this);
}

View file

@ -10,9 +10,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<History>> History::create(JS::Realm& realm, DOM::Document& document)
JS::NonnullGCPtr<History> History::create(JS::Realm& realm, DOM::Document& document)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<History>(realm, realm, document));
return realm.heap().allocate<History>(realm, realm, document);
}
History::History(JS::Realm& realm, DOM::Document& document)

View file

@ -16,7 +16,7 @@ class History final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(History, Bindings::PlatformObject);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<History>> create(JS::Realm&, DOM::Document&);
[[nodiscard]] static JS::NonnullGCPtr<History> create(JS::Realm&, DOM::Document&);
virtual ~History() override;

View file

@ -28,7 +28,7 @@ JS::GCPtr<ImageData> ImageData::create_with_size(JS::Realm& realm, int width, in
auto bitmap_or_error = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGBA8888, Gfx::IntSize(width, height), 1, width * sizeof(u32), data->data().data());
if (bitmap_or_error.is_error())
return nullptr;
return realm.heap().allocate<ImageData>(realm, realm, bitmap_or_error.release_value(), move(data)).release_allocated_value_but_fixme_should_propagate_errors();
return realm.heap().allocate<ImageData>(realm, realm, bitmap_or_error.release_value(), move(data));
}
ImageData::ImageData(JS::Realm& realm, NonnullRefPtr<Gfx::Bitmap> bitmap, JS::NonnullGCPtr<JS::Uint8ClampedArray> data)

View file

@ -13,17 +13,17 @@ namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageChannel>> MessageChannel::construct_impl(JS::Realm& realm)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<MessageChannel>(realm, realm));
return realm.heap().allocate<MessageChannel>(realm, realm);
}
MessageChannel::MessageChannel(JS::Realm& realm)
: PlatformObject(realm)
{
// 1. Set this's port 1 to a new MessagePort in this's relevant Realm.
m_port1 = MessagePort::create(realm).release_value_but_fixme_should_propagate_errors();
m_port1 = MessagePort::create(realm);
// 2. Set this's port 2 to a new MessagePort in this's relevant Realm.
m_port2 = MessagePort::create(realm).release_value_but_fixme_should_propagate_errors();
m_port2 = MessagePort::create(realm);
// 3. Entangle this's port 1 and this's port 2.
m_port1->entangle_with(*m_port2);

View file

@ -9,9 +9,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> MessageEvent::create(JS::Realm& realm, FlyString const& event_name, MessageEventInit const& event_init)
JS::NonnullGCPtr<MessageEvent> MessageEvent::create(JS::Realm& realm, FlyString const& event_name, MessageEventInit const& event_init)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<MessageEvent>(realm, realm, event_name, event_init));
return realm.heap().allocate<MessageEvent>(realm, realm, event_name, event_init);
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> MessageEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MessageEventInit const& event_init)

View file

@ -22,8 +22,8 @@ class MessageEvent : public DOM::Event {
WEB_PLATFORM_OBJECT(MessageEvent, DOM::Event);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> create(JS::Realm&, FlyString const& event_name, MessageEventInit const& event_init = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> construct_impl(JS::Realm&, FlyString const& event_name, MessageEventInit const& event_init);
[[nodiscard]] static JS::NonnullGCPtr<MessageEvent> create(JS::Realm&, FlyString const& event_name, MessageEventInit const& = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MessageEvent>> construct_impl(JS::Realm&, FlyString const& event_name, MessageEventInit const&);
MessageEvent(JS::Realm&, FlyString const& event_name, MessageEventInit const& event_init);
virtual ~MessageEvent() override;

View file

@ -14,9 +14,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<MessagePort>> MessagePort::create(JS::Realm& realm)
JS::NonnullGCPtr<MessagePort> MessagePort::create(JS::Realm& realm)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<MessagePort>(realm, realm));
return realm.heap().allocate<MessagePort>(realm, realm);
}
MessagePort::MessagePort(JS::Realm& realm)
@ -97,7 +97,7 @@ void MessagePort::post_message(JS::Value message)
MessageEventInit event_init {};
event_init.data = message;
event_init.origin = "<origin>"_string;
target_port->dispatch_event(MessageEvent::create(target_port->realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors());
target_port->dispatch_event(MessageEvent::create(target_port->realm(), HTML::EventNames::message, event_init));
}));
}

View file

@ -27,7 +27,7 @@ class MessagePort final : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(MessagePort, DOM::EventTarget);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MessagePort>> create(JS::Realm&);
[[nodiscard]] static JS::NonnullGCPtr<MessagePort> create(JS::Realm&);
virtual ~MessagePort() override;

View file

@ -15,9 +15,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<Navigator>> Navigator::create(JS::Realm& realm)
JS::NonnullGCPtr<Navigator> Navigator::create(JS::Realm& realm)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<Navigator>(realm, realm));
return realm.heap().allocate<Navigator>(realm, realm);
}
Navigator::Navigator(JS::Realm& realm)
@ -59,17 +59,17 @@ void Navigator::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_plugin_array);
}
JS::ThrowCompletionOr<JS::NonnullGCPtr<MimeTypeArray>> Navigator::mime_types()
JS::NonnullGCPtr<MimeTypeArray> Navigator::mime_types()
{
if (!m_mime_type_array)
m_mime_type_array = TRY(heap().allocate<MimeTypeArray>(realm(), realm()));
m_mime_type_array = heap().allocate<MimeTypeArray>(realm(), realm());
return *m_mime_type_array;
}
JS::ThrowCompletionOr<JS::NonnullGCPtr<PluginArray>> Navigator::plugins()
JS::NonnullGCPtr<PluginArray> Navigator::plugins()
{
if (!m_plugin_array)
m_plugin_array = TRY(heap().allocate<PluginArray>(realm(), realm()));
m_plugin_array = heap().allocate<PluginArray>(realm(), realm());
return *m_plugin_array;
}

View file

@ -24,7 +24,7 @@ class Navigator : public Bindings::PlatformObject
WEB_PLATFORM_OBJECT(Navigator, Bindings::PlatformObject);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Navigator>> create(JS::Realm&);
[[nodiscard]] static JS::NonnullGCPtr<Navigator> create(JS::Realm&);
// FIXME: Implement NavigatorContentUtilsMixin
@ -41,8 +41,8 @@ public:
bool webdriver() const;
JS::ThrowCompletionOr<JS::NonnullGCPtr<MimeTypeArray>> mime_types();
JS::ThrowCompletionOr<JS::NonnullGCPtr<PluginArray>> plugins();
[[nodiscard]] JS::NonnullGCPtr<MimeTypeArray> mime_types();
[[nodiscard]] JS::NonnullGCPtr<PluginArray> plugins();
virtual ~Navigator() override;

View file

@ -9,9 +9,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<PageTransitionEvent>> PageTransitionEvent::create(JS::Realm& realm, FlyString const& event_name, PageTransitionEventInit const& event_init)
JS::NonnullGCPtr<PageTransitionEvent> PageTransitionEvent::create(JS::Realm& realm, FlyString const& event_name, PageTransitionEventInit const& event_init)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<PageTransitionEvent>(realm, realm, event_name, event_init));
return realm.heap().allocate<PageTransitionEvent>(realm, realm, event_name, event_init);
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<PageTransitionEvent>> PageTransitionEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, PageTransitionEventInit const& event_init)

View file

@ -19,8 +19,8 @@ class PageTransitionEvent final : public DOM::Event {
WEB_PLATFORM_OBJECT(PageTransitionEvent, DOM::Event);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<PageTransitionEvent>> create(JS::Realm&, FlyString const& event_name, PageTransitionEventInit const& event_init);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<PageTransitionEvent>> construct_impl(JS::Realm&, FlyString const& event_name, PageTransitionEventInit const& event_init);
[[nodiscard]] static JS::NonnullGCPtr<PageTransitionEvent> create(JS::Realm&, FlyString const& event_name, PageTransitionEventInit const&);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<PageTransitionEvent>> construct_impl(JS::Realm&, FlyString const& event_name, PageTransitionEventInit const&);
PageTransitionEvent(JS::Realm&, FlyString const& event_name, PageTransitionEventInit const& event_init);

View file

@ -109,7 +109,7 @@ JS::GCPtr<DOM::Attr> prescan_get_attribute(DOM::Document& document, ByteBuffer c
} else if (input[position] == '\t' || input[position] == '\n' || input[position] == '\f' || input[position] == '\r' || input[position] == ' ')
goto spaces;
else if (input[position] == '/' || input[position] == '>')
return *DOM::Attr::create(document, attribute_name.to_deprecated_string(), "").release_value_but_fixme_should_propagate_errors();
return *DOM::Attr::create(document, attribute_name.to_deprecated_string(), "");
else
attribute_name.append_as_lowercase(input[position]);
++position;
@ -121,7 +121,7 @@ spaces:
if (!prescan_skip_whitespace_and_slashes(input, position))
return {};
if (input[position] != '=')
return DOM::Attr::create(document, attribute_name.to_deprecated_string(), "").release_value_but_fixme_should_propagate_errors();
return DOM::Attr::create(document, attribute_name.to_deprecated_string(), "");
++position;
value:
@ -134,13 +134,13 @@ value:
++position;
for (; !prescan_should_abort(input, position); ++position) {
if (input[position] == quote_character)
return DOM::Attr::create(document, attribute_name.to_deprecated_string(), attribute_value.to_deprecated_string()).release_value_but_fixme_should_propagate_errors();
return DOM::Attr::create(document, attribute_name.to_deprecated_string(), attribute_value.to_deprecated_string());
else
attribute_value.append_as_lowercase(input[position]);
}
return {};
} else if (input[position] == '>')
return DOM::Attr::create(document, attribute_name.to_deprecated_string(), "").release_value_but_fixme_should_propagate_errors();
return DOM::Attr::create(document, attribute_name.to_deprecated_string(), "");
else
attribute_value.append_as_lowercase(input[position]);
@ -150,7 +150,7 @@ value:
for (; !prescan_should_abort(input, position); ++position) {
if (input[position] == '\t' || input[position] == '\n' || input[position] == '\f' || input[position] == '\r' || input[position] == ' ' || input[position] == '>')
return DOM::Attr::create(document, attribute_name.to_deprecated_string(), attribute_value.to_deprecated_string()).release_value_but_fixme_should_propagate_errors();
return DOM::Attr::create(document, attribute_name.to_deprecated_string(), attribute_value.to_deprecated_string());
else
attribute_value.append_as_lowercase(input[position]);
}

View file

@ -281,7 +281,7 @@ void HTMLParser::the_end()
document->load_timing_info().dom_content_loaded_event_start_time = HighResolutionTime::unsafe_shared_current_time();
// 2. Fire an event named DOMContentLoaded at the Document object, with its bubbles attribute initialized to true.
auto content_loaded_event = DOM::Event::create(document->realm(), HTML::EventNames::DOMContentLoaded).release_value_but_fixme_should_propagate_errors();
auto content_loaded_event = DOM::Event::create(document->realm(), HTML::EventNames::DOMContentLoaded);
content_loaded_event->set_bubbles(true);
document->dispatch_event(content_loaded_event);
@ -322,7 +322,7 @@ void HTMLParser::the_end()
// 5. Fire an event named load at window, 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.
window->dispatch_event(DOM::Event::create(document->realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
window->dispatch_event(DOM::Event::create(document->realm(), HTML::EventNames::load));
// FIXME: 6. Invoke WebDriver BiDi load complete with the Document's browsing context, and a new WebDriver BiDi navigation status whose id is the Document object's navigation id, status is "complete", and url is the Document object's URL.
@ -490,13 +490,13 @@ void HTMLParser::handle_initial(HTMLToken& token)
}
if (token.is_comment()) {
auto comment = realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors();
auto comment = realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment());
MUST(document().append_child(*comment));
return;
}
if (token.is_doctype()) {
auto doctype = realm().heap().allocate<DOM::DocumentType>(realm(), document()).release_allocated_value_but_fixme_should_propagate_errors();
auto doctype = realm().heap().allocate<DOM::DocumentType>(realm(), document());
doctype->set_name(token.doctype_data().name);
doctype->set_public_id(token.doctype_data().public_identifier);
doctype->set_system_id(token.doctype_data().system_identifier);
@ -525,7 +525,7 @@ void HTMLParser::handle_before_html(HTMLToken& token)
// -> A comment token
if (token.is_comment()) {
// Insert a comment as the last child of the Document object.
auto comment = realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors();
auto comment = realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment());
MUST(document().append_child(*comment));
return;
}
@ -822,7 +822,7 @@ AnythingElse:
void HTMLParser::insert_comment(HTMLToken& token)
{
auto adjusted_insertion_location = find_appropriate_place_for_inserting_node();
adjusted_insertion_location.parent->insert_before(realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors(), adjusted_insertion_location.insert_before_sibling);
adjusted_insertion_location.parent->insert_before(realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment()), adjusted_insertion_location.insert_before_sibling);
}
void HTMLParser::handle_in_head(HTMLToken& token)
@ -1004,7 +1004,7 @@ DOM::Text* HTMLParser::find_character_insertion_node()
if (adjusted_insertion_location.insert_before_sibling) {
if (adjusted_insertion_location.insert_before_sibling->previous_sibling() && adjusted_insertion_location.insert_before_sibling->previous_sibling()->is_text())
return static_cast<DOM::Text*>(adjusted_insertion_location.insert_before_sibling->previous_sibling());
auto new_text_node = realm().heap().allocate<DOM::Text>(realm(), document(), "").release_allocated_value_but_fixme_should_propagate_errors();
auto new_text_node = realm().heap().allocate<DOM::Text>(realm(), document(), "");
adjusted_insertion_location.parent->insert_before(*new_text_node, *adjusted_insertion_location.insert_before_sibling);
return new_text_node;
}
@ -1012,7 +1012,7 @@ DOM::Text* HTMLParser::find_character_insertion_node()
return nullptr;
if (adjusted_insertion_location.parent->last_child() && adjusted_insertion_location.parent->last_child()->is_text())
return verify_cast<DOM::Text>(adjusted_insertion_location.parent->last_child());
auto new_text_node = realm().heap().allocate<DOM::Text>(realm(), document(), "").release_allocated_value_but_fixme_should_propagate_errors();
auto new_text_node = realm().heap().allocate<DOM::Text>(realm(), document(), "");
MUST(adjusted_insertion_location.parent->append_child(*new_text_node));
return new_text_node;
}
@ -1137,7 +1137,7 @@ void HTMLParser::handle_after_body(HTMLToken& token)
if (token.is_comment()) {
auto& insertion_location = m_stack_of_open_elements.first();
MUST(insertion_location.append_child(realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors()));
MUST(insertion_location.append_child(realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment())));
return;
}
@ -1173,7 +1173,7 @@ void HTMLParser::handle_after_body(HTMLToken& token)
void HTMLParser::handle_after_after_body(HTMLToken& token)
{
if (token.is_comment()) {
auto comment = realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors();
auto comment = realm().heap().allocate<DOM::Comment>(realm(), document(), token.comment());
MUST(document().append_child(*comment));
return;
}
@ -3402,7 +3402,7 @@ void HTMLParser::handle_after_frameset(HTMLToken& token)
void HTMLParser::handle_after_after_frameset(HTMLToken& token)
{
if (token.is_comment()) {
auto comment = document().heap().allocate<DOM::Comment>(document().realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors();
auto comment = document().heap().allocate<DOM::Comment>(document().realm(), document(), token.comment());
MUST(document().append_child(comment));
return;
}
@ -3669,7 +3669,7 @@ DOM::Document& HTMLParser::document()
Vector<JS::Handle<DOM::Node>> HTMLParser::parse_html_fragment(DOM::Element& context_element, StringView markup)
{
// 1. Create a new Document node, and mark it as being an HTML document.
auto temp_document = DOM::Document::create(context_element.realm()).release_value_but_fixme_should_propagate_errors();
auto temp_document = DOM::Document::create(context_element.realm());
temp_document->set_document_type(DOM::Document::Type::HTML);
temp_document->set_is_temporary_document_for_fragment_parsing({});

View file

@ -16,7 +16,7 @@ namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<Path2D>> Path2D::construct_impl(JS::Realm& realm, Optional<Variant<JS::Handle<Path2D>, DeprecatedString>> const& path)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<Path2D>(realm, realm, path));
return realm.heap().allocate<Path2D>(realm, realm, path);
}
// https://html.spec.whatwg.org/multipage/canvas.html#dom-path2d

View file

@ -9,9 +9,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> PromiseRejectionEvent::create(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
JS::NonnullGCPtr<PromiseRejectionEvent> PromiseRejectionEvent::create(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<PromiseRejectionEvent>(realm, realm, event_name, event_init));
return realm.heap().allocate<PromiseRejectionEvent>(realm, realm, event_name, event_init);
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> PromiseRejectionEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init)

View file

@ -24,8 +24,8 @@ class PromiseRejectionEvent final : public DOM::Event {
WEB_PLATFORM_OBJECT(PromiseRejectionEvent, DOM::Event);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> create(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const& event_init = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> construct_impl(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const& event_init);
[[nodiscard]] static JS::NonnullGCPtr<PromiseRejectionEvent> create(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const& = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<PromiseRejectionEvent>> construct_impl(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const&);
virtual ~PromiseRejectionEvent() override;

View file

@ -259,7 +259,7 @@ void EnvironmentSettingsObject::notify_about_rejected_promises(Badge<EventLoop>)
// FIXME: This currently assumes that global is a WindowObject.
auto& window = verify_cast<HTML::Window>(global);
auto promise_rejection_event = PromiseRejectionEvent::create(window.realm(), HTML::EventNames::unhandledrejection, event_init).release_value_but_fixme_should_propagate_errors();
auto promise_rejection_event = PromiseRejectionEvent::create(window.realm(), HTML::EventNames::unhandledrejection, event_init);
bool not_handled = window.dispatch_event(*promise_rejection_event);

View file

@ -37,7 +37,7 @@ WebIDL::ExceptionOr<JS::GCPtr<JavaScriptModuleScript>> JavaScriptModuleScript::c
auto& realm = settings_object.realm();
// 2. Let script be a new module script that this algorithm will subsequently initialize.
auto script = MUST_OR_THROW_OOM(realm.heap().allocate<JavaScriptModuleScript>(realm, move(base_url), filename, settings_object));
auto script = realm.heap().allocate<JavaScriptModuleScript>(realm, move(base_url), filename, settings_object);
// 3. Set script's settings object to settings.
// NOTE: This was already done when constructing.

View file

@ -27,7 +27,7 @@ void WindowEnvironmentSettingsObject::visit_edges(JS::Cell::Visitor& visitor)
}
// https://html.spec.whatwg.org/multipage/window-object.html#set-up-a-window-environment-settings-object
WebIDL::ExceptionOr<void> WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext> execution_context, Optional<Environment> reserved_environment, AK::URL top_level_creation_url, Origin top_level_origin)
void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext> execution_context, Optional<Environment> reserved_environment, AK::URL top_level_creation_url, Origin top_level_origin)
{
// 1. Let realm be the value of execution context's Realm component.
auto realm = execution_context->realm;
@ -38,7 +38,7 @@ WebIDL::ExceptionOr<void> WindowEnvironmentSettingsObject::setup(AK::URL const&
// 3. Let settings object be a new environment settings object whose algorithms are defined as follows:
// NOTE: See the functions defined for this class.
auto settings_object = MUST_OR_THROW_OOM(realm->heap().allocate<WindowEnvironmentSettingsObject>(*realm, window, move(execution_context)));
auto settings_object = realm->heap().allocate<WindowEnvironmentSettingsObject>(*realm, window, move(execution_context));
// 4. If reservedEnvironment is non-null, then:
if (reserved_environment.has_value()) {
@ -71,15 +71,13 @@ WebIDL::ExceptionOr<void> WindowEnvironmentSettingsObject::setup(AK::URL const&
// 7. Set realm's [[HostDefined]] field to settings object.
// Non-Standard: We store the ESO next to the web intrinsics in a custom HostDefined object
auto intrinsics = MUST_OR_THROW_OOM(realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm));
auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm);
auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics);
realm->set_host_defined(move(host_defined));
// Non-Standard: We cannot fully initialize window object until *after* the we set up
// the realm's [[HostDefined]] internal slot as the internal slot contains the web platform intrinsics
TRY(window.initialize_web_interfaces({}));
return {};
MUST(window.initialize_web_interfaces({}));
}
// https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:responsible-document

View file

@ -15,7 +15,7 @@ class WindowEnvironmentSettingsObject final : public EnvironmentSettingsObject {
JS_CELL(WindowEnvironmentSettingsObject, EnvironmentSettingsObject);
public:
static WebIDL::ExceptionOr<void> setup(AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext>, Optional<Environment>, AK::URL top_level_creation_url, Origin top_level_origin);
static void setup(AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext>, Optional<Environment>, AK::URL top_level_creation_url, Origin top_level_origin);
virtual ~WindowEnvironmentSettingsObject() override;

View file

@ -27,10 +27,10 @@ public:
{
auto realm = execution_context->realm;
VERIFY(realm);
auto settings_object = realm->heap().allocate<WorkerEnvironmentSettingsObject>(*realm, move(execution_context)).release_allocated_value_but_fixme_should_propagate_errors();
auto settings_object = realm->heap().allocate<WorkerEnvironmentSettingsObject>(*realm, move(execution_context));
settings_object->target_browsing_context = nullptr;
auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm).release_allocated_value_but_fixme_should_propagate_errors();
auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm);
auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics);
realm->set_host_defined(move(host_defined));

View file

@ -11,9 +11,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<Storage>> Storage::create(JS::Realm& realm)
JS::NonnullGCPtr<Storage> Storage::create(JS::Realm& realm)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<Storage>(realm, realm));
return realm.heap().allocate<Storage>(realm, realm);
}
Storage::Storage(JS::Realm& realm)

View file

@ -17,7 +17,7 @@ class Storage : public Bindings::LegacyPlatformObject {
WEB_PLATFORM_OBJECT(Storage, Bindings::LegacyPlatformObject);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Storage>> create(JS::Realm&);
[[nodiscard]] static JS::NonnullGCPtr<Storage> create(JS::Realm&);
~Storage();
size_t length() const;

View file

@ -235,7 +235,7 @@ public:
case ValueTag::StringObject: {
auto* realm = m_vm.current_realm();
auto string = TRY(deserialize_string_primitive(m_vm, m_vector, position));
m_memory.append(TRY(JS::StringObject::create(*realm, string, realm->intrinsics().string_prototype())));
m_memory.append(JS::StringObject::create(*realm, string, realm->intrinsics().string_prototype()));
break;
}
case ValueTag::DateObject: {

View file

@ -9,9 +9,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<SubmitEvent>> SubmitEvent::create(JS::Realm& realm, FlyString const& event_name, SubmitEventInit const& event_init)
JS::NonnullGCPtr<SubmitEvent> SubmitEvent::create(JS::Realm& realm, FlyString const& event_name, SubmitEventInit const& event_init)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<SubmitEvent>(realm, realm, event_name, event_init));
return realm.heap().allocate<SubmitEvent>(realm, realm, event_name, event_init);
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<SubmitEvent>> SubmitEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, SubmitEventInit const& event_init)

View file

@ -19,7 +19,7 @@ class SubmitEvent final : public DOM::Event {
WEB_PLATFORM_OBJECT(SubmitEvent, DOM::Event);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<SubmitEvent>> create(JS::Realm&, FlyString const& event_name, SubmitEventInit const& event_init);
[[nodiscard]] static JS::NonnullGCPtr<SubmitEvent> create(JS::Realm&, FlyString const& event_name, SubmitEventInit const& event_init);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<SubmitEvent>> construct_impl(JS::Realm&, FlyString const& event_name, SubmitEventInit const& event_init);
virtual ~SubmitEvent() override;

View file

@ -10,9 +10,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<TextMetrics>> TextMetrics::create(JS::Realm& realm)
JS::NonnullGCPtr<TextMetrics> TextMetrics::create(JS::Realm& realm)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<TextMetrics>(realm, realm));
return realm.heap().allocate<TextMetrics>(realm, realm);
}
TextMetrics::TextMetrics(JS::Realm& realm)

View file

@ -14,7 +14,7 @@ class TextMetrics : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(TextMetrics, Bindings::PlatformObject);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TextMetrics>> create(JS::Realm&);
[[nodiscard]] static JS::NonnullGCPtr<TextMetrics> create(JS::Realm&);
virtual ~TextMetrics() override;

View file

@ -10,9 +10,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<TrackEvent>> TrackEvent::create(JS::Realm& realm, FlyString const& event_name, TrackEventInit event_init)
JS::NonnullGCPtr<TrackEvent> TrackEvent::create(JS::Realm& realm, FlyString const& event_name, TrackEventInit event_init)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<TrackEvent>(realm, realm, event_name, move(event_init)));
return realm.heap().allocate<TrackEvent>(realm, realm, event_name, move(event_init));
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<TrackEvent>> TrackEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, TrackEventInit event_init)

View file

@ -23,8 +23,8 @@ class TrackEvent : public DOM::Event {
WEB_PLATFORM_OBJECT(TrackEvent, DOM::Event);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TrackEvent>> create(JS::Realm&, FlyString const& event_name, TrackEventInit event_init = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TrackEvent>> construct_impl(JS::Realm&, FlyString const& event_name, TrackEventInit event_init);
[[nodiscard]] static JS::NonnullGCPtr<TrackEvent> create(JS::Realm&, FlyString const& event_name, TrackEventInit = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TrackEvent>> construct_impl(JS::Realm&, FlyString const& event_name, TrackEventInit);
// https://html.spec.whatwg.org/multipage/media.html#dom-trackevent-track
Variant<Empty, JS::Handle<VideoTrack>, JS::Handle<AudioTrack>> track() const;

View file

@ -153,7 +153,7 @@ void VideoTrack::set_selected(bool selected)
if (previously_unselected_track_is_selected || selected_track_was_unselected_without_another_selection) {
m_media_element->queue_a_media_element_task([this]() {
m_video_track_list->dispatch_event(DOM::Event::create(realm(), HTML::EventNames::change).release_value_but_fixme_should_propagate_errors());
m_video_track_list->dispatch_event(DOM::Event::create(realm(), HTML::EventNames::change));
});
}
}

View file

@ -84,9 +84,9 @@ private:
u32 m_handle { 0 };
};
WebIDL::ExceptionOr<JS::NonnullGCPtr<Window>> Window::create(JS::Realm& realm)
JS::NonnullGCPtr<Window> Window::create(JS::Realm& realm)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<Window>(realm, realm));
return realm.heap().allocate<Window>(realm, realm);
}
Window::Window(JS::Realm& realm)
@ -577,7 +577,7 @@ void Window::fire_a_page_transition_event(FlyString const& event_name, bool pers
// with the persisted attribute initialized to persisted,
PageTransitionEventInit event_init {};
event_init.persisted = persisted;
auto event = PageTransitionEvent::create(associated_document().realm(), event_name, event_init).release_value_but_fixme_should_propagate_errors();
auto event = PageTransitionEvent::create(associated_document().realm(), event_name, event_init);
// ...the cancelable attribute initialized to true,
event->set_cancelable(true);
@ -593,15 +593,10 @@ void Window::fire_a_page_transition_event(FlyString const& event_name, bool pers
WebIDL::ExceptionOr<JS::NonnullGCPtr<Storage>> Window::local_storage()
{
// FIXME: Implement according to spec.
auto& vm = this->vm();
static HashMap<Origin, JS::Handle<Storage>> local_storage_per_origin;
auto storage = TRY_OR_THROW_OOM(vm, local_storage_per_origin.try_ensure(associated_document().origin(), [this]() -> ErrorOr<JS::Handle<Storage>> {
auto storage_or_exception = Storage::create(realm());
if (storage_or_exception.is_exception())
return Error::from_errno(ENOMEM);
return *storage_or_exception.release_value();
}));
auto storage = local_storage_per_origin.ensure(associated_document().origin(), [this]() -> JS::Handle<Storage> {
return Storage::create(realm());
});
return JS::NonnullGCPtr { *storage };
}
@ -609,15 +604,10 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Storage>> Window::local_storage()
WebIDL::ExceptionOr<JS::NonnullGCPtr<Storage>> Window::session_storage()
{
// FIXME: Implement according to spec.
auto& vm = this->vm();
static HashMap<Origin, JS::Handle<Storage>> session_storage_per_origin;
auto storage = TRY_OR_THROW_OOM(vm, session_storage_per_origin.try_ensure(associated_document().origin(), [this]() -> ErrorOr<JS::Handle<Storage>> {
auto storage_or_exception = Storage::create(realm());
if (storage_or_exception.is_exception())
return Error::from_errno(ENOMEM);
return *storage_or_exception.release_value();
}));
auto storage = session_storage_per_origin.ensure(associated_document().origin(), [this]() -> JS::Handle<Storage> {
return Storage::create(realm());
});
return JS::NonnullGCPtr { *storage };
}
@ -680,7 +670,7 @@ void Window::invoke_idle_callbacks()
// 1. Pop the top callback from window's list of runnable idle callbacks.
auto callback = m_runnable_idle_callbacks.take_first();
// 2. Let deadlineArg be a new IdleDeadline whose [get deadline time algorithm] is getDeadline.
auto deadline_arg = RequestIdleCallback::IdleDeadline::create(realm()).release_value_but_fixme_should_propagate_errors();
auto deadline_arg = RequestIdleCallback::IdleDeadline::create(realm());
// 3. Call callback with deadlineArg as its argument. If an uncaught runtime script error occurs, then report the exception.
auto result = callback->invoke(deadline_arg);
if (result.is_error())
@ -730,11 +720,11 @@ Vector<JS::NonnullGCPtr<Plugin>> Window::pdf_viewer_plugin_objects()
if (m_pdf_viewer_plugin_objects.is_empty()) {
// FIXME: Propagate errors.
m_pdf_viewer_plugin_objects.append(realm().heap().allocate<Plugin>(realm(), realm(), "PDF Viewer"_string).release_allocated_value_but_fixme_should_propagate_errors());
m_pdf_viewer_plugin_objects.append(realm().heap().allocate<Plugin>(realm(), realm(), "Chrome PDF Viewer"_string).release_allocated_value_but_fixme_should_propagate_errors());
m_pdf_viewer_plugin_objects.append(realm().heap().allocate<Plugin>(realm(), realm(), "Chromium PDF Viewer"_string).release_allocated_value_but_fixme_should_propagate_errors());
m_pdf_viewer_plugin_objects.append(realm().heap().allocate<Plugin>(realm(), realm(), "Microsoft Edge PDF Viewer"_string).release_allocated_value_but_fixme_should_propagate_errors());
m_pdf_viewer_plugin_objects.append(realm().heap().allocate<Plugin>(realm(), realm(), "WebKit built-in PDF"_string).release_allocated_value_but_fixme_should_propagate_errors());
m_pdf_viewer_plugin_objects.append(realm().heap().allocate<Plugin>(realm(), realm(), "PDF Viewer"_string));
m_pdf_viewer_plugin_objects.append(realm().heap().allocate<Plugin>(realm(), realm(), "Chrome PDF Viewer"_string));
m_pdf_viewer_plugin_objects.append(realm().heap().allocate<Plugin>(realm(), realm(), "Chromium PDF Viewer"_string));
m_pdf_viewer_plugin_objects.append(realm().heap().allocate<Plugin>(realm(), realm(), "Microsoft Edge PDF Viewer"_string));
m_pdf_viewer_plugin_objects.append(realm().heap().allocate<Plugin>(realm(), realm(), "WebKit built-in PDF"_string));
}
return m_pdf_viewer_plugin_objects;
@ -753,8 +743,8 @@ Vector<JS::NonnullGCPtr<MimeType>> Window::pdf_viewer_mime_type_objects()
return {};
if (m_pdf_viewer_mime_type_objects.is_empty()) {
m_pdf_viewer_mime_type_objects.append(realm().heap().allocate<MimeType>(realm(), realm(), "application/pdf"_string).release_allocated_value_but_fixme_should_propagate_errors());
m_pdf_viewer_mime_type_objects.append(realm().heap().allocate<MimeType>(realm(), realm(), "text/pdf"_string).release_allocated_value_but_fixme_should_propagate_errors());
m_pdf_viewer_mime_type_objects.append(realm().heap().allocate<MimeType>(realm(), realm(), "application/pdf"_string));
m_pdf_viewer_mime_type_objects.append(realm().heap().allocate<MimeType>(realm(), realm(), "text/pdf"_string));
}
return m_pdf_viewer_mime_type_objects;
@ -776,7 +766,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> Window::count_queuin
auto function = JS::NativeFunction::create(realm, move(steps), 0, "size", &realm);
// 3. Set globalObjects count queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObjects relevant settings object.
m_count_queuing_strategy_size_function = MUST_OR_THROW_OOM(heap().allocate<WebIDL::CallbackType>(realm, *function, relevant_settings_object(*this)));
m_count_queuing_strategy_size_function = heap().allocate<WebIDL::CallbackType>(realm, *function, relevant_settings_object(*this));
}
return JS::NonnullGCPtr { *m_count_queuing_strategy_size_function };
@ -800,7 +790,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> Window::byte_length_
auto function = JS::NativeFunction::create(realm, move(steps), 1, "size", &realm);
// 3. Set globalObjects byte length queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObjects relevant settings object.
m_byte_length_queuing_strategy_size_function = MUST_OR_THROW_OOM(heap().allocate<WebIDL::CallbackType>(realm, *function, relevant_settings_object(*this)));
m_byte_length_queuing_strategy_size_function = heap().allocate<WebIDL::CallbackType>(realm, *function, relevant_settings_object(*this));
}
return JS::NonnullGCPtr { *m_byte_length_queuing_strategy_size_function };
@ -824,7 +814,7 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
WindowOrWorkerGlobalScopeMixin::initialize(realm);
if (s_internals_object_exposed)
define_direct_property("internals", MUST_OR_THROW_OOM(heap().allocate<Internals::Internals>(realm, realm)), JS::default_attributes);
define_direct_property("internals", heap().allocate<Internals::Internals>(realm, realm), JS::default_attributes);
return {};
}
@ -880,13 +870,13 @@ void Window::set_name(String const& name)
}
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-location
WebIDL::ExceptionOr<JS::NonnullGCPtr<Location>> Window::location()
JS::NonnullGCPtr<Location> Window::location()
{
auto& realm = this->realm();
// The Window object's location getter steps are to return this's Location object.
if (!m_location)
m_location = MUST_OR_THROW_OOM(heap().allocate<Location>(realm, realm));
m_location = heap().allocate<Location>(realm, realm);
return JS::NonnullGCPtr { *m_location };
}
@ -993,13 +983,13 @@ WebIDL::ExceptionOr<JS::GCPtr<WindowProxy>> Window::open(Optional<String> const&
}
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator
WebIDL::ExceptionOr<JS::NonnullGCPtr<Navigator>> Window::navigator()
JS::NonnullGCPtr<Navigator> Window::navigator()
{
auto& realm = this->realm();
// The navigator and clientInformation getter steps are to return this's associated Navigator.
if (!m_navigator)
m_navigator = MUST_OR_THROW_OOM(heap().allocate<Navigator>(realm, realm));
m_navigator = heap().allocate<Navigator>(realm, realm);
return JS::NonnullGCPtr { *m_navigator };
}
@ -1043,7 +1033,7 @@ void Window::post_message(JS::Value message, String const&)
MessageEventInit event_init {};
event_init.data = message;
event_init.origin = "<origin>"_string;
dispatch_event(MessageEvent::create(realm(), EventNames::message, event_init).release_value_but_fixme_should_propagate_errors());
dispatch_event(MessageEvent::create(realm(), EventNames::message, event_init));
});
}
@ -1057,11 +1047,11 @@ Variant<JS::Handle<DOM::Event>, JS::Value> Window::event() const
}
// https://w3c.github.io/csswg-drafts/cssom/#dom-window-getcomputedstyle
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSS::CSSStyleDeclaration>> Window::get_computed_style(DOM::Element& element, Optional<String> const& pseudo_element) const
JS::NonnullGCPtr<CSS::CSSStyleDeclaration> Window::get_computed_style(DOM::Element& element, Optional<String> const& pseudo_element) const
{
// FIXME: Make this fully spec compliant.
(void)pseudo_element;
return MUST_OR_THROW_OOM(heap().allocate<CSS::ResolvedCSSStyleDeclaration>(realm(), element));
return heap().allocate<CSS::ResolvedCSSStyleDeclaration>(realm(), element);
}
// https://w3c.github.io/csswg-drafts/cssom-view/#dom-window-matchmedia
@ -1071,21 +1061,21 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<CSS::MediaQueryList>> Window::match_media(S
auto parsed_media_query_list = parse_media_query_list(CSS::Parser::ParsingContext(associated_document()), query);
// 2. Return a new MediaQueryList object, with this's associated Document as the document, with parsed media query list as its associated media query list.
auto media_query_list = MUST_OR_THROW_OOM(heap().allocate<CSS::MediaQueryList>(realm(), associated_document(), move(parsed_media_query_list)));
auto media_query_list = heap().allocate<CSS::MediaQueryList>(realm(), associated_document(), move(parsed_media_query_list));
associated_document().add_media_query_list(media_query_list);
return media_query_list;
}
// https://w3c.github.io/csswg-drafts/cssom-view/#dom-window-screen
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSS::Screen>> Window::screen()
JS::NonnullGCPtr<CSS::Screen> Window::screen()
{
// The screen attribute must return the Screen object associated with the Window object.
if (!m_screen)
m_screen = MUST_OR_THROW_OOM(heap().allocate<CSS::Screen>(realm(), *this));
m_screen = heap().allocate<CSS::Screen>(realm(), *this);
return JS::NonnullGCPtr { *m_screen };
}
WebIDL::ExceptionOr<JS::GCPtr<CSS::VisualViewport>> Window::visual_viewport()
JS::GCPtr<CSS::VisualViewport> Window::visual_viewport()
{
// If the associated document is fully active, the visualViewport attribute must return
// the VisualViewport object associated with the Window objects associated document.
@ -1396,31 +1386,31 @@ JS::GCPtr<Selection::Selection> Window::get_selection() const
}
// https://w3c.github.io/hr-time/#dom-windoworworkerglobalscope-performance
WebIDL::ExceptionOr<JS::NonnullGCPtr<HighResolutionTime::Performance>> Window::performance()
JS::NonnullGCPtr<HighResolutionTime::Performance> Window::performance()
{
if (!m_performance)
m_performance = MUST_OR_THROW_OOM(heap().allocate<HighResolutionTime::Performance>(realm(), *this));
m_performance = heap().allocate<HighResolutionTime::Performance>(realm(), *this);
return JS::NonnullGCPtr { *m_performance };
}
// https://w3c.github.io/webcrypto/#dom-windoworworkerglobalscope-crypto
WebIDL::ExceptionOr<JS::NonnullGCPtr<Crypto::Crypto>> Window::crypto()
JS::NonnullGCPtr<Crypto::Crypto> Window::crypto()
{
auto& realm = this->realm();
if (!m_crypto)
m_crypto = MUST_OR_THROW_OOM(heap().allocate<Crypto::Crypto>(realm, realm));
m_crypto = heap().allocate<Crypto::Crypto>(realm, realm);
return JS::NonnullGCPtr { *m_crypto };
}
// https://html.spec.whatwg.org/multipage/custom-elements.html#dom-window-customelements
WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomElementRegistry>> Window::custom_elements()
JS::NonnullGCPtr<CustomElementRegistry> Window::custom_elements()
{
auto& realm = this->realm();
// The customElements attribute of the Window interface must return the CustomElementRegistry object for that Window object.
if (!m_custom_element_registry)
m_custom_element_registry = MUST_OR_THROW_OOM(heap().allocate<CustomElementRegistry>(realm, realm));
m_custom_element_registry = heap().allocate<CustomElementRegistry>(realm, realm);
return JS::NonnullGCPtr { *m_custom_element_registry };
}

View file

@ -46,7 +46,7 @@ class Window final
WEB_PLATFORM_OBJECT(Window, DOM::EventTarget);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Window>> create(JS::Realm&);
[[nodiscard]] static JS::NonnullGCPtr<Window> create(JS::Realm&);
~Window();
@ -131,7 +131,7 @@ public:
JS::NonnullGCPtr<DOM::Document const> document() const;
String name() const;
void set_name(String const&);
WebIDL::ExceptionOr<JS::NonnullGCPtr<Location>> location();
[[nodiscard]] JS::NonnullGCPtr<Location> location();
JS::NonnullGCPtr<History> history() const;
void focus();
@ -142,7 +142,7 @@ public:
JS::GCPtr<DOM::Element const> frame_element() const;
WebIDL::ExceptionOr<JS::GCPtr<WindowProxy>> open(Optional<String> const& url, Optional<String> const& target, Optional<String> const& features);
WebIDL::ExceptionOr<JS::NonnullGCPtr<Navigator>> navigator();
[[nodiscard]] JS::NonnullGCPtr<Navigator> navigator();
void alert(String const& message = {});
bool confirm(Optional<String> const& message);
@ -152,11 +152,11 @@ public:
Variant<JS::Handle<DOM::Event>, JS::Value> event() const;
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSS::CSSStyleDeclaration>> get_computed_style(DOM::Element&, Optional<String> const& pseudo_element) const;
[[nodiscard]] JS::NonnullGCPtr<CSS::CSSStyleDeclaration> get_computed_style(DOM::Element&, Optional<String> const& pseudo_element) const;
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSS::MediaQueryList>> match_media(String const& query);
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSS::Screen>> screen();
WebIDL::ExceptionOr<JS::GCPtr<CSS::VisualViewport>> visual_viewport();
[[nodiscard]] JS::NonnullGCPtr<CSS::Screen> screen();
[[nodiscard]] JS::GCPtr<CSS::VisualViewport> visual_viewport();
i32 inner_width() const;
i32 inner_height() const;
@ -182,11 +182,11 @@ public:
JS::GCPtr<Selection::Selection> get_selection() const;
WebIDL::ExceptionOr<JS::NonnullGCPtr<HighResolutionTime::Performance>> performance();
[[nodiscard]] JS::NonnullGCPtr<HighResolutionTime::Performance> performance();
WebIDL::ExceptionOr<JS::NonnullGCPtr<Crypto::Crypto>> crypto();
[[nodiscard]] JS::NonnullGCPtr<Crypto::Crypto> crypto();
WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomElementRegistry>> custom_elements();
[[nodiscard]] JS::NonnullGCPtr<CustomElementRegistry> custom_elements();
HighResolutionTime::DOMHighResTimeStamp get_last_activation_timestamp() const { return m_last_activation_timestamp; }
void set_last_activation_timestamp(HighResolutionTime::DOMHighResTimeStamp timestamp) { m_last_activation_timestamp = timestamp; }

View file

@ -23,7 +23,7 @@ Worker::Worker(String const& script_url, WorkerOptions const options, DOM::Docum
, m_document(&document)
, m_custom_data()
, m_worker_vm(JS::VM::create(adopt_own(m_custom_data)).release_value_but_fixme_should_propagate_errors())
, m_implicit_port(MessagePort::create(document.realm()).release_value_but_fixme_should_propagate_errors())
, m_implicit_port(MessagePort::create(document.realm()))
{
}
@ -77,10 +77,10 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> Worker::create(String const& scrip
// 5. Let worker URL be the resulting URL record.
// 6. Let worker be a new Worker object.
auto worker = MUST_OR_THROW_OOM(document.heap().allocate<Worker>(document.realm(), script_url, options, document));
auto worker = document.heap().allocate<Worker>(document.realm(), script_url, options, document);
// 7. Let outside port be a new MessagePort in outside settings's Realm.
auto outside_port = TRY(MessagePort::create(outside_settings.realm()));
auto outside_port = MessagePort::create(outside_settings.realm());
// 8. Associate the outside port with worker
worker->m_outside_port = outside_port;
@ -166,7 +166,7 @@ void Worker::run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_setti
MessageEventInit event_init {};
event_init.data = message;
event_init.origin = "<origin>"_string;
dispatch_event(MessageEvent::create(*m_worker_realm, HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors());
dispatch_event(MessageEvent::create(*m_worker_realm, HTML::EventNames::message, event_init));
}));
return JS::js_undefined();
@ -263,7 +263,7 @@ void Worker::run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_setti
// FIXME: Global scope association
// 16. Let inside port be a new MessagePort object in inside settings's Realm.
auto inside_port = MessagePort::create(m_inner_settings->realm()).release_value_but_fixme_should_propagate_errors();
auto inside_port = MessagePort::create(m_inner_settings->realm());
// 17. Associate inside port with worker global scope.
// FIXME: Global scope association

View file

@ -27,7 +27,7 @@ WorkerGlobalScope::~WorkerGlobalScope() = default;
void WorkerGlobalScope::initialize(JS::Realm& realm)
{
Base::initialize(realm);
m_navigator = MUST(WorkerNavigator::create(*this));
m_navigator = WorkerNavigator::create(*this);
}
void WorkerGlobalScope::visit_edges(Cell::Visitor& visitor)

View file

@ -11,9 +11,9 @@
namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<WorkerNavigator>> WorkerNavigator::create(WorkerGlobalScope& global_scope)
JS::NonnullGCPtr<WorkerNavigator> WorkerNavigator::create(WorkerGlobalScope& global_scope)
{
return MUST_OR_THROW_OOM(global_scope.heap().allocate<WorkerNavigator>(global_scope.realm(), global_scope));
return global_scope.heap().allocate<WorkerNavigator>(global_scope.realm(), global_scope);
}
WorkerNavigator::WorkerNavigator(WorkerGlobalScope& global_scope)

View file

@ -22,7 +22,7 @@ class WorkerNavigator : public Bindings::PlatformObject
WEB_PLATFORM_OBJECT(WorkerNavigator, Bindings::PlatformObject);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<WorkerNavigator>> create(WorkerGlobalScope&);
[[nodiscard]] static JS::NonnullGCPtr<WorkerNavigator> create(WorkerGlobalScope&);
virtual ~WorkerNavigator() override;