Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / bindings / image_constructor.lucb

#==============================================================================================
#
#   image_constructor - Bindings::ImageConstructor: the legacy factory function Image()
#
#   DESCRIPTION:
#       Port of Libraries/LibWeb/Bindings/ImageConstructor.cpp (lines 1-73) and ImageConstructor.h (lines
#       1-30). `new Image(...)` creates an <img> element; ImageConstructor 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) 2021, the SerenityOS developers.
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

## Ported from Libraries/LibWeb/Bindings/ImageConstructor.cpp:21 Web::Bindings::ImageConstructor::ImageConstructor:
## NativeFunction(realm.intrinsics().function_prototype()).
pub func bind_image_constructor_construct_realm(this: BindImageConstructor*, realm: Realm*):
    trap("unported (P3): Web::Bindings::ImageConstructor::ImageConstructor (a JS::NativeFunction)")

## Ported from Libraries/LibWeb/Bindings/ImageConstructor.cpp:26 Web::Bindings::ImageConstructor::initialize (override):
## the function's length (0), name ("Image") and prototype (HTMLImageElement's) properties.
pub func bind_image_constructor_initialize_impl(base: JsCell*, realm: Realm*):
    trap("unported (P3): Web::Bindings::ImageConstructor::initialize (JS properties)")

## Ported from Libraries/LibWeb/Bindings/ImageConstructor.cpp:36 Web::Bindings::ImageConstructor::call (virtual):
## a TypeError (ConstructorWithoutNew, "Image").
pub func bind_image_constructor_call_impl(this: BindImageConstructor*) -> JsValue!:
    trap("unported (P3): Web::Bindings::ImageConstructor::call (a JS TypeError)")

## Ported from Libraries/LibWeb/Bindings/ImageConstructor.cpp:43 Web::Bindings::ImageConstructor::construct (virtual).
## https://html.spec.whatwg.org/multipage/embedded-content.html#dom-image
## https://webidl.spec.whatwg.org/#legacy-factory-functions
pub func bind_image_constructor_construct_js_function_object_impl(this: BindImageConstructor*, new_target: JsFunctionObject*) -> JsObject*!:
    # 1. Let document be the current global object's associated Document.
    # 2. Let img be the result of creating an element given document, "img", and the HTML namespace.
    # 3. If width is given, then set an attribute value for img using "width" and width.
    # 4. If height is given, then set an attribute value for img using "height" and height.
    # 5. Return img.
    # (The arguments are JS values and the result is the element's wrapper: phase 3.)
    trap("unported (P3): Web::Bindings::ImageConstructor::construct (JS arguments and wrapper)")

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