Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / aria / aria_mixin_3.lucb

#==============================================================================================
#
#   aria_mixin_3 - ARIA::ARIAMixin: the role from the role attribute, global attributes, ID
#                  references and the element-referencing attributes
#
#   DESCRIPTION:
#       Port of Libraries/LibWeb/ARIA/ARIAMixin.cpp (lines 28-281) with the rest of
#       ARIAMixin.h's virtual declarations, in the header's order. to_element, the
#       accessibility tree predicates and id_reference_exists are pure virtual here; DOM::Element
#       overrides them.
#
#       Copyright (c) 2022, Jonah Shafran <jonahshafran@gmail.com>
#       Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

# mark: Roles ===================================================================================

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.h:42 Web::ARIA::ARIAMixin::default_role (virtual).
# https://www.w3.org/TR/html-aria/#docconformance
pub func aria_mixin_default_role_impl(this: AriaMixin*) -> AriaRole?:
    return none

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.h:44 Web::ARIA::ARIAMixin::to_element (virtual).
pub func aria_mixin_to_element_impl(this: AriaMixin*) -> DomElement*:
    trap("pure virtual: Web::ARIA::ARIAMixin::to_element")

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.h:45 Web::ARIA::ARIAMixin::to_element (virtual).
pub func aria_mixin_to_element_const_impl(this: AriaMixin*) -> DomElement*:
    trap("pure virtual: Web::ARIA::ARIAMixin::to_element")

## The ASCII whitespace predicate (Infra::is_ascii_whitespace) the token lists split on.
struct AriaIsAsciiWhitespace: ak.CharPredicate:
    var unused: u8

    func matches(ch: u8) -> bool:
        return web_infra.is_ascii_whitespace((u32)ch)

## The loop role_from_role_attribute_value runs for each role that needs a context:
## `for (auto ancestor = to_element().parent_element(); ancestor; ancestor = ancestor->parent_element())`
## with `first_is_one_of(ancestor->role_or_default(), roles...)` as its test.
func aria_mixin_has_ancestor_with_role(this: AriaMixin*, roles: const AriaRole[]) -> bool:
    var ancestor = dom_node_parent_element(aria_mixin_to_element(this).dom_node())
    while let element = ancestor:
        let ancestor_role = aria_mixin_role_or_default(&element.aria_mixin)
        for role in roles:
            if ancestor_role == role:
                return true
        ancestor = dom_node_parent_element(element.dom_node())
    return false

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:29 Web::ARIA::ARIAMixin::role_from_role_attribute_value.
# https://www.w3.org/TR/wai-aria-1.2/#introroles
pub func aria_mixin_role_from_role_attribute_value(this: AriaMixin*) -> AriaRole?:
    # 1. Use the rules of the host language to detect that an element has a role attribute and to identify the attribute value string for it.
    let maybe_role_string = aria_mixin_role(this)
    let role_string = maybe_role_string else return none

    # 2. Separate the attribute value string for that attribute into a sequence of whitespace-free substrings by separating on whitespace.
    let role_view = ak.string_bytes_as_string_view(&role_string)
    let is_ascii_whitespace = AriaIsAsciiWhitespace(unused = 0)
    let role_list = ak.string_view_split_view_if(&role_view, &is_ascii_whitespace)

    # 3. Compare the substrings to all the names of the non-abstract WAI-ARIA roles. Case-sensitivity of the comparison inherits from the case-sensitivity of the host language.
    for role_name in ak.vector_span_const(&role_list):
        let role = aria_role_from_string(role_name) else continue
        # NOTE: Per https://w3c.github.io/aria/#directory, "Authors are advised to treat directory as deprecated and to
        # use 'list'." Further, the "directory role == computedrole list" and "div w/directory role == computedrole
        # list" tests in https://wpt.fyi/results/wai-aria/role/synonym-roles.html expect "list", not "directory".
        if role == AriaRole.directory:
            return AriaRole.list
        # NOTE: The "image" role value is a synonym for the older "img" role value; however, the "synonym img role ==
        # computedrole image" test in https://wpt.fyi/results/wai-aria/role/synonym-roles.html expects "image", not "img".
        if role == AriaRole.img:
            return AriaRole.image
        # https://w3c.github.io/core-aam/#roleMappingComputedRole
        # When an element has a role but is not contained in the required context (for example, an orphaned listitem
        # without the required accessible parent of role list), User Agents MUST ignore the role token, and return the
        # computedrole as if the ignored role token had not been included.
        if role == AriaRole.columnheader:
            if aria_mixin_has_ancestor_with_role(this, [AriaRole.row]):
                return AriaRole.columnheader
            continue
        if role == AriaRole.gridcell:
            if aria_mixin_has_ancestor_with_role(this, [AriaRole.row]):
                return AriaRole.gridcell
            continue
        if role == AriaRole.listitem:
            if aria_mixin_has_ancestor_with_role(this, [AriaRole.directory, AriaRole.list]):
                return AriaRole.listitem
            continue
        if role == AriaRole.menuitem:
            if aria_mixin_has_ancestor_with_role(this, [AriaRole.menu, AriaRole.menubar]):
                return AriaRole.menuitem
            continue
        if role == AriaRole.menuitemcheckbox:
            if aria_mixin_has_ancestor_with_role(this, [AriaRole.menu, AriaRole.menubar]):
                return AriaRole.menuitemcheckbox
            continue
        if role == AriaRole.menuitemradio:
            if aria_mixin_has_ancestor_with_role(this, [AriaRole.menu, AriaRole.menubar]):
                return AriaRole.menuitemradio
            continue
        if role == AriaRole.option:
            if aria_mixin_has_ancestor_with_role(this, [AriaRole.listbox]):
                return AriaRole.option
            continue
        if role == AriaRole.row:
            if aria_mixin_has_ancestor_with_role(this, [AriaRole.table, AriaRole.grid, AriaRole.treegrid]):
                return AriaRole.row
            continue
        if role == AriaRole.rowgroup:
            if aria_mixin_has_ancestor_with_role(this, [AriaRole.table, AriaRole.grid, AriaRole.treegrid]):
                return AriaRole.rowgroup
            continue
        if role == AriaRole.rowheader:
            if aria_mixin_has_ancestor_with_role(this, [AriaRole.row]):
                return AriaRole.rowheader
            continue
        if role == AriaRole.tab:
            if aria_mixin_has_ancestor_with_role(this, [AriaRole.tablist]):
                return AriaRole.tab
            continue
        if role == AriaRole.treeitem:
            if aria_mixin_has_ancestor_with_role(this, [AriaRole.tree]):
                return AriaRole.treeitem
            continue
        # https://w3c.github.io/aria/#document-handling_author-errors_roles
        # Certain landmark roles require names from authors. In situations where an author has not specified names for
        # these landmarks, it is considered an authoring error. The user agent MUST treat such elements as if no role
        # had been provided. If a valid fallback role had been specified, or if the element had an implicit ARIA role,
        # then user agents would continue to expose that role, instead.
        if role == AriaRole.form or role == AriaRole.region:
            let element = aria_mixin_to_element(this)
            let name = dom_node_accessible_name(element.dom_node(), dom_node_document(element.dom_node()), DomShouldComputeRole.no) else trap("MUST: accessible_name")
            if ak.string_is_empty(&name):
                continue
        if role == AriaRole.none_ or role == AriaRole.presentation:
            # https://w3c.github.io/aria/#conflict_resolution_presentation_none
            # If an element is focusable, user agents MUST ignore the none/presentation
            # role and expose the element with its implicit role.
            if dom_event_target_is_focusable(aria_mixin_to_element(this).dom_event_target()):
                continue
            # If an element has global WAI-ARIA states or properties, user agents MUST
            # ignore the none/presentation role and instead expose the element's implicit role.
            if aria_mixin_has_global_aria_attribute(this):
                continue
            # NOTE: Per https://w3c.github.io/aria/#presentation, "the working group introduced 'none' as the preferred
            # synonym to the presentation role"; further, https://wpt.fyi/results/wai-aria/role/synonym-roles.html has
            # a "synonym presentation role == computedrole none" test that expects "none", not "presentation".
            if role == AriaRole.presentation:
                return AriaRole.none_
        # 4. Use the first such substring in textual order that matches the name of a non-abstract WAI-ARIA role.
        if not aria_is_abstract_role(role):
            return role

    # https://www.w3.org/TR/wai-aria-1.2/#document-handling_author-errors_roles
    # If the role attribute contains no tokens matching the name of a non-abstract WAI-ARIA role, the user agent MUST treat the element as if no role had been provided.
    # https://www.w3.org/TR/wai-aria-1.2/#implicit_semantics
    return none

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:177 Web::ARIA::ARIAMixin::role_or_default.
pub func aria_mixin_role_or_default(this: AriaMixin*) -> AriaRole?:
    if let role = aria_mixin_role_from_role_attribute_value(this):
        return role
    return aria_mixin_default_role(this)

# mark: The accessibility tree ==================================================================

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.h:51 Web::ARIA::ARIAMixin::exclude_from_accessibility_tree (virtual).
# https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion
pub func aria_mixin_exclude_from_accessibility_tree_impl(this: AriaMixin*) -> bool:
    trap("pure virtual: Web::ARIA::ARIAMixin::exclude_from_accessibility_tree")

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.h:54 Web::ARIA::ARIAMixin::include_in_accessibility_tree (virtual).
# https://www.w3.org/TR/wai-aria-1.2/#tree_inclusion
pub func aria_mixin_include_in_accessibility_tree_impl(this: AriaMixin*) -> bool:
    trap("pure virtual: Web::ARIA::ARIAMixin::include_in_accessibility_tree")

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:185 Web::ARIA::ARIAMixin::has_global_aria_attribute.
# https://www.w3.org/TR/wai-aria-1.2/#global_states
pub func aria_mixin_has_global_aria_attribute(this: AriaMixin*) -> bool:
    # aria_atomic().has_value() || aria_braille_label().has_value() || ...: the first present attribute answers.
    if aria_mixin_aria_atomic(this) != none:
        return true
    if aria_mixin_aria_braille_label(this) != none:
        return true
    if aria_mixin_aria_braille_role_description(this) != none:
        return true
    if aria_mixin_aria_busy(this) != none:
        return true
    if aria_mixin_aria_controls(this) != none:
        return true
    if aria_mixin_aria_current(this) != none:
        return true
    if aria_mixin_aria_described_by(this) != none:
        return true
    if aria_mixin_aria_description(this) != none:
        return true
    if aria_mixin_aria_details(this) != none:
        return true
    if aria_mixin_aria_disabled(this) != none:
        return true
    if aria_mixin_aria_drop_effect(this) != none:
        return true
    if aria_mixin_aria_error_message(this) != none:
        return true
    if aria_mixin_aria_flow_to(this) != none:
        return true
    if aria_mixin_aria_grabbed(this) != none:
        return true
    if aria_mixin_aria_has_popup(this) != none:
        return true
    if aria_mixin_aria_hidden(this) != none:
        return true
    if aria_mixin_aria_invalid(this) != none:
        return true
    if aria_mixin_aria_key_shortcuts(this) != none:
        return true
    if aria_mixin_aria_label(this) != none:
        return true
    if aria_mixin_aria_labelled_by(this) != none:
        return true
    if aria_mixin_aria_live(this) != none:
        return true
    if aria_mixin_aria_owns(this) != none:
        return true
    if aria_mixin_aria_relevant(this) != none:
        return true
    return aria_mixin_aria_role_description(this) != none

# mark: ID references ===========================================================================

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:213 Web::ARIA::ARIAMixin::parse_id_reference.
# https://www.w3.org/TR/wai-aria-1.2/#valuetype_idref
pub func aria_mixin_parse_id_reference(this: AriaMixin*, id_reference: ak.String?) -> ak.String?:
    let reference = id_reference else return none

    if aria_mixin_id_reference_exists(this, reference):
        return reference

    return none

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:224 Web::ARIA::ARIAMixin::parse_id_reference_list.
# https://www.w3.org/TR/wai-aria-1.2/#valuetype_idref_list
pub func aria_mixin_parse_id_reference_list(this: AriaMixin*, id_list: ak.String?) -> ak.Vector[ak.String]:
    var result: ak.Vector[ak.String]
    let list = id_list else return result

    let list_view = ak.string_bytes_as_string_view(&list)
    let is_ascii_whitespace = AriaIsAsciiWhitespace(unused = 0)
    let id_references = ak.string_view_split_view_if(&list_view, &is_ascii_whitespace)
    for id_reference_view in ak.vector_span_const(&id_references):
        let id_reference = ak.string_from_utf8(id_reference_view) else trap("MUST: String::from_utf8")
        if aria_mixin_id_reference_exists(this, id_reference):
            ak.vector_append_t(&result, id_reference)
    return result

# mark: Element-referencing attributes ==========================================================

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:249 Web::ARIA::ARIAMixin::aria_active_descendant_element
## (ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES).
pub func aria_mixin_aria_active_descendant_element(this: AriaMixin*) -> DomElement*?:
    return gc.weak_ptr(&this.m_aria_active_descendant_element)

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:249 Web::ARIA::ARIAMixin::set_aria_active_descendant_element
## (ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_aria_active_descendant_element(this: AriaMixin*, value: DomElement*?):
    gc.weak_assign(&this.m_aria_active_descendant_element, value)

# mark: Element-list-referencing attributes =====================================================

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::aria_controls_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_aria_controls_elements(this: AriaMixin*) -> const ak.Vector[gc.Weak[DomElement]]*?:
    let elements = this.m_aria_controls_elements else return none
    return elements

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::aria_described_by_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_aria_described_by_elements(this: AriaMixin*) -> const ak.Vector[gc.Weak[DomElement]]*?:
    let elements = this.m_aria_described_by_elements else return none
    return elements

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::aria_details_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_aria_details_elements(this: AriaMixin*) -> const ak.Vector[gc.Weak[DomElement]]*?:
    let elements = this.m_aria_details_elements else return none
    return elements

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::aria_error_message_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_aria_error_message_elements(this: AriaMixin*) -> const ak.Vector[gc.Weak[DomElement]]*?:
    let elements = this.m_aria_error_message_elements else return none
    return elements

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::aria_flow_to_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_aria_flow_to_elements(this: AriaMixin*) -> const ak.Vector[gc.Weak[DomElement]]*?:
    let elements = this.m_aria_flow_to_elements else return none
    return elements

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::aria_labelled_by_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_aria_labelled_by_elements(this: AriaMixin*) -> const ak.Vector[gc.Weak[DomElement]]*?:
    let elements = this.m_aria_labelled_by_elements else return none
    return elements

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::aria_owns_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_aria_owns_elements(this: AriaMixin*) -> const ak.Vector[gc.Weak[DomElement]]*?:
    let elements = this.m_aria_owns_elements else return none
    return elements

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::cached_aria_controls_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_cached_aria_controls_elements(this: AriaMixin*) -> JsArray*?:
    return this.m_cached_aria_controls_elements

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::cached_aria_described_by_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_cached_aria_described_by_elements(this: AriaMixin*) -> JsArray*?:
    return this.m_cached_aria_described_by_elements

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::cached_aria_details_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_cached_aria_details_elements(this: AriaMixin*) -> JsArray*?:
    return this.m_cached_aria_details_elements

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::cached_aria_error_message_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_cached_aria_error_message_elements(this: AriaMixin*) -> JsArray*?:
    return this.m_cached_aria_error_message_elements

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::cached_aria_flow_to_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_cached_aria_flow_to_elements(this: AriaMixin*) -> JsArray*?:
    return this.m_cached_aria_flow_to_elements

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::cached_aria_labelled_by_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_cached_aria_labelled_by_elements(this: AriaMixin*) -> JsArray*?:
    return this.m_cached_aria_labelled_by_elements

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::cached_aria_owns_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_cached_aria_owns_elements(this: AriaMixin*) -> JsArray*?:
    return this.m_cached_aria_owns_elements

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::set_aria_controls_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_aria_controls_elements(this: AriaMixin*, value: ak.Vector[gc.Weak[DomElement]]?):
    if let elements = value:
        let storage = new ak.Vector[gc.Weak[DomElement]]() else trap("out of memory")
        *storage = elements
        this.m_aria_controls_elements = storage
    else:
        this.m_aria_controls_elements = none

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::set_aria_described_by_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_aria_described_by_elements(this: AriaMixin*, value: ak.Vector[gc.Weak[DomElement]]?):
    if let elements = value:
        let storage = new ak.Vector[gc.Weak[DomElement]]() else trap("out of memory")
        *storage = elements
        this.m_aria_described_by_elements = storage
    else:
        this.m_aria_described_by_elements = none

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::set_aria_details_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_aria_details_elements(this: AriaMixin*, value: ak.Vector[gc.Weak[DomElement]]?):
    if let elements = value:
        let storage = new ak.Vector[gc.Weak[DomElement]]() else trap("out of memory")
        *storage = elements
        this.m_aria_details_elements = storage
    else:
        this.m_aria_details_elements = none

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::set_aria_error_message_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_aria_error_message_elements(this: AriaMixin*, value: ak.Vector[gc.Weak[DomElement]]?):
    if let elements = value:
        let storage = new ak.Vector[gc.Weak[DomElement]]() else trap("out of memory")
        *storage = elements
        this.m_aria_error_message_elements = storage
    else:
        this.m_aria_error_message_elements = none

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::set_aria_flow_to_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_aria_flow_to_elements(this: AriaMixin*, value: ak.Vector[gc.Weak[DomElement]]?):
    if let elements = value:
        let storage = new ak.Vector[gc.Weak[DomElement]]() else trap("out of memory")
        *storage = elements
        this.m_aria_flow_to_elements = storage
    else:
        this.m_aria_flow_to_elements = none

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::set_aria_labelled_by_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_aria_labelled_by_elements(this: AriaMixin*, value: ak.Vector[gc.Weak[DomElement]]?):
    if let elements = value:
        let storage = new ak.Vector[gc.Weak[DomElement]]() else trap("out of memory")
        *storage = elements
        this.m_aria_labelled_by_elements = storage
    else:
        this.m_aria_labelled_by_elements = none

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::set_aria_owns_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_aria_owns_elements(this: AriaMixin*, value: ak.Vector[gc.Weak[DomElement]]?):
    if let elements = value:
        let storage = new ak.Vector[gc.Weak[DomElement]]() else trap("out of memory")
        *storage = elements
        this.m_aria_owns_elements = storage
    else:
        this.m_aria_owns_elements = none

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::set_cached_aria_controls_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_cached_aria_controls_elements(this: AriaMixin*, value: JsArray*?):
    this.m_cached_aria_controls_elements = value

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::set_cached_aria_described_by_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_cached_aria_described_by_elements(this: AriaMixin*, value: JsArray*?):
    this.m_cached_aria_described_by_elements = value

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::set_cached_aria_details_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_cached_aria_details_elements(this: AriaMixin*, value: JsArray*?):
    this.m_cached_aria_details_elements = value

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::set_cached_aria_error_message_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_cached_aria_error_message_elements(this: AriaMixin*, value: JsArray*?):
    this.m_cached_aria_error_message_elements = value

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::set_cached_aria_flow_to_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_cached_aria_flow_to_elements(this: AriaMixin*, value: JsArray*?):
    this.m_cached_aria_flow_to_elements = value

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::set_cached_aria_labelled_by_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_cached_aria_labelled_by_elements(this: AriaMixin*, value: JsArray*?):
    this.m_cached_aria_labelled_by_elements = value

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:278 Web::ARIA::ARIAMixin::set_cached_aria_owns_elements
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_set_cached_aria_owns_elements(this: AriaMixin*, value: JsArray*?):
    this.m_cached_aria_owns_elements = value

# mark: ID reference existence =================================================================

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.h:84 Web::ARIA::ARIAMixin::id_reference_exists (virtual).
pub func aria_mixin_id_reference_exists_impl(this: AriaMixin*, arg0: ak.String) -> bool:
    trap("pure virtual: Web::ARIA::ARIAMixin::id_reference_exists")