dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / dom / static_range.lucb
#==============================================================================================
#
# static_range - DOM::StaticRange: a range that does not follow DOM mutations
#
# DESCRIPTION:
# Port of LibWeb/DOM/StaticRange.cpp (lines 1-47).
#
#==============================================================================================
## Ported from StaticRange.cpp:20 Web::DOM::StaticRange::StaticRange.
pub func dom_static_range_construct(this: DomStaticRange*, start_container: DomNode*, start_offset: u32, end_container: DomNode*, end_offset: u32):
dom_abstract_range_construct(this.dom_abstract_range(), start_container, start_offset, end_container, end_offset)
## Ported from StaticRange.cpp:28 Web::DOM::StaticRange::construct_impl.
# https://dom.spec.whatwg.org/#dom-staticrange-staticrange
pub func dom_static_range_construct_impl(realm: Realm*, init: DomStaticRangeInit*) -> DomStaticRange*!:
let start_container = init.start_container else trap("VERIFY: startContainer")
let end_container = init.end_container else trap("VERIFY: endContainer")
# 1. If init["startContainer"] or init["endContainer"] is a DocumentType or Attr node, then throw an "InvalidNodeTypeError" DOMException.
if is_dom_document_type(start_container) or is_dom_attr(start_container):
try idl_throw(.idl_dom_exception(idl_invalid_node_type_error_create(realm, ak.utf16_string_from_str("startContainer cannot be a DocumentType or Attribute node."))))
if is_dom_document_type(end_container) or is_dom_attr(end_container):
try idl_throw(.idl_dom_exception(idl_invalid_node_type_error_create(realm, ak.utf16_string_from_str("endContainer cannot be a DocumentType or Attribute node."))))
# 2. Set this’s start to (init["startContainer"], init["startOffset"]) and end to (init["endContainer"], init["endOffset"]).
return realm_create_dom_static_range(realm, start_container, init.start_offset, end_container, init.end_offset)
## Ported from StaticRange.cpp:41 Web::DOM::StaticRange::initialize (override).
pub func dom_static_range_initialize_impl(base: JsCell*, realm: Realm*):
web_set_prototype_for_interface(base, realm, BindInterfaceName.static_range)
dom_abstract_range_initialize_impl(base, realm)