1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/URL.h>
#include <LibJS/Heap/Cell.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/POSTResource.h>
#include <LibWeb/HTML/PolicyContainers.h>
#include <LibWeb/ReferrerPolicy/ReferrerPolicy.h>
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-2
class DocumentState final : public JS::Cell {
JS_CELL(DocumentState, JS::Cell);
public:
struct NestedHistory {
String id;
Vector<JS::NonnullGCPtr<SessionHistoryEntry>> entries;
};
virtual ~DocumentState();
enum class Client {
Tag,
};
enum class NoReferrer {
Tag,
};
[[nodiscard]] JS::GCPtr<DOM::Document> document() const { return m_document; }
void set_document(JS::GCPtr<DOM::Document> document) { m_document = document; }
[[nodiscard]] Variant<PolicyContainer, Client> history_policy_container() const { return m_history_policy_container; }
void set_history_policy_container(Variant<PolicyContainer, Client> history_policy_container) { m_history_policy_container = move(history_policy_container); }
[[nodiscard]] Variant<NoReferrer, Client, AK::URL> request_referrer() const { return m_request_referrer; }
void set_request_referrer(Variant<NoReferrer, Client, AK::URL> request_referrer) { m_request_referrer = move(request_referrer); }
[[nodiscard]] ReferrerPolicy::ReferrerPolicy request_referrer_policy() const { return m_request_referrer_policy; }
void set_request_referrer_policy(ReferrerPolicy::ReferrerPolicy request_referrer_policy) { m_request_referrer_policy = move(request_referrer_policy); }
[[nodiscard]] Optional<HTML::Origin> initiator_origin() const { return m_initiator_origin; }
void set_initiator_origin(Optional<HTML::Origin> initiator_origin) { m_initiator_origin = move(initiator_origin); }
[[nodiscard]] Optional<HTML::Origin> origin() const { return m_origin; }
void set_origin(Optional<HTML::Origin> origin) { m_origin = move(origin); }
[[nodiscard]] Vector<NestedHistory> const& nested_histories() const { return m_nested_histories; }
[[nodiscard]] Vector<NestedHistory>& nested_histories() { return m_nested_histories; }
[[nodiscard]] Variant<Empty, String, POSTResource> resource() const { return m_resource; }
void set_resource(Variant<Empty, String, POSTResource> resource) { m_resource = move(resource); }
[[nodiscard]] bool reload_pending() const { return m_reload_pending; }
void set_reload_pending(bool reload_pending) { m_reload_pending = reload_pending; }
[[nodiscard]] bool ever_populated() const { return m_ever_populated; }
void set_ever_populated(bool ever_populated) { m_ever_populated = ever_populated; }
[[nodiscard]] String ever_navigable_target_name() const { return m_navigable_target_name; }
void set_navigable_target_name(String navigable_target_name) { m_navigable_target_name = navigable_target_name; }
private:
DocumentState();
void visit_edges(Cell::Visitor&) override;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-document
JS::GCPtr<DOM::Document> m_document;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-history-policy-container
Variant<PolicyContainer, Client> m_history_policy_container { Client::Tag };
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-request-referrer
Variant<NoReferrer, Client, AK::URL> m_request_referrer { Client::Tag };
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-request-referrer-policy
ReferrerPolicy::ReferrerPolicy m_request_referrer_policy { ReferrerPolicy::DEFAULT_REFERRER_POLICY };
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-initiator-origin
Optional<HTML::Origin> m_initiator_origin;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-origin
Optional<HTML::Origin> m_origin;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-nested-histories
Vector<NestedHistory> m_nested_histories;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-resource
Variant<Empty, String, POSTResource> m_resource {};
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-reload-pending
bool m_reload_pending { false };
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-ever-populated
bool m_ever_populated { false };
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#document-state-nav-target-name
String m_navigable_target_name;
};
}
|