Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.1

0.6.1 / src / web / bindings / audio_constructor.lucb

#==============================================================================================
#
#   audio_constructor - Bindings::AudioConstructor: the legacy factory function Audio()
#
#   DESCRIPTION:
#       Port of Libraries/LibWeb/Bindings/AudioConstructor.cpp (lines 1-72) and AudioConstructor.h (lines
#       1-30). `new Audio(...)` creates an <audio> element; AudioConstructor is a JS::NativeFunction,
#       a JS object, so it comes with luce-js in phase 3 (DESIGN.md ยง3.6): the functions are
#       here with their steps, and trap until then.
#
#       Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

## Ported from Libraries/LibWeb/Bindings/AudioConstructor.cpp:20 Web::Bindings::AudioConstructor::AudioConstructor:
## NativeFunction(realm.intrinsics().function_prototype()).
pub func bind_audio_constructor_construct_realm(this: BindAudioConstructor*, realm: Realm*):
    trap("unported (P3): Web::Bindings::AudioConstructor::AudioConstructor (a JS::NativeFunction)")

## Ported from Libraries/LibWeb/Bindings/AudioConstructor.cpp:25 Web::Bindings::AudioConstructor::initialize (override):
## the function's length (0), name ("Audio") and prototype (HTMLAudioElement's) properties.
pub func bind_audio_constructor_initialize_impl(base: JsCell*, realm: Realm*):
    trap("unported (P3): Web::Bindings::AudioConstructor::initialize (JS properties)")

## Ported from Libraries/LibWeb/Bindings/AudioConstructor.cpp:35 Web::Bindings::AudioConstructor::call (virtual):
## a TypeError (ConstructorWithoutNew, "Audio").
pub func bind_audio_constructor_call_impl(this: BindAudioConstructor*) -> JsValue!:
    trap("unported (P3): Web::Bindings::AudioConstructor::call (a JS TypeError)")

## Ported from Libraries/LibWeb/Bindings/AudioConstructor.cpp:42 Web::Bindings::AudioConstructor::construct (virtual).
## https://html.spec.whatwg.org/multipage/media.html#dom-audio
## https://webidl.spec.whatwg.org/#legacy-factory-functions
pub func bind_audio_constructor_construct_js_function_object_impl(this: BindAudioConstructor*, new_target: JsFunctionObject*) -> JsObject*!:
    # 1. Let document be the current global object's associated Document.
    # 2. Let audio be the result of creating an element given document, "audio", and the HTML namespace.
    # 3. Set an attribute value for audio using "preload" and "auto".
    # 4. If src is given, then set an attribute value for audio using "src" and src.
    #    (This will cause the user agent to invoke the object's resource selection algorithm before returning.)
    # 5. Return audio.
    # (The arguments are JS values and the result is the element's wrapper: phase 3.)
    trap("unported (P3): Web::Bindings::AudioConstructor::construct (JS arguments and wrapper)")

## Ported from Libraries/LibWeb/Bindings/AudioConstructor.h:27 Web::Bindings::AudioConstructor::has_constructor (virtual).
pub func bind_audio_constructor_has_constructor_impl(this: BindAudioConstructor*) -> bool:
    return true