Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / html / promise_rejection_event.lucb

#==============================================================================================
#
#   promise_rejection_event - HTML::PromiseRejectionEvent: the unhandledrejection and
#                             rejectionhandled events of a global
#
#   DESCRIPTION:
#       Port of Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp (lines 1-48) and
#       PromiseRejectionEvent.h (lines 1-47): an Event carrying the rejected promise and its
#       reason. Notifying about rejected promises fires one at a global for each promise still
#       not handled (a FontFace whose load failed rejects its promise, with scripting off too).
#       The prototype (WEB_SET_PROTOTYPE_FOR_INTERFACE) waits for the bindings (P3).
#
#       Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

## The default PromiseRejectionEventInit (`{}`): no promise, an undefined reason.
pub func html_promise_rejection_event_init_default() -> HtmlPromiseRejectionEventInit:
    return HtmlPromiseRejectionEventInit(event_init = DomEventInit(), promise = none, reason = js_undefined())

## Ported from PromiseRejectionEvent.cpp:15 Web::HTML::PromiseRejectionEvent::create.
pub func html_promise_rejection_event_create(realm: Realm*, event_name: ak.FlyString, event_init: HtmlPromiseRejectionEventInit) -> HtmlPromiseRejectionEvent*:
    let event = realm_create_html_promise_rejection_event(realm, realm, event_name, event_init)
    dom_event_set_is_trusted(event.dom_event(), true)
    return event

## Ported from PromiseRejectionEvent.cpp:22 Web::HTML::PromiseRejectionEvent::construct_impl.
pub func html_promise_rejection_event_construct_impl(realm: Realm*, event_name: ak.FlyString, event_init: HtmlPromiseRejectionEventInit) -> HtmlPromiseRejectionEvent*!:
    return html_promise_rejection_event_create(realm, event_name, event_init)

## Ported from PromiseRejectionEvent.cpp:27 Web::HTML::PromiseRejectionEvent::PromiseRejectionEvent.
pub func html_promise_rejection_event_construct(this: HtmlPromiseRejectionEvent*, realm: Realm*, event_name: ak.FlyString, event_init: HtmlPromiseRejectionEventInit):
    dom_event_construct_dom_event_init(this.dom_event(), realm, event_name, event_init.event_init)
    this.m_promise = event_init.promise else trap("VERIFY: *event_init.promise")
    this.m_reason = event_init.reason

## Ported from PromiseRejectionEvent.cpp:36 Web::HTML::PromiseRejectionEvent::visit_edges (override).
pub func html_promise_rejection_event_visit_edges_impl(base: gc.Cell*, visitor: gc.CellVisitor*):
    let this = (HtmlPromiseRejectionEvent*)base
    dom_event_visit_edges_impl(base, visitor)
    js_visit_object(visitor, this.m_promise)
    js_visit_value(visitor, this.m_reason)

## Ported from PromiseRejectionEvent.cpp:43 Web::HTML::PromiseRejectionEvent::initialize (override).
pub func html_promise_rejection_event_initialize_impl(base: JsCell*, realm: Realm*):
    web_set_prototype_for_interface(base, realm, BindInterfaceName.promise_rejection_event)
    dom_event_initialize_impl(base, realm)

## Ported from PromiseRejectionEvent.h:34 Web::HTML::PromiseRejectionEvent::promise.
pub func html_promise_rejection_event_promise(this: HtmlPromiseRejectionEvent*) -> JsObject*:
    return this.m_promise

## Ported from PromiseRejectionEvent.h:35 Web::HTML::PromiseRejectionEvent::reason.
pub func html_promise_rejection_event_reason(this: HtmlPromiseRejectionEvent*) -> JsValue:
    return this.m_reason