Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / dom / abstract_range.lucb

#==============================================================================================
#
#   abstract_range - DOM::AbstractRange: the boundary points shared by Range and StaticRange
#
#   DESCRIPTION:
#       Port of LibWeb/DOM/AbstractRange.cpp (lines 1-38) and the inline functions of
#       AbstractRange.h.
#
#==============================================================================================

## Ported from AbstractRange.cpp:14 Web::DOM::AbstractRange::AbstractRange.
pub func dom_abstract_range_construct(this: DomAbstractRange*, start_container: DomNode*, start_offset: u32, end_container: DomNode*, end_offset: u32):
    bind_platform_object_construct_realm(this.bind_platform_object(), bind_platform_object_realm(start_container.bind_platform_object()))
    this.m_start_container = start_container
    this.m_start_offset = start_offset
    this.m_end_container = end_container
    this.m_end_offset = end_offset

## Ported from AbstractRange.cpp:25 Web::DOM::AbstractRange::initialize (override).
pub func dom_abstract_range_initialize_impl(base: JsCell*, realm: Realm*):
    web_set_prototype_for_interface(base, realm, BindInterfaceName.abstract_range)
    # Base::initialize(realm): PlatformObject inherits JS::Object's.
    js_cell_initialize_impl(base, realm)

## Ported from AbstractRange.cpp:31 Web::DOM::AbstractRange::visit_edges (override).
pub func dom_abstract_range_visit_edges_impl(base: gc.Cell*, visitor: gc.CellVisitor*):
    let this = (DomAbstractRange*)base
    bind_platform_object_visit_edges_impl(base, visitor)
    gc.cell_visitor_visit_t_2(visitor, this.m_start_container)
    gc.cell_visitor_visit_t_2(visitor, this.m_end_container)

# mark: AbstractRange.h =========================================================================

## Ported from AbstractRange.h:30 Web::DOM::AbstractRange::start.
pub func dom_abstract_range_start(this: DomAbstractRange*) -> DomBoundaryPoint:
    return DomBoundaryPoint(node = this.m_start_container, offset = this.m_start_offset)

## Ported from AbstractRange.h:31 Web::DOM::AbstractRange::start_container.
pub func dom_abstract_range_start_container(this: DomAbstractRange*) -> DomNode*:
    return this.m_start_container

## Ported from AbstractRange.h:32 Web::DOM::AbstractRange::start_offset.
pub func dom_abstract_range_start_offset(this: DomAbstractRange*) -> u32:
    return this.m_start_offset

## Ported from AbstractRange.h:34 Web::DOM::AbstractRange::end.
pub func dom_abstract_range_end(this: DomAbstractRange*) -> DomBoundaryPoint:
    return DomBoundaryPoint(node = this.m_end_container, offset = this.m_end_offset)

## Ported from AbstractRange.h:35 Web::DOM::AbstractRange::end_container.
pub func dom_abstract_range_end_container(this: DomAbstractRange*) -> DomNode*:
    return this.m_end_container

## Ported from AbstractRange.h:36 Web::DOM::AbstractRange::end_offset.
pub func dom_abstract_range_end_offset(this: DomAbstractRange*) -> u32:
    return this.m_end_offset

## Ported from AbstractRange.h:39 Web::DOM::AbstractRange::collapsed.
# https://dom.spec.whatwg.org/#range-collapsed
pub func dom_abstract_range_collapsed(this: DomAbstractRange*) -> bool:
    # A range is collapsed if its start node is its end node and its start offset is its end offset.
    return dom_abstract_range_start_container(this) == dom_abstract_range_end_container(this) and dom_abstract_range_start_offset(this) == dom_abstract_range_end_offset(this)

## Ported from AbstractRange.h:45 Web::DOM::AbstractRange::operator==.
pub func dom_abstract_range_eq(this: DomAbstractRange*, other: DomAbstractRange*) -> bool:
    return dom_abstract_range_start_container(this) == dom_abstract_range_start_container(other) and dom_abstract_range_start_offset(this) == dom_abstract_range_start_offset(other) and dom_abstract_range_end_container(this) == dom_abstract_range_end_container(other) and dom_abstract_range_end_offset(this) == dom_abstract_range_end_offset(other)