TraversableNavigable.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Vector.h>
  8. #include <LibWeb/HTML/Navigable.h>
  9. #include <LibWeb/HTML/VisibilityState.h>
  10. namespace Web::HTML {
  11. // https://html.spec.whatwg.org/multipage/document-sequences.html#traversable-navigable
  12. class TraversableNavigable final : public Navigable {
  13. JS_CELL(TraversableNavigable, Navigable);
  14. public:
  15. static WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> create_a_new_top_level_traversable(Page&, JS::GCPtr<BrowsingContext> opener, String target_name);
  16. static WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> create_a_fresh_top_level_traversable(Page&, AK::URL const& initial_navigation_url, Variant<Empty, String, POSTResource> = Empty {});
  17. virtual ~TraversableNavigable() override;
  18. bool is_top_level_traversable() const;
  19. int current_session_history_step() const { return m_current_session_history_step; };
  20. Vector<JS::NonnullGCPtr<SessionHistoryEntry>>& session_history_entries() { return m_session_history_entries; };
  21. Vector<JS::NonnullGCPtr<SessionHistoryEntry>> const& session_history_entries() const { return m_session_history_entries; };
  22. bool running_nested_apply_history_step() const { return m_running_nested_apply_history_step; };
  23. VisibilityState system_visibility_state() const { return m_system_visibility_state; };
  24. Vector<int> get_all_used_history_steps() const;
  25. void clear_the_forward_session_history();
  26. private:
  27. TraversableNavigable();
  28. virtual void visit_edges(Cell::Visitor&) override;
  29. // https://html.spec.whatwg.org/multipage/document-sequences.html#tn-current-session-history-step
  30. int m_current_session_history_step { 0 };
  31. // https://html.spec.whatwg.org/multipage/document-sequences.html#tn-session-history-entries
  32. Vector<JS::NonnullGCPtr<SessionHistoryEntry>> m_session_history_entries;
  33. // FIXME: https://html.spec.whatwg.org/multipage/document-sequences.html#tn-session-history-traversal-queue
  34. // https://html.spec.whatwg.org/multipage/document-sequences.html#tn-running-nested-apply-history-step
  35. bool m_running_nested_apply_history_step { false };
  36. // https://html.spec.whatwg.org/multipage/document-sequences.html#system-visibility-state
  37. VisibilityState m_system_visibility_state { VisibilityState::Visible };
  38. };
  39. }