2022-12-12 11:46:54 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
2023-01-01 17:46:00 +01:00
|
|
|
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
2022-12-12 11:46:54 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibJS/Heap/Cell.h>
|
|
|
|
#include <LibWeb/Forward.h>
|
2023-04-11 10:20:11 +03:00
|
|
|
#include <LibWeb/HTML/ActivateTab.h>
|
2023-01-01 17:46:00 +01:00
|
|
|
#include <LibWeb/HTML/HistoryHandlingBehavior.h>
|
|
|
|
#include <LibWeb/HTML/POSTResource.h>
|
2023-04-06 18:10:12 +03:00
|
|
|
#include <LibWeb/HTML/SourceSnapshotParams.h>
|
2023-04-11 10:20:11 +03:00
|
|
|
#include <LibWeb/HTML/TokenizedFeatures.h>
|
2022-12-12 11:46:54 +01:00
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
2023-05-07 12:47:38 -04:00
|
|
|
enum class CSPNavigationType {
|
|
|
|
Other,
|
|
|
|
FormSubmission,
|
|
|
|
};
|
|
|
|
|
2022-12-12 11:46:54 +01:00
|
|
|
// https://html.spec.whatwg.org/multipage/document-sequences.html#navigable
|
|
|
|
class Navigable : public JS::Cell {
|
|
|
|
JS_CELL(Navigable, JS::Cell);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~Navigable() override;
|
|
|
|
|
2023-04-25 20:46:32 +03:00
|
|
|
ErrorOr<void> initialize_navigable(JS::NonnullGCPtr<DocumentState> document_state, JS::GCPtr<Navigable> parent);
|
|
|
|
|
2023-04-06 23:16:38 +03:00
|
|
|
Vector<JS::Handle<Navigable>> child_navigables() const;
|
|
|
|
|
2022-12-12 11:46:54 +01:00
|
|
|
String const& id() const { return m_id; };
|
|
|
|
JS::GCPtr<Navigable> parent() const { return m_parent; };
|
|
|
|
|
|
|
|
bool is_closing() const { return m_closing; };
|
|
|
|
void set_closing(bool value) { m_closing = value; };
|
|
|
|
|
|
|
|
bool is_delaying_load_events() const { return m_delaying_load_events; };
|
|
|
|
void set_delaying_load_events(bool value) { m_delaying_load_events = value; };
|
|
|
|
|
|
|
|
JS::GCPtr<SessionHistoryEntry> active_session_history_entry() const { return m_active_session_history_entry; };
|
|
|
|
JS::GCPtr<SessionHistoryEntry> current_session_history_entry() const { return m_current_session_history_entry; };
|
2023-04-06 23:28:08 +03:00
|
|
|
void set_current_session_history_entry(JS::GCPtr<SessionHistoryEntry> entry) { m_current_session_history_entry = entry; };
|
2022-12-12 11:46:54 +01:00
|
|
|
|
2023-04-06 18:08:44 +03:00
|
|
|
Vector<JS::NonnullGCPtr<SessionHistoryEntry>>& get_session_history_entries() const;
|
|
|
|
|
2023-04-06 23:33:21 +03:00
|
|
|
void activate_history_entry(JS::GCPtr<SessionHistoryEntry>);
|
|
|
|
|
2022-12-12 11:46:54 +01:00
|
|
|
JS::GCPtr<DOM::Document> active_document();
|
|
|
|
JS::GCPtr<BrowsingContext> active_browsing_context();
|
|
|
|
JS::GCPtr<WindowProxy> active_window_proxy();
|
|
|
|
JS::GCPtr<Window> active_window();
|
|
|
|
|
2023-04-06 23:30:02 +03:00
|
|
|
JS::GCPtr<SessionHistoryEntry> get_the_target_history_entry(int target_step) const;
|
|
|
|
|
2022-12-12 11:46:54 +01:00
|
|
|
String target_name() const;
|
|
|
|
|
|
|
|
JS::GCPtr<NavigableContainer> container() const;
|
|
|
|
|
2023-04-06 12:06:45 +03:00
|
|
|
JS::GCPtr<TraversableNavigable> traversable_navigable() const;
|
2022-12-12 12:17:46 +01:00
|
|
|
JS::GCPtr<TraversableNavigable> top_level_traversable();
|
2022-12-12 12:07:41 +01:00
|
|
|
|
2023-04-11 10:20:11 +03:00
|
|
|
enum class WindowType {
|
|
|
|
ExistingOrNone,
|
|
|
|
NewAndUnrestricted,
|
|
|
|
NewWithNoOpener,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ChosenNavigable {
|
|
|
|
JS::GCPtr<Navigable> navigable;
|
|
|
|
WindowType window_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
ChosenNavigable choose_a_navigable(StringView name, TokenizedFeature::NoOpener no_opener, ActivateTab = ActivateTab::Yes);
|
|
|
|
|
2023-01-01 17:43:05 +01:00
|
|
|
static JS::GCPtr<Navigable> navigable_with_active_document(JS::NonnullGCPtr<DOM::Document>);
|
|
|
|
|
2023-04-24 21:37:35 +03:00
|
|
|
enum class Traversal {
|
|
|
|
Tag
|
|
|
|
};
|
|
|
|
|
|
|
|
Variant<Empty, Traversal, String> ongoing_navigation() const { return m_ongoing_navigation; }
|
|
|
|
|
2023-04-06 18:10:12 +03:00
|
|
|
WebIDL::ExceptionOr<void> populate_session_history_entry_document(JS::GCPtr<SessionHistoryEntry>, Optional<NavigationParams>, Optional<String> navigation_id, SourceSnapshotParams const&, Function<void()>);
|
|
|
|
|
2023-01-01 17:46:00 +01:00
|
|
|
WebIDL::ExceptionOr<void> navigate(
|
|
|
|
AK::URL const&,
|
|
|
|
JS::NonnullGCPtr<DOM::Document> source_document,
|
|
|
|
Variant<Empty, String, POSTResource> document_resource = Empty {},
|
|
|
|
JS::GCPtr<Fetch::Infrastructure::Response> = nullptr,
|
|
|
|
bool exceptions_enabled = false,
|
|
|
|
HistoryHandlingBehavior = HistoryHandlingBehavior::Push,
|
2023-05-07 12:47:38 -04:00
|
|
|
CSPNavigationType csp_navigation_type = CSPNavigationType::Other,
|
2023-01-01 17:46:00 +01:00
|
|
|
ReferrerPolicy::ReferrerPolicy = ReferrerPolicy::ReferrerPolicy::EmptyString);
|
|
|
|
|
|
|
|
WebIDL::ExceptionOr<void> navigate_to_a_fragment(AK::URL const&, HistoryHandlingBehavior, String navigation_id);
|
|
|
|
|
2023-05-07 12:47:38 -04:00
|
|
|
WebIDL::ExceptionOr<void> navigate_to_a_javascript_url(AK::URL const&, HistoryHandlingBehavior, Origin const& initiator_origin, CSPNavigationType csp_navigation_type);
|
2023-01-01 17:46:00 +01:00
|
|
|
|
2023-04-07 00:08:39 +03:00
|
|
|
void reload();
|
|
|
|
|
2022-12-12 11:46:54 +01:00
|
|
|
protected:
|
|
|
|
Navigable();
|
|
|
|
|
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
2023-04-24 21:37:35 +03:00
|
|
|
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#ongoing-navigation
|
|
|
|
Variant<Empty, Traversal, String> m_ongoing_navigation;
|
|
|
|
|
2022-12-12 11:46:54 +01:00
|
|
|
private:
|
|
|
|
// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-id
|
|
|
|
String m_id;
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-parent
|
|
|
|
JS::GCPtr<Navigable> m_parent;
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-current-history-entry
|
|
|
|
JS::GCPtr<SessionHistoryEntry> m_current_session_history_entry;
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/document-sequences.html#nav-active-history-entry
|
|
|
|
JS::GCPtr<SessionHistoryEntry> m_active_session_history_entry;
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/document-sequences.html#is-closing
|
|
|
|
bool m_closing { false };
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/document-sequences.html#delaying-load-events-mode
|
|
|
|
bool m_delaying_load_events { false };
|
|
|
|
|
|
|
|
// Implied link between navigable and its container.
|
|
|
|
JS::GCPtr<NavigableContainer> m_container;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|