ladybird/Userland/Libraries/LibWeb/HTML/SessionHistoryEntry.h
Shannon Booth e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00

90 lines
3.6 KiB
C++

/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/WeakPtr.h>
#include <LibJS/Heap/Cell.h>
#include <LibJS/Heap/GCPtr.h>
#include <LibURL/URL.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/PolicyContainers.h>
#include <LibWeb/HTML/StructuredSerialize.h>
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/history.html#scroll-restoration-mode
enum class ScrollRestorationMode {
// https://html.spec.whatwg.org/multipage/history.html#dom-scrollrestoration-auto
// The user agent is responsible for restoring the scroll position upon navigation.
Auto,
// https://html.spec.whatwg.org/multipage/history.html#dom-scrollrestoration-manual
// The page is responsible for restoring the scroll position and the user agent does not attempt to do so automatically.
Manual,
};
// https://html.spec.whatwg.org/multipage/history.html#session-history-entry
struct SessionHistoryEntry final : public JS::Cell {
JS_CELL(SessionHistoryEntry, JS::Cell);
JS_DECLARE_ALLOCATOR(SessionHistoryEntry);
SessionHistoryEntry();
void visit_edges(Cell::Visitor&) override;
enum class Pending {
Tag,
};
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-step
// step, a non-negative integer or "pending", initially "pending".
Variant<int, Pending> step { Pending::Tag };
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-url
// URL, a URL
URL::URL url;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-document-state
JS::GCPtr<HTML::DocumentState> document_state;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-classic-history-api-state
// classic history API state, which is serialized state, initially StructuredSerializeForStorage(null).
SerializationRecord classic_history_api_state;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-state
// navigation API state, which is a serialized state, initially StructuredSerializeForStorage(undefined).
SerializationRecord navigation_api_state;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-key
// navigation API key, which is a string, initially set to the result of generating a random UUID.
String navigation_api_key;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-id
// navigation API ID, which is a string, initially set to the result of generating a random UUID.
String navigation_api_id;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-scroll-restoration-mode
// scroll restoration mode, a scroll restoration mode, initially "auto"
ScrollRestorationMode scroll_restoration_mode { ScrollRestorationMode::Auto };
// policy container, a policy container or null
Optional<PolicyContainer> policy_container;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-scroll-position
// FIXME: scroll position data, which is scroll position data for the document's restorable scrollable regions
// browsing context name, a browsing context name or null, initially null
Optional<ByteString> browsing_context_name;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-other
// FIXME: persisted user state, which is implementation-defined, initially null
// NOTE: This is where we could remember the state of form controls, for example.
JS::GCPtr<BrowsingContext> original_source_browsing_context;
};
}