SessionHistoryEntry.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. SessionHistoryEntry();
  28. void visit_edges(Cell::Visitor&) override;
  29. enum class Pending {
  30. Tag,
  31. };
  32. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-step
  33. // step, a non-negative integer or "pending", initially "pending".
  34. Variant<int, Pending> step { Pending::Tag };
  35. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-url
  36. // URL, a URL
  37. AK::URL url;
  38. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-document-state
  39. JS::GCPtr<HTML::DocumentState> document_state;
  40. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-classic-history-api-state
  41. // classic history API state, which is serialized state, initially StructuredSerializeForStorage(null).
  42. SerializationRecord classic_history_api_state;
  43. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-state
  44. // navigation API state, which is a serialized state, initially StructuredSerializeForStorage(undefined).
  45. SerializationRecord navigation_api_state;
  46. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-key
  47. // navigation API key, which is a string, initially set to the result of generating a random UUID.
  48. String navigation_api_key;
  49. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-id
  50. // navigation API ID, which is a string, initially set to the result of generating a random UUID.
  51. String navigation_api_id;
  52. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-scroll-restoration-mode
  53. // scroll restoration mode, a scroll restoration mode, initially "auto"
  54. ScrollRestorationMode scroll_restoration_mode { ScrollRestorationMode::Auto };
  55. // policy container, a policy container or null
  56. Optional<PolicyContainer> policy_container;
  57. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-scroll-position
  58. // FIXME: scroll position data, which is scroll position data for the document's restorable scrollable regions
  59. // browsing context name, a browsing context name or null, initially null
  60. Optional<DeprecatedString> browsing_context_name;
  61. // https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-other
  62. // FIXME: persisted user state, which is implementation-defined, initially null
  63. // NOTE: This is where we could remember the state of form controls, for example.
  64. JS::GCPtr<BrowsingContext> original_source_browsing_context;
  65. };
  66. }