Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.1

0.6.1 / src / web / html / htmlu_list_element.lucb

#==============================================================================================
#
#   htmlu_list_element - HTML::HTMLUListElement: <ul>
#
#   DESCRIPTION:
#       Port of LibWeb/HTML/HTMLUListElement.cpp (lines 1-59) and HTMLUListElement.h: the
#       constructor (which moves the mixin tables to HTMLUListElement's, as C++'s vptrs move),
#       initialize, the inline overrides and the type attribute's presentational hint.
#
#==============================================================================================

## Ported from HTMLUListElement.cpp:18 Web::HTML::HTMLUListElement::HTMLUListElement.
pub func html_htmlu_list_element_construct(this: HtmlHtmluListElement*, document: DomDocument*, qualified_name: DomQualifiedName):
    html_element_construct(this.html_element(), document, qualified_name)
    # The vptrs of the mixin bases move to HTMLUListElement's tables.
    let element = this.html_element()
    element.element.slottable_mixin.vtable = &html_htmlu_list_element_slottable_mixin_vtable
    element.element.aria_mixin.vtable = &html_htmlu_list_element_aria_mixin_vtable
    element.element.animatable.vtable = &html_htmlu_list_element_animatable_vtable
    element.global_event_handlers.vtable = &html_htmlu_list_element_global_event_handlers_vtable
    element.form_associated_element.vtable = &html_htmlu_list_element_form_associated_element_vtable

## Ported from HTMLUListElement.cpp:25 Web::HTML::HTMLUListElement::initialize (override).
pub func html_htmlu_list_element_initialize_impl(base: JsCell*, realm: Realm*):
    web_set_prototype_for_interface(base, realm, BindInterfaceName.htmlu_list_element)
    html_element_initialize_impl(base, realm)

## Ported from HTMLUListElement.h:22 Web::HTML::HTMLUListElement::default_role (override).
pub func html_htmlu_list_element_default_role_impl(base: AriaMixin*) -> AriaRole?:
    return AriaRole.list

## Ported from HTMLUListElement.h:24 Web::HTML::HTMLUListElement::is_html_ulist_element (override).
pub func html_htmlu_list_element_is_html_ulist_element_impl(base: DomNode*) -> bool:
    return true

## Ported from HTMLUListElement.cpp:31 Web::HTML::HTMLUListElement::is_presentational_hint (override).
pub func html_htmlu_list_element_is_presentational_hint_impl(base: DomElement*, name: ak.FlyString) -> bool:
    if dom_element_is_presentational_hint_impl(base, name):
        return true

    return ak.fly_string_eq_fly_string(&name, &html_attribute_names_type)

## Ported from HTMLUListElement.cpp:39 Web::HTML::HTMLUListElement::apply_presentational_hints (override).
pub func html_htmlu_list_element_apply_presentational_hints_impl(base: DomElement*, properties: ak.Vector[CssStyleProperty]*):
    dom_element_apply_presentational_hints_impl(base, properties)

    # https://html.spec.whatwg.org/multipage/rendering.html#lists
    for attribute in dom_element_attribute_span(base):
        let name = dom_attr_name(attribute)
        let value = dom_attr_value(attribute)
        if ak.fly_string_eq_fly_string(&name, &html_attribute_names_type):
            if ak.string_equals_ignoring_ascii_case_string_view(&value, ak.sv("none")):
                ak.vector_append_t(properties, CssStyleProperty(property_id = css_data.PropertyId.list_style_type, value = css_keyword_style_value_create(css_data.Keyword.none_).css_style_value()))
            elif ak.string_equals_ignoring_ascii_case_string_view(&value, ak.sv("disc")):
                ak.vector_append_t(properties, html_list_style_type_counter_style("disc"))
            elif ak.string_equals_ignoring_ascii_case_string_view(&value, ak.sv("circle")):
                ak.vector_append_t(properties, html_list_style_type_counter_style("circle"))
            elif ak.string_equals_ignoring_ascii_case_string_view(&value, ak.sv("square")):
                ak.vector_append_t(properties, html_list_style_type_counter_style("square"))