/* * Copyright (c) 2022, Andreas Kling * Copyright (c) 2023, Aliaksandr Kalenik * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include namespace Web::HTML { enum class CSPNavigationType { Other, FormSubmission, }; // https://html.spec.whatwg.org/multipage/document-sequences.html#navigable class Navigable : public JS::Cell { JS_CELL(Navigable, JS::Cell); public: virtual ~Navigable() override; ErrorOr initialize_navigable(JS::NonnullGCPtr document_state, JS::GCPtr parent); Vector> child_navigables() const; String const& id() const { return m_id; } JS::GCPtr 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 active_session_history_entry() const { return m_active_session_history_entry; } JS::GCPtr current_session_history_entry() const { return m_current_session_history_entry; } void set_current_session_history_entry(JS::GCPtr entry) { m_current_session_history_entry = entry; } Vector>& get_session_history_entries() const; void activate_history_entry(JS::GCPtr); JS::GCPtr active_document(); JS::GCPtr active_browsing_context(); JS::GCPtr active_window_proxy(); JS::GCPtr active_window(); JS::GCPtr get_the_target_history_entry(int target_step) const; String target_name() const; JS::GCPtr container() const; JS::GCPtr container_document() const; JS::GCPtr traversable_navigable() const; JS::GCPtr top_level_traversable(); enum class WindowType { ExistingOrNone, NewAndUnrestricted, NewWithNoOpener, }; struct ChosenNavigable { JS::GCPtr navigable; WindowType window_type; }; ChosenNavigable choose_a_navigable(StringView name, TokenizedFeature::NoOpener no_opener, ActivateTab = ActivateTab::Yes); static JS::GCPtr navigable_with_active_document(JS::NonnullGCPtr); enum class Traversal { Tag }; Variant ongoing_navigation() const { return m_ongoing_navigation; } WebIDL::ExceptionOr populate_session_history_entry_document(JS::GCPtr, Optional, Optional navigation_id, SourceSnapshotParams const&, bool allow_POST, Function); WebIDL::ExceptionOr navigate( AK::URL const&, JS::NonnullGCPtr source_document, Variant document_resource = Empty {}, JS::GCPtr = nullptr, bool exceptions_enabled = false, HistoryHandlingBehavior = HistoryHandlingBehavior::Push, CSPNavigationType csp_navigation_type = CSPNavigationType::Other, ReferrerPolicy::ReferrerPolicy = ReferrerPolicy::ReferrerPolicy::EmptyString); WebIDL::ExceptionOr navigate_to_a_fragment(AK::URL const&, HistoryHandlingBehavior, String navigation_id); WebIDL::ExceptionOr navigate_to_a_javascript_url(AK::URL const&, HistoryHandlingBehavior, Origin const& initiator_origin, CSPNavigationType csp_navigation_type); void reload(); protected: Navigable(); virtual void visit_edges(Cell::Visitor&) override; // https://html.spec.whatwg.org/multipage/browsing-the-web.html#ongoing-navigation Variant m_ongoing_navigation; 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 m_parent; // https://html.spec.whatwg.org/multipage/document-sequences.html#nav-current-history-entry JS::GCPtr m_current_session_history_entry; // https://html.spec.whatwg.org/multipage/document-sequences.html#nav-active-history-entry JS::GCPtr 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 m_container; }; }