Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / aria / aria_mixin_1.lucb

#==============================================================================================
#
#   aria_mixin_1 - ARIA::ARIAMixin: construction and the visit of its cached element arrays
#
#   DESCRIPTION:
#       Port of Libraries/LibWeb/ARIA/ARIAMixin.cpp (lines 17-26). Ported ahead of region r13b
#       because every Element constructs and visits its ARIAMixin; aria_mixin_2 and aria_mixin_3
#       have the rest of the file.
#
#       Copyright (c) 2022, Jonah Shafran <jonahshafran@gmail.com>
#       Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:17 Web::ARIA::ARIAMixin::ARIAMixin.
## `= default`: every member starts empty, which the zeroed cell already is.
pub func aria_mixin_construct(this: AriaMixin*):
    return

## Ported from Libraries/LibWeb/ARIA/ARIAMixin.cpp:20 Web::ARIA::ARIAMixin::visit_edges.
## Visits m_cached_<attribute> for each ARIA element-list attribute
## (ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES).
pub func aria_mixin_visit_edges(this: AriaMixin*, visitor: gc.CellVisitor*):
    visit_cached_array(this.m_cached_aria_controls_elements, visitor)
    visit_cached_array(this.m_cached_aria_described_by_elements, visitor)
    visit_cached_array(this.m_cached_aria_details_elements, visitor)
    visit_cached_array(this.m_cached_aria_error_message_elements, visitor)
    visit_cached_array(this.m_cached_aria_flow_to_elements, visitor)
    visit_cached_array(this.m_cached_aria_labelled_by_elements, visitor)
    visit_cached_array(this.m_cached_aria_owns_elements, visitor)

## visitor.visit(m_cached_…) of one cached JS::Array. Only the JS-facing getters (P3) create
## these arrays, so until luce-js wraps the DOM each one is empty and there is nothing to visit.
func visit_cached_array(array: JsArray*?, visitor: gc.CellVisitor*):
    if array != none:
        trap("unported (P3): Web::ARIA::ARIAMixin::visit_edges of a cached JS::Array")