Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / html / document_state.lucb

#==============================================================================================
#
#   document_state - HTML::DocumentState and HTML::SessionHistoryEntry: the document state of a
#   session history entry, and the entry
#
#   DESCRIPTION:
#       Port of Libraries/LibWeb/HTML/DocumentState.cpp (lines 1-17) with DocumentState.h's
#       inline accessors, and of SessionHistoryEntry.cpp (lines 1-33) with SessionHistoryEntry.h's
#       inline accessors. Both are RefCounted in C++: managed memory here (DESIGN.md ยง3.3).
#
#       Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

# mark: DocumentState ===========================================================================

## Ported from DocumentState.h:24 Web::HTML::DocumentState::create.
pub func html_document_state_create() -> HtmlDocumentState*:
    let this = new HtmlDocumentState(m_history_policy_container = HtmlSerializedPolicyContainerOrHtmlDocumentStateClient.html_document_state_client(HtmlDocumentStateClient.tag), m_request_referrer = FetchRequestReferrerType.fetch_request_referrer(FetchRequestReferrer.client), m_resource = EmptyOrStringOrHtmlPostResource.empty) else trap("out of memory")
    html_document_state_construct(this)
    return this

## Ported from DocumentState.cpp:13 Web::HTML::DocumentState::DocumentState (`= default`: the
## default member initializers).
pub func html_document_state_construct(this: HtmlDocumentState*):
    this.m_history_policy_container = HtmlSerializedPolicyContainerOrHtmlDocumentStateClient.html_document_state_client(HtmlDocumentStateClient.tag)
    this.m_request_referrer = FetchRequestReferrerType.fetch_request_referrer(FetchRequestReferrer.client)
    this.m_request_referrer_policy = referrer_policy_default_referrer_policy
    this.m_about_base_url = none
    this.m_resource = EmptyOrStringOrHtmlPostResource.empty
    this.m_reload_pending = false
    this.m_ever_populated = false

## Ported from DocumentState.h:36 Web::HTML::DocumentState::document_id.
pub func html_document_state_document_id(this: const HtmlDocumentState*) -> i64?:
    return this.m_document_id

## Ported from DocumentState.h:37 Web::HTML::DocumentState::set_document_id.
pub func html_document_state_set_document_id(this: HtmlDocumentState*, document_id: i64?):
    this.m_document_id = document_id

## Ported from DocumentState.h:39 Web::HTML::DocumentState::history_policy_container.
pub func html_document_state_history_policy_container(this: const HtmlDocumentState*) -> HtmlSerializedPolicyContainerOrHtmlDocumentStateClient:
    return this.m_history_policy_container

## Ported from DocumentState.h:40 Web::HTML::DocumentState::set_history_policy_container.
pub func html_document_state_set_history_policy_container(this: HtmlDocumentState*, history_policy_container: HtmlSerializedPolicyContainerOrHtmlDocumentStateClient):
    this.m_history_policy_container = history_policy_container

## Ported from DocumentState.h:42 Web::HTML::DocumentState::request_referrer.
pub func html_document_state_request_referrer(this: const HtmlDocumentState*) -> FetchRequestReferrerType:
    return this.m_request_referrer

## Ported from DocumentState.h:43 Web::HTML::DocumentState::set_request_referrer.
pub func html_document_state_set_request_referrer(this: HtmlDocumentState*, request_referrer: FetchRequestReferrerType):
    this.m_request_referrer = request_referrer

## Ported from DocumentState.h:45 Web::HTML::DocumentState::request_referrer_policy.
pub func html_document_state_request_referrer_policy(this: const HtmlDocumentState*) -> ReferrerPolicyReferrerPolicy:
    return this.m_request_referrer_policy

## Ported from DocumentState.h:46 Web::HTML::DocumentState::set_request_referrer_policy.
pub func html_document_state_set_request_referrer_policy(this: HtmlDocumentState*, request_referrer_policy: ReferrerPolicyReferrerPolicy):
    this.m_request_referrer_policy = request_referrer_policy

## Ported from DocumentState.h:48 Web::HTML::DocumentState::initiator_origin.
pub func html_document_state_initiator_origin(this: const HtmlDocumentState*) -> web_url.Origin?:
    return this.m_initiator_origin

## Ported from DocumentState.h:49 Web::HTML::DocumentState::set_initiator_origin.
pub func html_document_state_set_initiator_origin(this: HtmlDocumentState*, initiator_origin: web_url.Origin?):
    this.m_initiator_origin = initiator_origin

## Ported from DocumentState.h:51 Web::HTML::DocumentState::origin.
pub func html_document_state_origin(this: const HtmlDocumentState*) -> web_url.Origin?:
    return this.m_origin

## Ported from DocumentState.h:52 Web::HTML::DocumentState::set_origin.
pub func html_document_state_set_origin(this: HtmlDocumentState*, origin: web_url.Origin?):
    this.m_origin = origin

## Ported from DocumentState.h:54 Web::HTML::DocumentState::about_base_url.
pub func html_document_state_about_base_url(this: const HtmlDocumentState*) -> web_url.Url?:
    return this.m_about_base_url

## Ported from DocumentState.h:55 Web::HTML::DocumentState::set_about_base_url.
pub func html_document_state_set_about_base_url(this: HtmlDocumentState*, url: web_url.Url?):
    this.m_about_base_url = url

## Ported from DocumentState.h:57 Web::HTML::DocumentState::nested_histories (const).
pub func html_document_state_nested_histories_const(this: const HtmlDocumentState*) -> ak.Vector[HtmlDocumentStateNestedHistory]:
    return this.m_nested_histories

## Ported from DocumentState.h:58 Web::HTML::DocumentState::nested_histories.
pub func html_document_state_nested_histories(this: HtmlDocumentState*) -> ak.Vector[HtmlDocumentStateNestedHistory]*:
    return &this.m_nested_histories

## Ported from DocumentState.h:60 Web::HTML::DocumentState::resource.
pub func html_document_state_resource(this: const HtmlDocumentState*) -> EmptyOrStringOrHtmlPostResource:
    return this.m_resource

## Ported from DocumentState.h:61 Web::HTML::DocumentState::set_resource.
pub func html_document_state_set_resource(this: HtmlDocumentState*, resource: EmptyOrStringOrHtmlPostResource):
    this.m_resource = resource

## Ported from DocumentState.h:63 Web::HTML::DocumentState::reload_pending.
pub func html_document_state_reload_pending(this: const HtmlDocumentState*) -> bool:
    return this.m_reload_pending

## Ported from DocumentState.h:64 Web::HTML::DocumentState::set_reload_pending.
pub func html_document_state_set_reload_pending(this: HtmlDocumentState*, reload_pending: bool):
    this.m_reload_pending = reload_pending

## Ported from DocumentState.h:66 Web::HTML::DocumentState::ever_populated.
pub func html_document_state_ever_populated(this: const HtmlDocumentState*) -> bool:
    return this.m_ever_populated

## Ported from DocumentState.h:67 Web::HTML::DocumentState::set_ever_populated.
pub func html_document_state_set_ever_populated(this: HtmlDocumentState*, ever_populated: bool):
    this.m_ever_populated = ever_populated

## Ported from DocumentState.h:69 Web::HTML::DocumentState::navigable_target_name.
pub func html_document_state_navigable_target_name(this: const HtmlDocumentState*) -> ak.String:
    return this.m_navigable_target_name

## Ported from DocumentState.h:70 Web::HTML::DocumentState::set_navigable_target_name.
pub func html_document_state_set_navigable_target_name(this: HtmlDocumentState*, navigable_target_name: ak.String):
    this.m_navigable_target_name = navigable_target_name

# mark: SessionHistoryEntry =====================================================================

## Ported from SessionHistoryEntry.cpp:15 Web::HTML::SessionHistoryEntry::create.
pub func html_session_history_entry_create() -> HtmlSessionHistoryEntry*:
    let this = new HtmlSessionHistoryEntry(m_step = I32OrHtmlSessionHistoryEntryPending.html_session_history_entry_pending(HtmlSessionHistoryEntryPending.tag), m_url = web_url.url_empty()) else trap("out of memory")
    html_session_history_entry_construct(this)
    return this

## Ported from SessionHistoryEntry.cpp:25 Web::HTML::SessionHistoryEntry::SessionHistoryEntry, with
## the default member initializers.
pub func html_session_history_entry_construct(this: HtmlSessionHistoryEntry*):
    this.m_step = I32OrHtmlSessionHistoryEntryPending.html_session_history_entry_pending(HtmlSessionHistoryEntryPending.tag)
    this.m_scroll_restoration_mode = HtmlScrollRestorationMode.auto
    this.m_classic_history_api_state = html_structured_serialize_for_storage(vm_the(), js_null()) else trap("MUST: structured_serialize_for_storage")
    this.m_navigation_api_state = html_structured_serialize_for_storage(vm_the(), js_undefined()) else trap("MUST: structured_serialize_for_storage")
    this.m_navigation_api_key = crypto_generate_random_uuid()
    this.m_navigation_api_id = crypto_generate_random_uuid()

## Ported from SessionHistoryEntry.h:40 Web::HTML::SessionHistoryEntry::step.
pub func html_session_history_entry_step(this: const HtmlSessionHistoryEntry*) -> I32OrHtmlSessionHistoryEntryPending:
    return this.m_step

## Ported from SessionHistoryEntry.h:41 Web::HTML::SessionHistoryEntry::set_step.
pub func html_session_history_entry_set_step(this: HtmlSessionHistoryEntry*, step: I32OrHtmlSessionHistoryEntryPending):
    this.m_step = step

## Ported from SessionHistoryEntry.h:43 Web::HTML::SessionHistoryEntry::url.
pub func html_session_history_entry_url(this: const HtmlSessionHistoryEntry*) -> web_url.Url:
    return this.m_url

## Ported from SessionHistoryEntry.h:44 Web::HTML::SessionHistoryEntry::set_url.
pub func html_session_history_entry_set_url(this: HtmlSessionHistoryEntry*, url: web_url.Url):
    this.m_url = url

## Ported from SessionHistoryEntry.cpp:22 Web::HTML::SessionHistoryEntry::document_state.
pub func html_session_history_entry_document_state(this: const HtmlSessionHistoryEntry*) -> HtmlDocumentState*?:
    return this.m_document_state

## Ported from SessionHistoryEntry.cpp:23 Web::HTML::SessionHistoryEntry::set_document_state.
pub func html_session_history_entry_set_document_state(this: HtmlSessionHistoryEntry*, document_state: HtmlDocumentState*?):
    this.m_document_state = document_state

## Ported from SessionHistoryEntry.h:49 Web::HTML::SessionHistoryEntry::classic_history_api_state.
pub func html_session_history_entry_classic_history_api_state(this: const HtmlSessionHistoryEntry*) -> ak.Vector[u8]:
    return this.m_classic_history_api_state

## Ported from SessionHistoryEntry.h:50 Web::HTML::SessionHistoryEntry::set_classic_history_api_state.
pub func html_session_history_entry_set_classic_history_api_state(this: HtmlSessionHistoryEntry*, classic_history_api_state: ak.Vector[u8]):
    this.m_classic_history_api_state = classic_history_api_state

## Ported from SessionHistoryEntry.h:52 Web::HTML::SessionHistoryEntry::navigation_api_state.
pub func html_session_history_entry_navigation_api_state(this: const HtmlSessionHistoryEntry*) -> ak.Vector[u8]:
    return this.m_navigation_api_state

## Ported from SessionHistoryEntry.h:53 Web::HTML::SessionHistoryEntry::set_navigation_api_state.
pub func html_session_history_entry_set_navigation_api_state(this: HtmlSessionHistoryEntry*, navigation_api_state: ak.Vector[u8]):
    this.m_navigation_api_state = navigation_api_state

## Ported from SessionHistoryEntry.h:55 Web::HTML::SessionHistoryEntry::navigation_api_key.
pub func html_session_history_entry_navigation_api_key(this: const HtmlSessionHistoryEntry*) -> ak.String:
    return this.m_navigation_api_key

## Ported from SessionHistoryEntry.h:56 Web::HTML::SessionHistoryEntry::set_navigation_api_key.
pub func html_session_history_entry_set_navigation_api_key(this: HtmlSessionHistoryEntry*, navigation_api_key: ak.String):
    this.m_navigation_api_key = navigation_api_key

## Ported from SessionHistoryEntry.h:58 Web::HTML::SessionHistoryEntry::navigation_api_id.
pub func html_session_history_entry_navigation_api_id(this: const HtmlSessionHistoryEntry*) -> ak.String:
    return this.m_navigation_api_id

## Ported from SessionHistoryEntry.h:59 Web::HTML::SessionHistoryEntry::set_navigation_api_id.
pub func html_session_history_entry_set_navigation_api_id(this: HtmlSessionHistoryEntry*, navigation_api_id: ak.String):
    this.m_navigation_api_id = navigation_api_id

## Ported from SessionHistoryEntry.h:61 Web::HTML::SessionHistoryEntry::scroll_restoration_mode.
pub func html_session_history_entry_scroll_restoration_mode(this: const HtmlSessionHistoryEntry*) -> HtmlScrollRestorationMode:
    return this.m_scroll_restoration_mode

## Ported from SessionHistoryEntry.h:62 Web::HTML::SessionHistoryEntry::set_scroll_restoration_mode.
pub func html_session_history_entry_set_scroll_restoration_mode(this: HtmlSessionHistoryEntry*, scroll_restoration_mode: HtmlScrollRestorationMode):
    this.m_scroll_restoration_mode = scroll_restoration_mode