Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.1

0.6.1 / src / web / html / html_audio_element.lucb

#==============================================================================================
#
#   html_audio_element - HTML::HTMLAudioElement: <audio>
#
#   DESCRIPTION:
#       Port of LibWeb/HTML/HTMLAudioElement.cpp (lines 1-60): construction (which moves the
#       mixin tables to HTMLAudioElement's, as C++'s vptrs move), initialize, the computed style
#       of an audio element without controls, its AudioBox layout node and whether it paints.
#
#==============================================================================================

## Ported from HTMLAudioElement.cpp:18 Web::HTML::HTMLAudioElement::HTMLAudioElement.
pub func html_audio_element_construct(this: HtmlAudioElement*, document: DomDocument*, qualified_name: DomQualifiedName):
    html_media_element_construct(this.html_media_element(), document, qualified_name)
    # The vptrs of the mixin bases move to HTMLAudioElement's tables.
    let element = this.html_element()
    element.element.slottable_mixin.vtable = &html_audio_element_slottable_mixin_vtable
    element.element.aria_mixin.vtable = &html_audio_element_aria_mixin_vtable
    element.element.animatable.vtable = &html_audio_element_animatable_vtable
    element.global_event_handlers.vtable = &html_audio_element_global_event_handlers_vtable
    element.form_associated_element.vtable = &html_audio_element_form_associated_element_vtable

## Ported from HTMLAudioElement.cpp:25 Web::HTML::HTMLAudioElement::initialize (override).
pub func html_audio_element_initialize_impl(base: JsCell*, realm: Realm*):
    web_set_prototype_for_interface(base, realm, BindInterfaceName.html_audio_element)
    html_media_element_initialize_impl(base, realm)

## Ported from HTMLAudioElement.cpp:31 Web::HTML::HTMLAudioElement::adjust_computed_style (override).
pub func html_audio_element_adjust_computed_style_impl(base: DomElement*, style: CssComputedProperties*):
    html_media_element_adjust_computed_style_impl(base, style)

    # https://html.spec.whatwg.org/multipage/rendering.html#embedded-content-rendering-rules
    if not dom_element_has_attribute(base, html_attribute_names_controls):
        html_media_element_set_display(style, CssDisplayShort.none_)

## Ported from HTMLAudioElement.cpp:40 Web::HTML::HTMLAudioElement::create_layout_node (override).
pub func html_audio_element_create_layout_node_impl(base: DomElement*, style: CssComputedProperties*) -> LayoutNode*?:
    # heap().allocate<Layout::AudioBox>(...): a layout node's initialize is JS::Cell's, which does nothing.
    return realm_create_layout_audio_box(dom_element_realm(base), dom_node_document(base.dom_node()), base, style).layout_node()

## Ported from HTMLAudioElement.cpp:45 Web::HTML::HTMLAudioElement::layout_node.
pub func html_audio_element_layout_node(this: HtmlAudioElement*) -> LayoutAudioBox*?:
    return (LayoutAudioBox*?)dom_node_layout_node(this.dom_node())

## Ported from HTMLAudioElement.cpp:50 Web::HTML::HTMLAudioElement::should_paint.
pub func html_audio_element_should_paint(this: HtmlAudioElement*) -> bool:
    return dom_element_has_attribute(this.dom_element(), html_attribute_names_controls) or dom_node_is_scripting_disabled(this.dom_node())

## Ported from HTMLAudioElement.cpp:55 Web::HTML::HTMLAudioElement::layout_node.
pub func html_audio_element_layout_node_const(this: HtmlAudioElement*) -> LayoutAudioBox*?:
    return (LayoutAudioBox*?)dom_node_layout_node(this.dom_node())