Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / ui_events / ui_event.lucb

#==============================================================================================
#
#   ui_event - UIEvents::UIEvent and UIEvents::FocusEvent
#
#   DESCRIPTION:
#       Port of Libraries/LibWeb/UIEvents/UIEvent.cpp (lines 1-52) with UIEvent.h's inline
#       members, and FocusEvent.cpp (lines 1-39). UIEvent::create and FocusEvent::create keep
#       the signatures their callers had while the classes were stubs (the event as its
#       DOM::Event).
#
#       Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
#       Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

# mark: UIEvent =================================================================================

## Ported from UIEvent.cpp:16 Web::UIEvents::UIEvent::create (the event as its DOM::Event).
pub func ui_events_ui_event_create(realm: Realm*, event_name: ak.FlyString) -> DomEvent*:
    return (DomEvent*)realm_create_ui_events_ui_event(realm, realm, event_name)

## Ported from UIEvent.cpp:21 Web::UIEvents::UIEvent::construct_impl.
pub func ui_events_ui_event_construct_impl(realm: Realm*, event_name: ak.FlyString, event_init: UiEventsUiEventInit) -> UiEventsUiEvent*!:
    return realm_create_ui_events_ui_event_ui_event_init(realm, realm, event_name, event_init)

## Ported from UIEvent.cpp:26 Web::UIEvents::UIEvent::UIEvent(JS::Realm&, FlyString const&).
pub func ui_events_ui_event_construct(this: UiEventsUiEvent*, realm: Realm*, event_name: ak.FlyString):
    dom_event_construct(this.dom_event(), realm, event_name)

## Ported from UIEvent.cpp:31 Web::UIEvents::UIEvent::UIEvent(JS::Realm&, FlyString const&, UIEventInit const&).
pub func ui_events_ui_event_construct_ui_event_init(this: UiEventsUiEvent*, realm: Realm*, event_name: ak.FlyString, event_init: UiEventsUiEventInit):
    dom_event_construct_dom_event_init(this.dom_event(), realm, event_name, event_init.event_init)
    this.m_view = event_init.view
    this.m_detail = event_init.detail

## Ported from UIEvent.cpp:40 Web::UIEvents::UIEvent::initialize (override).
pub func ui_events_ui_event_initialize_impl(base: JsCell*, realm: Realm*):
    web_set_prototype_for_interface(base, realm, BindInterfaceName.ui_event)
    dom_event_initialize_impl(base, realm)

## Ported from UIEvent.cpp:46 Web::UIEvents::UIEvent::visit_edges (override).
pub func ui_events_ui_event_visit_edges_impl(base: gc.Cell*, visitor: gc.CellVisitor*):
    let this = (UiEventsUiEvent*)base
    dom_event_visit_edges_impl(base, visitor)
    gc.cell_visitor_visit_t(visitor, this.m_view)

## Ported from UIEvent.h:31 Web::UIEvents::UIEvent::view.
pub func ui_events_ui_event_view(this: UiEventsUiEvent*) -> HtmlWindowProxy*?:
    return this.m_view

## Ported from UIEvent.h:32 Web::UIEvents::UIEvent::detail.
pub func ui_events_ui_event_detail(this: UiEventsUiEvent*) -> i32:
    return this.m_detail

## Ported from UIEvent.h:33 Web::UIEvents::UIEvent::which (virtual).
pub func ui_events_ui_event_which_impl(this: UiEventsUiEvent*) -> u32:
    return 0

## Ported from UIEvent.h:35 Web::UIEvents::UIEvent::init_ui_event.
pub func ui_events_ui_event_init_ui_event(this: UiEventsUiEvent*, type_: ak.String, bubbles: bool, cancelable: bool, view: HtmlWindowProxy*?, detail: i32):
    # Initializes attributes of an UIEvent object. This method has the same behavior as initEvent().

    # 1. If this’s dispatch flag is set, then return.
    if dom_event_dispatched(this.dom_event()):
        return

    # 2. Initialize this with type, bubbles, and cancelable.
    dom_event_initialize_event(this.dom_event(), type_, bubbles, cancelable)

    # Implementation Defined: Initialise other values.
    this.m_view = view
    this.m_detail = detail

# mark: FocusEvent ==============================================================================

## Ported from FocusEvent.cpp:14 Web::UIEvents::FocusEvent::create (the event as its DOM::Event).
pub func ui_events_focus_event_create(realm: Realm*, event_name: ak.FlyString, event_init: UiEventsFocusEventInit = UiEventsFocusEventInit()) -> DomEvent*:
    return (DomEvent*)realm_create_ui_events_focus_event(realm, realm, event_name, event_init)

## Ported from FocusEvent.cpp:19 Web::UIEvents::FocusEvent::construct_impl.
pub func ui_events_focus_event_construct_impl(realm: Realm*, event_name: ak.FlyString, event_init: UiEventsFocusEventInit) -> DomEvent*!:
    return ui_events_focus_event_create(realm, event_name, event_init)

## Ported from FocusEvent.cpp:24 Web::UIEvents::FocusEvent::FocusEvent.
pub func ui_events_focus_event_construct(this: UiEventsFocusEvent*, realm: Realm*, event_name: ak.FlyString, event_init: UiEventsFocusEventInit):
    ui_events_ui_event_construct_ui_event_init(this.ui_events_ui_event(), realm, event_name, event_init.ui_event_init)
    dom_event_set_related_target(this.dom_event(), event_init.related_target)

## Ported from FocusEvent.cpp:32 Web::UIEvents::FocusEvent::initialize (override).
pub func ui_events_focus_event_initialize_impl(base: JsCell*, realm: Realm*):
    web_set_prototype_for_interface(base, realm, BindInterfaceName.focus_event)
    ui_events_ui_event_initialize_impl(base, realm)