SessionHistoryEntry.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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/URL.h>
  8. #include <AK/WeakPtr.h>
  9. #include <LibJS/Heap/Cell.h>
  10. #include <LibJS/Heap/GCPtr.h>
  11. #include <LibWeb/Forward.h>
  12. #include <LibWeb/HTML/PolicyContainers.h>
  13. #include <LibWeb/HTML/StructuredSerialize.h>
  14. namespace Web::HTML {
  15. // https://html.spec.whatwg.org/multipage/history.html#scroll-restoration-mode
  16. enum class ScrollRestorationMode {
  17. // https://html.spec.whatwg.org/multipage/history.html#dom-scrollrestoration-auto
  18. // The user agent is responsible for restoring the scroll position upon navigation.
  19. Auto,
  20. // https://html.spec.whatwg.org/multipage/history.html#dom-scrollrestoration-manual
  21. // The page is responsible for restoring the scroll position and the user agent does not attempt to do so automatically.
  22. Manual,
  23. };
  24. // https://html.spec.whatwg.org/multipage/history.html#session-history-entry
  25. struct SessionHistoryEntry final : public JS::Cell {
  26. JS_CELL(SessionHistoryEntry, JS::Cell);
  27. JS_DECLARE_ALLOCATOR(SessionHistoryEntry);
  28. SessionHistoryEntry();
  29. void visit_edges(Cell::Visitor&) override;
  30. enum class Pending {
  31. Tag,
  32. };
  33. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-step
  34. // step, a non-negative integer or "pending", initially "pending".
  35. Variant<int, Pending> step { Pending::Tag };
  36. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-url
  37. // URL, a URL
  38. URL url;
  39. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-document-state
  40. JS::GCPtr<HTML::DocumentState> document_state;
  41. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-classic-history-api-state
  42. // classic history API state, which is serialized state, initially StructuredSerializeForStorage(null).
  43. SerializationRecord classic_history_api_state;
  44. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-state
  45. // navigation API state, which is a serialized state, initially StructuredSerializeForStorage(undefined).
  46. SerializationRecord navigation_api_state;
  47. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-key
  48. // navigation API key, which is a string, initially set to the result of generating a random UUID.
  49. String navigation_api_key;
  50. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-id
  51. // navigation API ID, which is a string, initially set to the result of generating a random UUID.
  52. String navigation_api_id;
  53. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-scroll-restoration-mode
  54. // scroll restoration mode, a scroll restoration mode, initially "auto"
  55. ScrollRestorationMode scroll_restoration_mode { ScrollRestorationMode::Auto };
  56. // policy container, a policy container or null
  57. Optional<PolicyContainer> policy_container;
  58. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-scroll-position
  59. // FIXME: scroll position data, which is scroll position data for the document's restorable scrollable regions
  60. // browsing context name, a browsing context name or null, initially null
  61. Optional<ByteString> browsing_context_name;
  62. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-other
  63. // FIXME: persisted user state, which is implementation-defined, initially null
  64. // NOTE: This is where we could remember the state of form controls, for example.
  65. JS::GCPtr<BrowsingContext> original_source_browsing_context;
  66. };
  67. }