TraversableNavigable.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. struct HistoryObjectLengthAndIndex {
  25. size_t script_history_length;
  26. size_t script_history_index;
  27. };
  28. HistoryObjectLengthAndIndex get_the_history_object_length_and_index(int) const;
  29. int get_the_used_step(int step) const;
  30. Vector<int> get_all_used_history_steps() const;
  31. void clear_the_forward_session_history();
  32. private:
  33. TraversableNavigable();
  34. virtual void visit_edges(Cell::Visitor&) override;
  35. // https://html.spec.whatwg.org/multipage/document-sequences.html#tn-current-session-history-step
  36. int m_current_session_history_step { 0 };
  37. // https://html.spec.whatwg.org/multipage/document-sequences.html#tn-session-history-entries
  38. Vector<JS::NonnullGCPtr<SessionHistoryEntry>> m_session_history_entries;
  39. // FIXME: https://html.spec.whatwg.org/multipage/document-sequences.html#tn-session-history-traversal-queue
  40. // https://html.spec.whatwg.org/multipage/document-sequences.html#tn-running-nested-apply-history-step
  41. bool m_running_nested_apply_history_step { false };
  42. // https://html.spec.whatwg.org/multipage/document-sequences.html#system-visibility-state
  43. VisibilityState m_system_visibility_state { VisibilityState::Visible };
  44. };
  45. }