Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / layout / audio_box.lucb

#==============================================================================================
#
#   audio_box - Layout::AudioBox: the box of <audio>
#
#   DESCRIPTION:
#       Port of LibWeb/Layout/AudioBox.cpp (lines 1-41) and AudioBox.h: sized by its content
#       (the controls' shadow tree), not as a replaced element.
#
#       Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

## Ported from Libraries/LibWeb/Layout/AudioBox.cpp:15 Web::Layout::AudioBox::AudioBox.
pub func layout_audio_box_construct(this: LayoutAudioBox*, document: DomDocument*, element: DomElement*, style: CssComputedProperties*):
    layout_replaced_box_construct(this.layout_replaced_box(), document, element, style)

## Ported from Libraries/LibWeb/Layout/AudioBox.cpp:20 Web::Layout::AudioBox::dom_node.
pub func layout_audio_box_dom_node(this: LayoutAudioBox*) -> HtmlAudioElement*:
    let element = layout_replaced_box_dom_node(this.layout_replaced_box()) else trap("VERIFY: an audio box has a DOM node")
    return (HtmlAudioElement*)element

## Ported from Libraries/LibWeb/Layout/AudioBox.cpp:25 Web::Layout::AudioBox::dom_node.
pub func layout_audio_box_dom_node_const(this: LayoutAudioBox*) -> HtmlAudioElement*:
    return layout_audio_box_dom_node(this)

## Ported from Libraries/LibWeb/Layout/AudioBox.cpp:30 Web::Layout::AudioBox::can_have_children (override).
pub func layout_audio_box_can_have_children_impl(base: LayoutNode*) -> bool:
    # If we allow children when controls are disabled, innerText may be non-empty.
    return dom_element_shadow_root(layout_audio_box_dom_node((LayoutAudioBox*)base).dom_element()) != none

## Ported from Libraries/LibWeb/Layout/AudioBox.cpp:36 Web::Layout::AudioBox::create_paintable (override).
pub func layout_audio_box_create_paintable_impl(base: LayoutNode*) -> PaintPaintable*?:
    return paint_paintable_box_create_layout_box((LayoutBox*)base).paint_paintable()

## Ported from Libraries/LibWeb/Layout/AudioBox.h:30 Web::Layout::AudioBox::has_auto_content_box_size (override).
# Treat the audio element as if it was not a replaced element, sizing based on its content.
# Thus, it can fit to the shadow DOM controls, instead of having a hardcoded height.
pub func layout_audio_box_has_auto_content_box_size_impl(base: LayoutBox*) -> bool:
    _ = base
    return false