Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.1

0.6.1 / src / web / dom / document_h_2.lucb

#==============================================================================================
#
#   document_h_2 - DOM::Document: the inline functions of Document.h (accessors, part 2)
#
#   DESCRIPTION:
#       Port of the functions defined in LibWeb/DOM/Document.h (lines 656-1121), in the
#       header's order: the style and layout update flags, favicons, initial about:blank,
#       the pending scroll events, the load timing info, the script lists, the execCommand
#       state and value overrides, the iteration templates over shadow roots, and the
#       private template notify_each_document_observer (as one function per notifier, at
#       the end).
#
#==============================================================================================

# mark: Accessors (continued) ===================================================================

## Ported from Document.h:656 Web::DOM::Document::needs_full_style_update.
pub func dom_document_needs_full_style_update(this: DomDocument*) -> bool:
    return this.m_needs_full_style_update

## Ported from Document.h:657 Web::DOM::Document::set_needs_full_style_update.
pub func dom_document_set_needs_full_style_update(this: DomDocument*, b: bool):
    this.m_needs_full_style_update = b

## Ported from Document.h:659 Web::DOM::Document::needs_full_layout_tree_update.
pub func dom_document_needs_full_layout_tree_update(this: DomDocument*) -> bool:
    return this.m_needs_full_layout_tree_update

## Ported from Document.h:660 Web::DOM::Document::set_needs_full_layout_tree_update.
pub func dom_document_set_needs_full_layout_tree_update(this: DomDocument*, b: bool):
    this.m_needs_full_layout_tree_update = b

## Ported from Document.h:666 Web::DOM::Document::has_active_favicon.
pub func dom_document_has_active_favicon(this: DomDocument*) -> bool:
    return this.m_active_favicon != none

## Ported from Document.h:673 Web::DOM::Document::is_initial_about_blank.
pub func dom_document_is_initial_about_blank(this: DomDocument*) -> bool:
    return this.m_is_initial_about_blank

## Ported from Document.h:674 Web::DOM::Document::set_is_initial_about_blank.
pub func dom_document_set_is_initial_about_blank(this: DomDocument*, b: bool):
    this.m_is_initial_about_blank = b

## Ported from Document.h:677 Web::DOM::Document::about_base_url.
pub func dom_document_about_base_url(this: DomDocument*) -> web_url.Url?:
    return this.m_about_base_url

## Ported from Document.h:678 Web::DOM::Document::set_about_base_url.
pub func dom_document_set_about_base_url(this: DomDocument*, url: web_url.Url?):
    this.m_about_base_url = url

## Ported from Document.h:688 Web::DOM::Document::pending_scroll_events.
pub func dom_document_pending_scroll_events(this: DomDocument*) -> ak.Vector[DomDocumentPendingScrollEvent]*:
    return &this.m_pending_scroll_events

## Ported from Document.h:713 Web::DOM::Document::has_been_destroyed.
pub func dom_document_has_been_destroyed(this: DomDocument*) -> bool:
    return this.m_has_been_destroyed

## Ported from Document.h:734 Web::DOM::Document::load_timing_info.
pub func dom_document_load_timing_info(this: DomDocument*) -> DomDocumentLoadTimingInfo*:
    return &this.m_load_timing_info

## Ported from Document.h:735 Web::DOM::Document::load_timing_info.
pub func dom_document_load_timing_info_const(this: DomDocument*) -> DomDocumentLoadTimingInfo:
    return this.m_load_timing_info

## Ported from Document.h:736 Web::DOM::Document::set_load_timing_info.
pub func dom_document_set_load_timing_info(this: DomDocument*, load_timing_info: DomDocumentLoadTimingInfo):
    this.m_load_timing_info = load_timing_info

## Ported from Document.h:739 Web::DOM::Document::previous_document_unload_timing.
pub func dom_document_previous_document_unload_timing(this: DomDocument*) -> DomDocumentUnloadTimingInfo*:
    return &this.m_previous_document_unload_timing

## Ported from Document.h:740 Web::DOM::Document::previous_document_unload_timing.
pub func dom_document_previous_document_unload_timing_const(this: DomDocument*) -> DomDocumentUnloadTimingInfo:
    return this.m_previous_document_unload_timing

## Ported from Document.h:741 Web::DOM::Document::set_previous_document_unload_timing.
pub func dom_document_set_previous_document_unload_timing(this: DomDocument*, previous_document_unload_timing: DomDocumentUnloadTimingInfo):
    this.m_previous_document_unload_timing = previous_document_unload_timing

## Ported from Document.h:756 Web::DOM::Document::has_scheduled_selectionchange_event.
pub func dom_document_has_scheduled_selectionchange_event(this: DomDocument*) -> bool:
    return this.m_has_scheduled_selectionchange_event

## Ported from Document.h:757 Web::DOM::Document::set_scheduled_selectionchange_event.
pub func dom_document_set_scheduled_selectionchange_event(this: DomDocument*, value: bool):
    this.m_has_scheduled_selectionchange_event = value

## Ported from Document.h:770 Web::DOM::Document::set_salvageable.
pub func dom_document_set_salvageable(this: DomDocument*, value: bool):
    this.m_salvageable = value

## Ported from Document.h:778 Web::DOM::Document::map_of_preloaded_resources.
pub func dom_document_map_of_preloaded_resources(this: DomDocument*) -> ak.HashMap[HtmlPreloadKey, HtmlPreloadEntry*, HtmlPreloadKeyTraits]*:
    return &this.m_map_of_preloaded_resources

## Ported from Document.h:779 Web::DOM::Document::map_of_preloaded_resources.
pub func dom_document_map_of_preloaded_resources_const(this: DomDocument*) -> const ak.HashMap[HtmlPreloadKey, HtmlPreloadEntry*, HtmlPreloadKeyTraits]*:
    return &this.m_map_of_preloaded_resources

## Ported from Document.h:782 Web::DOM::Document::has_speculative_fetch_url.
pub func dom_document_has_speculative_fetch_url(this: DomDocument*, url: web_url.Url) -> bool:
    return ak.hash_table_contains_t(&this.m_list_of_speculative_fetch_urls, url)

## Ported from Document.h:783 Web::DOM::Document::add_speculative_fetch_url.
pub func dom_document_add_speculative_fetch_url(this: DomDocument*, url: web_url.Url):
    _ = ak.hash_table_set(&this.m_list_of_speculative_fetch_urls, url)

## Ported from Document.h:802 Web::DOM::Document::unload_counter.
pub func dom_document_unload_counter(this: DomDocument*) -> u32:
    return this.m_unload_counter

## Ported from Document.h:813 Web::DOM::Document::last_animation_frame_timestamp.
pub func dom_document_last_animation_frame_timestamp(this: DomDocument*) -> f64?:
    return this.m_last_animation_frame_timestamp

## Ported from Document.h:830 Web::DOM::Document::ready_to_run_scripts.
pub func dom_document_ready_to_run_scripts(this: DomDocument*) -> bool:
    return this.m_ready_to_run_scripts

## Ported from Document.h:833 Web::DOM::Document::has_deferred_parser_start.
pub func dom_document_has_deferred_parser_start(this: DomDocument*) -> bool:
    return this.m_deferred_parser_start != none

## Ported from Document.h:845 Web::DOM::Document::anchor_name_map.
pub func dom_document_anchor_name_map(this: DomDocument*) -> DomAnchorNameMap*:
    return &this.m_anchor_name_map

## Ported from Document.h:851 Web::DOM::Document::design_mode_enabled_state.
pub func dom_document_design_mode_enabled_state(this: DomDocument*) -> bool:
    return this.m_design_mode_enabled

## Ported from Document.h:862 Web::DOM::Document::set_needs_invalidation_of_elements_affected_by_has.
pub func dom_document_set_needs_invalidation_of_elements_affected_by_has(this: DomDocument*):
    this.m_needs_invalidation_of_elements_affected_by_has = true

## Ported from Document.h:881 Web::DOM::Document::style_invalidation_counters.
pub func dom_document_style_invalidation_counters(this: DomDocument*) -> DomDocumentStyleInvalidationCounters*:
    return &this.m_style_invalidation_counters

## Ported from Document.h:887 Web::DOM::Document::set_needs_accumulated_visual_contexts_update.
pub func dom_document_set_needs_accumulated_visual_contexts_update(this: DomDocument*, value: bool):
    this.m_needs_accumulated_visual_contexts_update = value

## Ported from Document.h:888 Web::DOM::Document::needs_accumulated_visual_contexts_update.
pub func dom_document_needs_accumulated_visual_contexts_update(this: DomDocument*) -> bool:
    return this.m_needs_accumulated_visual_contexts_update

## Ported from Document.h:892 Web::DOM::Document::potentially_named_elements.
pub func dom_document_potentially_named_elements(this: DomDocument*) -> const ak.Vector[DomElement*]*:
    return &this.m_potentially_named_elements

## Ported from Document.h:905 Web::DOM::Document::for_each_shadow_root.
pub func dom_document_for_each_shadow_root(this: DomDocument*, callback: ak.Function1[DomShadowRoot*, unit]):
    for shadow_root in ak.intrusive_list_begin(&this.m_shadow_roots):
        ak.function1_call(&callback, shadow_root)

## Ported from Document.h:912 Web::DOM::Document::for_each_shadow_root.
pub func dom_document_for_each_shadow_root_const(this: DomDocument*, callback: ak.Function1[DomShadowRoot*, unit]):
    for shadow_root in ak.intrusive_list_begin(&this.m_shadow_roots):
        ak.function1_call(&callback, shadow_root)

## Ported from Document.h:923 Web::DOM::Document::top_layer_elements.
pub func dom_document_top_layer_elements(this: DomDocument*) -> const ak.OrderedHashTable[DomElement*, ak.PtrTraits[DomElement]]*:
    return &this.m_top_layer_elements

## Ported from Document.h:927 Web::DOM::Document::showing_auto_popover_list.
pub func dom_document_showing_auto_popover_list(this: DomDocument*) -> ak.Vector[HtmlElement*]*:
    return &this.m_showing_auto_popover_list

## Ported from Document.h:928 Web::DOM::Document::showing_hint_popover_list.
pub func dom_document_showing_hint_popover_list(this: DomDocument*) -> ak.Vector[HtmlElement*]*:
    return &this.m_showing_hint_popover_list

## Ported from Document.h:929 Web::DOM::Document::showing_auto_popover_list.
pub func dom_document_showing_auto_popover_list_const(this: DomDocument*) -> const ak.Vector[HtmlElement*]*:
    return &this.m_showing_auto_popover_list

## Ported from Document.h:930 Web::DOM::Document::showing_hint_popover_list.
pub func dom_document_showing_hint_popover_list_const(this: DomDocument*) -> const ak.Vector[HtmlElement*]*:
    return &this.m_showing_hint_popover_list

## Ported from Document.h:934 Web::DOM::Document::set_popover_pointerdown_target.
pub func dom_document_set_popover_pointerdown_target(this: DomDocument*, target: HtmlElement*?):
    this.m_popover_pointerdown_target = target

## Ported from Document.h:935 Web::DOM::Document::popover_pointerdown_target.
pub func dom_document_popover_pointerdown_target(this: DomDocument*) -> HtmlElement*?:
    return this.m_popover_pointerdown_target

## Ported from Document.h:937 Web::DOM::Document::open_dialogs_list.
pub func dom_document_open_dialogs_list(this: DomDocument*) -> ak.Vector[HtmlDialogElement*]*:
    return &this.m_open_dialogs_list

## Ported from Document.h:939 Web::DOM::Document::set_dialog_pointerdown_target.
pub func dom_document_set_dialog_pointerdown_target(this: DomDocument*, target: HtmlDialogElement*?):
    this.m_dialog_pointerdown_target = target

## Ported from Document.h:940 Web::DOM::Document::dialog_pointerdown_target.
pub func dom_document_dialog_pointerdown_target(this: DomDocument*) -> HtmlDialogElement*?:
    return this.m_dialog_pointerdown_target

## Ported from Document.h:942 Web::DOM::Document::transition_generation.
pub func dom_document_transition_generation(this: DomDocument*) -> usize:
    return this.m_transition_generation

## Ported from Document.h:945 Web::DOM::Document::is_decoded_svg.
pub func dom_document_is_decoded_svg(this: DomDocument*) -> bool:
    return this.m_is_decoded_svg

## Ported from Document.h:952 Web::DOM::Document::set_console_client.
pub func dom_document_set_console_client(this: DomDocument*, console_client: JsConsoleClient*?):
    this.m_console_client = console_client

## Ported from Document.h:953 Web::DOM::Document::console_client.
pub func dom_document_console_client(this: DomDocument*) -> JsConsoleClient*?:
    return this.m_console_client

## Ported from Document.h:958 Web::DOM::Document::cursor_blink_state.
pub func dom_document_cursor_blink_state(this: DomDocument*) -> bool:
    return this.m_cursor_blink_state

## Ported from Document.h:966 Web::DOM::Document::set_needs_repaint.
pub func dom_document_set_needs_repaint_t(this: DomDocument*, should_invalidate_display_list: InvalidateDisplayList = InvalidateDisplayList.yes):
    dom_document_set_needs_repaint_invalidate_display_list(this, should_invalidate_display_list)

## Ported from Document.h:1007 Web::DOM::Document::active_view_transition.
pub func dom_document_active_view_transition(this: DomDocument*) -> ViewTransitionViewTransition*?:
    return this.m_active_view_transition

## Ported from Document.h:1008 Web::DOM::Document::set_active_view_transition.
pub func dom_document_set_active_view_transition(this: DomDocument*, view_transition: ViewTransitionViewTransition*?):
    this.m_active_view_transition = view_transition

## Ported from Document.h:1009 Web::DOM::Document::rendering_suppression_for_view_transitions.
pub func dom_document_rendering_suppression_for_view_transitions(this: DomDocument*) -> bool:
    return this.m_rendering_suppression_for_view_transitions

## Ported from Document.h:1011 Web::DOM::Document::dynamic_view_transition_style_sheet.
pub func dom_document_dynamic_view_transition_style_sheet(this: DomDocument*) -> CssCssStyleSheet*?:
    return this.m_dynamic_view_transition_style_sheet

## Ported from Document.h:1012 Web::DOM::Document::set_show_view_transition_tree.
pub func dom_document_set_show_view_transition_tree(this: DomDocument*, value: bool):
    this.m_show_view_transition_tree = value

## Ported from Document.h:1013 Web::DOM::Document::update_callback_queue.
pub func dom_document_update_callback_queue(this: DomDocument*) -> ak.Vector[ViewTransitionViewTransition*?]*:
    return &this.m_update_callback_queue

## Ported from Document.h:1017 Web::DOM::Document::editing_host_manager.
pub func dom_document_editing_host_manager(this: DomDocument*) -> DomEditingHostManager*:
    return this.m_editing_host_manager

## Ported from Document.h:1020 Web::DOM::Document::default_single_line_container_name.
pub func dom_document_default_single_line_container_name(this: DomDocument*) -> ak.FlyString:
    return this.m_default_single_line_container_name

## Ported from Document.h:1021 Web::DOM::Document::set_default_single_line_container_name.
pub func dom_document_set_default_single_line_container_name(this: DomDocument*, name: ak.FlyString):
    this.m_default_single_line_container_name = name

## Ported from Document.h:1024 Web::DOM::Document::css_styling_flag.
pub func dom_document_css_styling_flag(this: DomDocument*) -> bool:
    return this.m_css_styling_flag

## Ported from Document.h:1025 Web::DOM::Document::set_css_styling_flag.
pub func dom_document_set_css_styling_flag(this: DomDocument*, flag: bool):
    this.m_css_styling_flag = flag

## Ported from Document.h:1028 Web::DOM::Document::command_state_override.
pub func dom_document_command_state_override(this: DomDocument*, command: ak.FlyString) -> bool?:
    let state = ak.hash_map_get_k(&this.m_command_state_override, command) else return none
    return *state

## Ported from Document.h:1029 Web::DOM::Document::set_command_state_override.
pub func dom_document_set_command_state_override(this: DomDocument*, command: ak.FlyString, state: bool):
    _ = ak.hash_map_set(&this.m_command_state_override, command, state)

## Ported from Document.h:1030 Web::DOM::Document::clear_command_state_override.
pub func dom_document_clear_command_state_override(this: DomDocument*, command: ak.FlyString):
    _ = ak.hash_map_remove_k(&this.m_command_state_override, command)

## Ported from Document.h:1031 Web::DOM::Document::reset_command_state_overrides.
pub func dom_document_reset_command_state_overrides(this: DomDocument*):
    ak.hash_map_clear(&this.m_command_state_override)

## Ported from Document.h:1034 Web::DOM::Document::command_value_override.
pub func dom_document_command_value_override(this: DomDocument*, command: ak.FlyString) -> const ak.Utf16String*?:
    return ak.hash_map_get_k(&this.m_command_value_override, command)

## Ported from Document.h:1037 Web::DOM::Document::reset_command_value_overrides.
pub func dom_document_reset_command_value_overrides(this: DomDocument*):
    ak.hash_map_clear(&this.m_command_value_override)

## Ported from Document.h:1041 Web::DOM::Document::session_storage_holder.
pub func dom_document_session_storage_holder(this: DomDocument*) -> HtmlStorage*?:
    return this.m_session_storage_holder

## Ported from Document.h:1042 Web::DOM::Document::set_session_storage_holder.
pub func dom_document_set_session_storage_holder(this: DomDocument*, storage: HtmlStorage*?):
    this.m_session_storage_holder = storage

## Ported from Document.h:1044 Web::DOM::Document::local_storage_holder.
pub func dom_document_local_storage_holder(this: DomDocument*) -> HtmlStorage*?:
    return this.m_local_storage_holder

## Ported from Document.h:1045 Web::DOM::Document::set_local_storage_holder.
pub func dom_document_set_local_storage_holder(this: DomDocument*, storage: HtmlStorage*?):
    this.m_local_storage_holder = storage

## Ported from Document.h:1078 Web::DOM::Document::script_blocking_style_sheet_set.
pub func dom_document_script_blocking_style_sheet_set(this: DomDocument*) -> ak.HashTable[DomElement*, ak.PtrTraits[DomElement]]*:
    return &this.m_script_blocking_style_sheet_set

## Ported from Document.h:1079 Web::DOM::Document::script_blocking_style_sheet_set.
pub func dom_document_script_blocking_style_sheet_set_const(this: DomDocument*) -> const ak.HashTable[DomElement*, ak.PtrTraits[DomElement]]*:
    return &this.m_script_blocking_style_sheet_set

## Ported from Document.h:1084 Web::DOM::Document::style_invalidator.
pub func dom_document_style_invalidator(this: DomDocument*) -> CssStyleInvalidator*:
    return this.m_style_invalidator

## Ported from Document.h:1092 Web::DOM::Document::custom_property_registration_generation.
pub func dom_document_custom_property_registration_generation(this: DomDocument*) -> usize:
    return this.m_custom_property_registration_generation

## Ported from Document.h:1095 Web::DOM::Document::style_scope.
pub func dom_document_style_scope_const(this: DomDocument*) -> const CssStyleScope*:
    return &this.m_style_scope

## Ported from Document.h:1096 Web::DOM::Document::style_scope.
pub func dom_document_style_scope(this: DomDocument*) -> CssStyleScope*:
    return &this.m_style_scope

## Ported from Document.h:1103 Web::DOM::Document::set_custom_element_registry.
pub func dom_document_set_custom_element_registry(this: DomDocument*, custom_element_registry: HtmlCustomElementRegistry*?):
    this.m_custom_element_registry = custom_element_registry

## Ported from Document.h:1118 Web::DOM::Document::is_dom_document (virtual).
pub func dom_document_is_dom_document_impl(this: DomDocument*) -> bool:
    return true

## Ported from Document.h:1121 Web::DOM::Document::global_event_handlers_to_event_target (override).
pub func dom_document_global_event_handlers_to_event_target_impl(base: HtmlGlobalEventHandlers*, arg0: ak.FlyString) -> DomEventTarget*?:
    # `return *this;`: the mixin is embedded in the Document it belongs to.
    let this = (DomDocument*)((u8*)base - memory.offset_of(DomDocument, global_event_handlers))
    return this.dom_event_target()

# mark: notify_each_document_observer ===========================================================

# Ported from Document.h:1146 Web::DOM::Document::notify_each_document_observer, a template over the
# observer's notifier getter: the observers are copied into m_document_observers_being_notified
# (so they stay alive while notified), each one's notifier is called, and the list is cleared on
# exit (ScopeGuard). The notifiers are read from the observer's fields, as its getters do.

## The first half of notify_each_document_observer: copy the observers to notify.
func dom_document_begin_notifying_document_observers(this: DomDocument*):
    ak.vector_ensure_capacity(&this.m_document_observers_being_notified, ak.hash_table_size(&this.m_document_observers))

    for observer in ak.hash_table_begin(&this.m_document_observers):
        ak.vector_unchecked_append_u(&this.m_document_observers_being_notified, *observer)

## The ScopeGuard of notify_each_document_observer.
func dom_document_end_notifying_document_observers(this: DomDocument*):
    ak.vector_clear_with_capacity(&this.m_document_observers_being_notified)

## notify_each_document_observer with document_readiness_observer() and the readiness.
func dom_document_notify_document_observers_of_readiness(this: DomDocument*, readiness: HtmlDocumentReadyState):
    defer dom_document_end_notifying_document_observers(this)
    dom_document_begin_notifying_document_observers(this)
    for document_observer in ak.vector_span(&this.m_document_observers_being_notified):
        if let notifier = document_observer.m_document_readiness_observer:
            ak.function1_call(&notifier.function, readiness)

## notify_each_document_observer with document_completely_loaded().
func dom_document_notify_document_observers_completely_loaded(this: DomDocument*):
    defer dom_document_end_notifying_document_observers(this)
    dom_document_begin_notifying_document_observers(this)
    for document_observer in ak.vector_span(&this.m_document_observers_being_notified):
        if let notifier = document_observer.m_document_completely_loaded:
            ak.function0_call(&notifier.function)

## notify_each_document_observer with document_became_active().
func dom_document_notify_document_observers_became_active(this: DomDocument*):
    defer dom_document_end_notifying_document_observers(this)
    dom_document_begin_notifying_document_observers(this)
    for document_observer in ak.vector_span(&this.m_document_observers_being_notified):
        if let notifier = document_observer.m_document_became_active:
            ak.function0_call(&notifier.function)

## notify_each_document_observer with document_became_inactive().
func dom_document_notify_document_observers_became_inactive(this: DomDocument*):
    defer dom_document_end_notifying_document_observers(this)
    dom_document_begin_notifying_document_observers(this)
    for document_observer in ak.vector_span(&this.m_document_observers_being_notified):
        if let notifier = document_observer.m_document_became_inactive:
            ak.function0_call(&notifier.function)

## notify_each_document_observer with document_visibility_state_observer() and the visibility state.
func dom_document_notify_document_observers_of_visibility_state(this: DomDocument*, visibility_state: HtmlVisibilityState):
    defer dom_document_end_notifying_document_observers(this)
    dom_document_begin_notifying_document_observers(this)
    for document_observer in ak.vector_span(&this.m_document_observers_being_notified):
        if let notifier = document_observer.m_document_visibility_state_observer:
            ak.function1_call(&notifier.function, visibility_state)

## notify_each_document_observer with document_page_showing_observer() and the page showing flag.
func dom_document_notify_document_observers_of_page_showing(this: DomDocument*, page_showing: bool):
    defer dom_document_end_notifying_document_observers(this)
    dom_document_begin_notifying_document_observers(this)
    for document_observer in ak.vector_span(&this.m_document_observers_being_notified):
        if let notifier = document_observer.m_document_page_showing_observer:
            ak.function1_call(&notifier.function, page_showing)