dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / dom / static_node_list.lucb
#==============================================================================================
#
# static_node_list - DOM::StaticNodeList: a NodeList over a fixed list of nodes
#
# DESCRIPTION:
# Port of LibWeb/DOM/StaticNodeList.cpp (lines 1-51).
#
#==============================================================================================
## Ported from StaticNodeList.cpp:16 Web::DOM::StaticNodeList::create.
pub func dom_static_node_list_create(realm: Realm*, static_nodes: ak.Vector[DomNode*?]) -> DomNodeList*:
return realm_create_dom_static_node_list(realm, realm, static_nodes).dom_node_list()
## Ported from StaticNodeList.cpp:21 Web::DOM::StaticNodeList::StaticNodeList.
pub func dom_static_node_list_construct(this: DomStaticNodeList*, realm: Realm*, static_nodes: ak.Vector[DomNode*?]):
dom_node_list_construct(this.dom_node_list(), realm)
for node in ak.vector_span_const(&static_nodes):
ak.vector_append_t(&this.m_static_nodes, node else trap("VERIFY: GC::Root<Node> is not null"))
## Ported from StaticNodeList.cpp:30 Web::DOM::StaticNodeList::visit_edges (override).
pub func dom_static_node_list_visit_edges_impl(base: gc.Cell*, visitor: gc.CellVisitor*):
let this = (DomStaticNodeList*)base
bind_platform_object_visit_edges_impl(base, visitor)
gc.cell_visitor_visit_vector(visitor, &this.m_static_nodes)
## Ported from StaticNodeList.cpp:37 Web::DOM::StaticNodeList::length (override).
# https://dom.spec.whatwg.org/#dom-nodelist-length
pub func dom_static_node_list_length_impl(base: DomNodeList*) -> u32:
let this = (DomStaticNodeList*)base
return (u32)ak.vector_size(&this.m_static_nodes)
## Ported from StaticNodeList.cpp:43 Web::DOM::StaticNodeList::item (override).
# https://dom.spec.whatwg.org/#dom-nodelist-item
pub func dom_static_node_list_item_impl(base: DomNodeList*, index: u32) -> DomNode*?:
let this = (DomStaticNodeList*)base
# The item(index) method must return the indexth node in the collection. If there is no indexth node in the collection, then the method must return null.
if (usize)index >= ak.vector_size(&this.m_static_nodes):
return none
return *ak.vector_at(&this.m_static_nodes, (usize)index)